-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
346 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
-- | Module used for re-rexporting | ||
module FMCt.Web | ||
( module X | ||
) | ||
where | ||
-- | Module used for re-rexporting | ||
module FMCt.Web ( | ||
module X, | ||
) where | ||
|
||
import FMCt.Web.MainWebsite as X (mainWebsite) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,43 @@ | ||
{-# LANGUAGE ExtendedDefaultRules #-} | ||
module FMCt.Web.Components.Brick | ||
(brick) | ||
where | ||
|
||
module FMCt.Web.Components.Brick (brick) where | ||
|
||
import Data.String (IsString (..)) | ||
import qualified Data.Text as LA | ||
import FMCt.Web.Style.StdStylingHeader (stdStylingHeader) | ||
import qualified Data.Text as LA | ||
import qualified Lucid as LU | ||
import qualified Lucid as LU | ||
import qualified Lucid.Bootstrap as LB | ||
import Data.String(IsString(..)) | ||
|
||
-- | The main component used for the website. | ||
brick | ||
:: ( IsString a, Show a, LU.ToHtml a | ||
, IsString b, Show b, LU.ToHtml b | ||
, IsString c, Show c, LU.ToHtml c | ||
, IsString d, Show d, LU.ToHtml d | ||
) | ||
=> a -- ^ Component Name | ||
-> b -- ^ Title | ||
-> c -- ^ SubTitle | ||
-> d -- ^ Content | ||
-> LU.Html () -- ^ Brick Component | ||
brick :: | ||
( IsString a | ||
, Show a | ||
, LU.ToHtml a | ||
, IsString b | ||
, Show b | ||
, LU.ToHtml b | ||
, IsString c | ||
, Show c | ||
, LU.ToHtml c | ||
, IsString d | ||
, Show d | ||
, LU.ToHtml d | ||
) => | ||
-- | Component Name | ||
a -> | ||
-- | Title | ||
b -> | ||
-- | SubTitle | ||
c -> | ||
-- | Content | ||
d -> | ||
-- | Brick Component | ||
LU.Html () | ||
brick cn ti st co = do | ||
LU.div_ [(LU.name_ . fromString . show ) cn ] $ | ||
LB.row_ $ do | ||
LB.span2_ $ LU.div_ [LU.name_ "Title" ] $ (LU.h1_ . LU.toHtml) ti | ||
LB.span2_ $ LU.div_ [LU.name_ "SubTitle" ] $ (LU.h2_ . LU.toHtml) st | ||
LU.hr_ [] | ||
LB.span2_ $ LU.div_ [LU.name_ "Content"] $ (LU.h3_ . LU.toHtml) co | ||
LU.hr_ [] | ||
|
||
LU.div_ [(LU.name_ . fromString . show) cn] $ | ||
LB.row_ $ do | ||
LB.span2_ $ LU.div_ [LU.name_ "Title"] $ (LU.h1_ . LU.toHtml) ti | ||
LB.span2_ $ LU.div_ [LU.name_ "SubTitle"] $ (LU.h2_ . LU.toHtml) st | ||
LU.hr_ [] | ||
LB.span2_ $ LU.div_ [LU.name_ "Content"] $ (LU.h3_ . LU.toHtml) co | ||
LU.hr_ [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,77 @@ | ||
module FMCt.Web.Components.DerivePage | ||
(derivePage) | ||
where | ||
module FMCt.Web.Components.DerivePage (derivePage) where | ||
|
||
import Data.List (unfoldr) | ||
import qualified Data.Text.Lazy as L | ||
import FMCt (eval1, evalToString, printStack) | ||
import FMCt.Parsing (parseFMC, parseFMCtoString) | ||
import FMCt.TypeChecker (derive) | ||
import FMCt.Web.Style.StdStylingHeader (stdStylingHeader) | ||
import Lucid | ||
import Lucid.Bootstrap | ||
import FMCt (evalToString, eval1, printStack) | ||
import FMCt.Web.Style.StdStylingHeader (stdStylingHeader) | ||
import FMCt.TypeChecker (derive) | ||
import FMCt.Parsing (parseFMCtoString, parseFMC ) | ||
import Data.List (unfoldr) | ||
|
||
derivePage :: L.Text -> L.Text | ||
derivePage term = renderText sDerivePage | ||
derivePage term = renderText sDerivePage | ||
where | ||
sDerivePage :: Html () | ||
sDerivePage = containerFluid_ $ deriveStyling >> span1_ deriveTitle >> span1_ deriveSubTitle >> span1_ page | ||
deriveStyling = stdStylingHeader "FMCt Derivation" | ||
deriveTitle = h1_ $ a_ [href_ "/" ] "FMCt-Web" | ||
deriveStyling = stdStylingHeader "FMCt Derivation" | ||
deriveTitle = h1_ $ a_ [href_ "/"] "FMCt-Web" | ||
deriveSubTitle = h2_ "Derivation" | ||
|
||
-- | Box for the derivation | ||
page :: Html () | ||
page = do | ||
body_ $ do | ||
termForm | ||
parsedBox | ||
derivationBox | ||
body_ $ do | ||
termForm | ||
parsedBox | ||
derivationBox | ||
|
||
-- | Form where the term can be inserted. | ||
termForm :: Html () | ||
termForm = do | ||
hr_ [] | ||
div_ [name_ "term-div"] $ form_ [action_ "derive" ] $ input_ [type_ "text", name_ "term"] | ||
hr_ [] | ||
div_ [name_ "term-div"] $ form_ [action_ "derive"] $ input_ [type_ "text", name_ "term"] | ||
|
||
-- | Box where the parsed term can be seen. | ||
parsedBox :: Html () | ||
parsedBox = do | ||
hr_ [] | ||
div_ [name_ "parsed-div"] $ do | ||
h2_ "Parsed Term" | ||
p_ [name_ "term-parsed"] $ (toHtml . parseFMCtoString . L.unpack) term | ||
|
||
hr_ [] | ||
div_ [name_ "parsed-div"] $ do | ||
h2_ "Parsed Term" | ||
p_ [name_ "term-parsed"] $ (toHtml . parseFMCtoString . L.unpack) term | ||
|
||
-- | Box where the parsed term can be seen. | ||
derivationBox :: Html () | ||
derivationBox = do | ||
let parsedT = (parseFMC . L.unpack) term | ||
hr_ [] | ||
div_ [name_ "parsed-div"] $ do | ||
h2_ "Parsed Term" | ||
p_ [name_ "term-parsed"] $ (rBr . show . derive ) parsedT | ||
let parsedT = (parseFMC . L.unpack) term | ||
hr_ [] | ||
div_ [name_ "parsed-div"] $ do | ||
h2_ "Parsed Term" | ||
p_ [name_ "term-parsed"] $ (rBr . show . derive) parsedT | ||
|
||
-- div_ [name_ "parsed-div"] $ do | ||
-- h2_ "Evaluation of Term" | ||
-- p_ [name_ "term-parsed"] $ (toHtml . printStack . eval1 ) parsedT | ||
|
||
|
||
-- | replace newline with Paragraph, and spaces with . | ||
rBr :: String -> Html () | ||
rBr str = aux spStr | ||
where | ||
aux x = case x of | ||
[] -> hr_ [] | ||
(x:xs) -> do p_ [] $ toHtml x | ||
aux xs | ||
|
||
[] -> hr_ [] | ||
(x : xs) -> do | ||
p_ [] $ toHtml x | ||
aux xs | ||
|
||
separateBy :: Eq a => a -> [a] -> [[a]] | ||
separateBy chr = unfoldr sep where | ||
sep [] = Nothing | ||
sep l = Just . fmap (drop 1) . break (== chr) $ l | ||
separateBy chr = unfoldr sep | ||
where | ||
sep [] = Nothing | ||
sep l = Just . fmap (drop 1) . break (== chr) $ l | ||
|
||
spStr = separateBy '\n' $ replaceSp str | ||
|
||
replaceSp [] = [] | ||
replaceSp(' ' : xs) = ' ' : replaceSp xs | ||
replaceSp (' ' : xs) = ' ' : replaceSp xs | ||
-- space taken from https://qwerty.dev/whitespace/ | ||
replaceSp( x : xs) = x : replaceSp xs | ||
replaceSp (x : xs) = x : replaceSp xs | ||
|
||
--rBr (x : xs) | ||
-- | x == '\n' = "<br>" ++ rBr xs | ||
-- | otherwise = x : rBr xs | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module FormPage where | ||
import Prelude hiding (head, id, div) | ||
|
||
import Text.Blaze.Html4.Strict hiding (map) | ||
import Text.Blaze.Html4.Strict.Attributes hiding (title) | ||
import Prelude hiding (div, head, id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,31 @@ | ||
{-# LANGUAGE ExtendedDefaultRules #-} | ||
module FMCt.Web.Components.MainPage | ||
( mainPage ) | ||
where | ||
import FMCt.Web.Style.StdStylingHeader (stdStylingHeader) | ||
|
||
module FMCt.Web.Components.MainPage (mainPage) where | ||
|
||
import qualified Data.Text.Lazy as LA | ||
import FMCt.Web.Components.Brick (brick) | ||
import FMCt.Web.Components.RegularPage (regularPage) | ||
import qualified Data.Text.Lazy as LA | ||
import qualified Lucid as LU | ||
import FMCt.Web.Style.StdStylingHeader (stdStylingHeader) | ||
import qualified Lucid as LU | ||
import qualified Lucid.Bootstrap as LB | ||
|
||
mainPage :: LA.Text | ||
mainPage = LU.renderText sMainPage | ||
where | ||
sMainPage :: LU.Html () | ||
sMainPage = do | ||
stdStylingHeader "FMCt" | ||
LB.container_ $ do | ||
LB.row_ $ do | ||
LB.span2_ $ LU.div_ [LU.name_ "Title" ] $ LU.h1_ "FMCt-Web" | ||
LB.span2_ $ LU.div_ [LU.name_ "SubTitle" ] $ LU.h2_ "V.0.4.1.beta" | ||
LU.hr_ [] | ||
LB.span2_ $ LU.h3_ "Welcome to the FMCt Web Interpreter." | ||
|
||
LU.hr_ [] | ||
LB.row_ $ do | ||
LB.span2_ $ | ||
LU.div_ [LU.name_ "Links"] $ do | ||
LU.h3_ "Links" | ||
LU.ul_ $ LU.a_ [LU.href_ "parse?term=*" ] "Parser" | ||
LU.ul_ $ LU.a_ [LU.href_ "derive?term=*"] "Derivation Tester" | ||
stdStylingHeader "FMCt" | ||
LB.container_ $ do | ||
LB.row_ $ do | ||
LB.span2_ $ LU.div_ [LU.name_ "Title"] $ LU.h1_ "FMCt-Web" | ||
LB.span2_ $ LU.div_ [LU.name_ "SubTitle"] $ LU.h2_ "V.0.4.1.beta" | ||
LU.hr_ [] | ||
LB.span2_ $ LU.h3_ "Welcome to the FMCt Web Interpreter." | ||
|
||
|
||
LU.hr_ [] | ||
LB.row_ $ do | ||
LB.span2_ $ | ||
LU.div_ [LU.name_ "Links"] $ do | ||
LU.h3_ "Links" | ||
LU.ul_ $ LU.a_ [LU.href_ "parse?term=*"] "Parser" | ||
LU.ul_ $ LU.a_ [LU.href_ "derive?term=*"] "Derivation Tester" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
module FMCt.Web.Components.ParsedBox | ||
(parsedBox) | ||
where | ||
module FMCt.Web.Components.ParsedBox (parsedBox) where |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
module FMCt.Web.Components.RegularPage | ||
(regularPage) | ||
where | ||
module FMCt.Web.Components.RegularPage (regularPage) where | ||
|
||
--import qualified Data.Text.Lazy as LA | ||
|
||
import Data.String (IsString (..)) | ||
import FMCt.Web.Style.StdStylingHeader (stdStylingHeader) | ||
import qualified Lucid as LU | ||
import qualified Lucid.Bootstrap as LB | ||
import FMCt.Web.Style.StdStylingHeader (stdStylingHeader) | ||
import Data.String (IsString(..)) | ||
regularPage | ||
:: ( LU.ToHtml b, Show b, IsString b ) | ||
=> b -- ^ Subtitle | ||
-> LU.Html () | ||
-> LU.Html () | ||
regularPage st rest = | ||
let | ||
pTitle = LU.h1_ $ LU.a_ [LU.href_ "/" ] "FMCt-Web" | ||
pSubTitle = LU.h2_ . LU.toHtml | ||
pStyling = stdStylingHeader . (fromString . show) | ||
in | ||
LB.containerFluid_ $ LU.div_ [LU.name_ "Page Components"] $ do | ||
pStyling st -- add the header to the file containing it's title and css | ||
LB.span1_ pTitle -- a page title | ||
LB.span1_ $ pSubTitle st -- a page subtitle | ||
rest | ||
|
||
|
||
regularPage :: | ||
(LU.ToHtml b, Show b, IsString b) => | ||
-- | Subtitle | ||
b -> | ||
LU.Html () -> | ||
LU.Html () | ||
regularPage st rest = | ||
let pTitle = LU.h1_ $ LU.a_ [LU.href_ "/"] "FMCt-Web" | ||
pSubTitle = LU.h2_ . LU.toHtml | ||
pStyling = stdStylingHeader . (fromString . show) | ||
in LB.containerFluid_ $ | ||
LU.div_ [LU.name_ "Page Components"] $ do | ||
pStyling st -- add the header to the file containing it's title and css | ||
LB.span1_ pTitle -- a page title | ||
LB.span1_ $ pSubTitle st -- a page subtitle | ||
rest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,36 @@ | ||
{-# LANGUAGE ExtendedDefaultRules #-} | ||
module FMCt.Web.Pages.Parse | ||
( pParse | ||
) | ||
where | ||
import FMCt.Parsing ( parseFMCtoString, parseFMC ) | ||
|
||
module FMCt.Web.Pages.Parse ( | ||
pParse, | ||
) where | ||
|
||
import qualified Data.Text.Lazy as LA | ||
import FMCt (eval1, printStack) | ||
import qualified Data.Text.Lazy as LA | ||
import qualified Lucid as LU | ||
import qualified Lucid.Bootstrap as LB | ||
import FMCt.Web.Style.StdStylingHeader (stdStylingHeader) | ||
import FMCt.Parsing (parseFMC, parseFMCtoString) | ||
import FMCt.Web.Components.Brick (brick) | ||
import FMCt.Web.Components.RegularPage (regularPage) | ||
import FMCt.Web.Components.Brick (brick) | ||
import FMCt.Web.Style.StdStylingHeader (stdStylingHeader) | ||
import qualified Lucid as LU | ||
import qualified Lucid.Bootstrap as LB | ||
|
||
pParse :: LA.Text -> LU.Html () | ||
pParse term = sReplPage' | ||
where | ||
sReplPage' = do | ||
regularPage "Parser" | ||
termForm | ||
parsedBox | ||
evaluationBox | ||
sReplPage' = do | ||
regularPage "Parser" | ||
termForm | ||
parsedBox | ||
evaluationBox | ||
|
||
-- | Form where the term can be inserted. | ||
termForm :: LU.Html () | ||
termForm = do | ||
LU.hr_ [] | ||
LU.div_ [LU.name_ "term-div"] $ LU.form_ [LU.action_ "parse" ] $ LU.input_ [LU.type_ "text", LU.name_ "term"] | ||
LU.hr_ [] | ||
LU.div_ [LU.name_ "term-div"] $ LU.form_ [LU.action_ "parse"] $ LU.input_ [LU.type_ "text", LU.name_ "term"] | ||
|
||
-- | Box where the parsed term can be seen. | ||
parsedBox = brick "parsed-div" "Parsed Term" "" parsedTerm | ||
where parsedTerm = (LU.toHtml . parseFMCtoString . LA.unpack) term | ||
parsedBox = brick "parsed-div" "Parsed Term" "" parsedTerm | ||
where | ||
parsedTerm = (LU.toHtml . parseFMCtoString . LA.unpack) term | ||
|
||
-- | Box where the evaluation result can be seen. | ||
evaluationBox = brick "evaluation-div" "Evaluation Result (Stack)" "" $ evalResult | ||
where evalResult = (LU.toHtml . printStack . eval1 . parseFMC . LA.unpack) term | ||
where | ||
evalResult = (LU.toHtml . printStack . eval1 . parseFMC . LA.unpack) term |
Oops, something went wrong.