proofsAreaTemplate :: Resources -> Html
proofsAreaTemplate res | isJust (error_msg res) = (h1 << primHtml "Error:") +++ pre << primHtml (fromJust $ error_msg res)
                       | otherwise = proofsTitle +++ ps where
  proofsTitle = h3 << (primHtml $ (show $ length $ Main.proofs res) ++ " proof(s) for \"" ++ (cleanUpSentence $ sentence res) ++"\"" )
  ps = mconcat $ map f $ zip3 (Main.proofs res) (readings res) [1..]
  cleanUpSentence s = reverse $ dropWhile isSpace $ reverse $ takeWhile (/= '=') s
  f (p,i,n) = thediv ! [ theclass "proofgroup" ] << (h3 ! [ theclass "prooftitle" ] << (primHtml $ "Proof " ++ show n)) +++ (lterm p +++ reading i +++ proof p) where
    proof p = thediv ! [ theclass "proof" ] << proof2html p
    lterm p = thediv ! [ theclass "reading" ] << paragraph << (lambda2html . betaReduce . monadReduce . etaReduce . term . snd . getVal) p
    reading i = thediv ! [ theclass "model_evaluation_result" ] << pre << primHtml i
proofsAreaTemplate :: Resources -> Html
proofsAreaTemplate res | isJust (error_msg res) = (h1 << primHtml "Error:") +++ pre << primHtml (fromJust $ error_msg res)
                       | otherwise = proofsTitle +++ ps where
  proofsTitle = h3 << (primHtml $ (show $ length $ Main.proofs res) ++ " proof(s) for \"" ++ (cleanUpSentence $ sentence res) ++"\"" )
  ps = mconcat $ map f $ zip3 (Main.proofs res) (readings res) [1..]
  cleanUpSentence s = reverse $ dropWhile isSpace $ reverse $ takeWhile (/= '=') s
  f (p,i,n) = thediv ! [ theclass "proofgroup" ] << (h3 ! [ theclass "prooftitle" ] << (primHtml $ "Proof " ++ show n)) +++ (lterm p +++ reading i +++ proof p) where
    proof p = thediv ! [ theclass "proof" ] << proof2html p
    lterm p = thediv ! [ theclass "reading" ] << paragraph << (lambda2html . betaReduce . monadReduce . etaReduce . term . snd . getVal) p
    reading i = thediv ! [ theclass "model_evaluation_result" ] << pre << primHtml i
proofsAreaTemplate res | isJust (error_msg res) = (h1 << primHtml "Error:") +++ pre << primHtml (fromJust $ error_msg res)
                       | otherwise = proofsTitle +++ ps where
  proofsTitle = h3 << (primHtml $ (show $ length $ Main.proofs res) ++ " proof(s) for \"" ++ (cleanUpSentence $ sentence res) ++"\"" )
  ps = mconcat $ map f $ zip3 (Main.proofs res) (readings res) [1..]
  cleanUpSentence s = reverse $ dropWhile isSpace $ reverse $ takeWhile (/= '=') s
  f (p,i,n) = thediv ! [ theclass "proofgroup" ] << (h3 ! [ theclass "prooftitle" ] << (primHtml $ "Proof " ++ show n)) +++ (lterm p +++ reading i +++ proof p) where
    proof p = thediv ! [ theclass "proof" ] << proof2html p
    lterm p = thediv ! [ theclass "reading" ] << paragraph << (lambda2html . betaReduce . monadReduce . etaReduce . term . snd . getVal) p
    reading i = thediv ! [ theclass "model_evaluation_result" ] << pre << primHtml i