packages feed

free-theorems-webui 0.2.1.0 → 0.2.1.1

raw patch · 3 files changed

+29/−25 lines, 3 files

Files

GeneratePDF.hs view
@@ -18,17 +18,17 @@  newtype PDF = PDF { fromPDF :: B.ByteString } -generatePDF model showTheorem decls sig im = do+generatePDF model showOptions decls sig im = do    setHeader "Content-type" "application/pdf"-   pdf <- liftIO (typeset $ asTeX model showTheorem decls sig im)+   pdf <- liftIO (typeset $ asTeX model showOptions decls sig im)    outputFPS (fromPDF pdf) -generateTeX model showTheorem decls sig im = do+generateTeX model showOptions decls sig im = do    setHeader "Content-type" "text/plain"-   output $ asTeX model showTheorem decls sig im+   output $ asTeX model showOptions decls sig im  -asTeX model showTheorem decls sig im =+asTeX model showOptions decls sig im =   intercalate "\n" $     [ "\\documentclass{article}"     , "\\usepackage{amsmath}"@@ -45,27 +45,31 @@     , "in the sublanguage of Haskell with " ++ show model ++ ", is:"     , ""     , formula (showTheorem (ifAllowed simplify $ asTheorem im))-    , formula (intercalate parBreak (map (show . ifAllowed simplifyUnfoldedLift) (unfoldLifts decls im)))-    , formula (intercalate parBreak (map show (unfoldClasses decls im)))+    , formula (intercalate parBreak (map (showLift . ifAllowed simplifyUnfoldedLift) (unfoldLifts decls im)))+    , formula (intercalate parBreak (map showClass (unfoldClasses decls im)))      , "Reducing all permissible relation variables to functions yields:"     , ""-    , formula ((showTheorem (ifAllowed simplify $ asTheorem im2)))-    , formula (intercalate parBreak (map (show . ifAllowed simplifyUnfoldedLift) (unfoldLifts decls im2)))-    , formula (intercalate parBreak (map show (unfoldClasses decls im2)))+    , formula ((showTheorem  (ifAllowed simplify $ asTheorem im2)))+    , formula (intercalate parBreak (map (showLift . ifAllowed simplifyUnfoldedLift) (unfoldLifts decls im2)))+    , formula (intercalate parBreak (map showClass (unfoldClasses decls im2)))      ] ++ (if isInequational model              then [ "Instead reducing all permissible relation variables to the inverses of functions yields:"                   , ""                   , formula (showTheorem (ifAllowed simplify $ asTheorem im3))-                  , formula (intercalate parBreak (map (show . ifAllowed simplifyUnfoldedLift) (unfoldLifts decls im3)))-                  , formula (intercalate parBreak (map show (unfoldClasses decls im3)))+                  , formula (intercalate parBreak (map (showLift . ifAllowed simplifyUnfoldedLift) (unfoldLifts decls im3)))+                  , formula (intercalate parBreak (map showClass (unfoldClasses decls im3)))                   ]              else []          ) ++     [ "\\end{document}"     ]     where+       -- Different show functions+       showTheorem = show . prettyTheorem showOptions+       showLift    = show . prettyUnfoldedLift showOptions+       showClass   = show . prettyUnfoldedClass showOptions        -- Return the argument if simplifications are allowed        ifAllowed smpl = case model of                             BasicSubset -> smpl
Main.hs view
@@ -41,7 +41,7 @@                      Just "pdf"       -> generatePDF        model   = modelFromOptions inputs        xtraSrc = fromMaybe "" $ lookup "xtraSrc" inputs-       showTheorem = showTheoremFromOptions inputs+       --showTheorem = showTheoremFromOptions inputs        outputHtml = output . renderHtml . input_page inputs        reportError title text = outputHtml $ errorBox title text    case lookup "type" inputs of@@ -58,7 +58,7 @@                      Right sig ->                         case interpret decls model sig of                            Nothing -> reportError "Error while interpreting signature" "not possible"-                           Just im -> generate model showTheorem decls sig im+                           Just im -> generate model (showOptions inputs) decls sig im  modelFromOptions opts =    case lookup "model" opts of@@ -71,31 +71,31 @@       styleFromOption "eq"   = EquationalTheorem       styleFromOption "ineq" = InequationalTheorem -showTheoremFromOptions opts =+showOptions opts =    case lookup "hideTypeInstantiations" opts of-      Just "yes" -> show . prettyTheorem [OmitTypeInstantiations]-      Nothing    -> show . prettyTheorem []+      Just "yes" -> [OmitTypeInstantiations]+      Nothing    -> []   data FormulaeFormat = Graphical -- Formulae are rendered as graphics                     | PlainText -- Formulae are rendered as plain text -generateHTML formulaeFormat inputs model showTheorem decls sig im = do+generateHTML formulaeFormat inputs model showOptions decls sig im = do    -- Select the appropriate rendering action   let (renderTheorem, renderLifts, renderClasses) =          case formulaeFormat of             Graphical ->                -- Convert to string and pass to the TeX renderer.-               ( liftIO . typesetAsHtmlImg      . showTheorem . asTheorem-               , liftIO . mapM typesetAsHtmlImg . map show-               , liftIO . mapM typesetAsHtmlImg . map show+               ( liftIO . typesetAsHtmlImg      . (show . prettyTheorem showOptions) . asTheorem+               , liftIO . mapM typesetAsHtmlImg . map (show . prettyUnfoldedLift showOptions)+               , liftIO . mapM typesetAsHtmlImg . map (show . prettyUnfoldedClass showOptions)                )             PlainText ->                -- Just convert everything to string.-               ( return . stringToHtml . showTheorem . asTheorem-               , return . map (stringToHtml . show)-               , return . map (stringToHtml . show)+               ( return . stringToHtml . (show . prettyTheorem showOptions) . asTheorem+               , return . map (stringToHtml . show . prettyUnfoldedLift showOptions)+               , return . map (stringToHtml . show . prettyUnfoldedClass showOptions)                )    -- Render all formulae to Html/[Html] with the selected method
free-theorems-webui.cabal view
@@ -1,5 +1,5 @@ Name:     free-theorems-webui-Version:  0.2.1.0+Version:  0.2.1.1  Synopsis: CGI-based web interface for the free-theorems package. Description: