diff options
Diffstat (limited to 'assignment-13/uFPL.dcl')
-rw-r--r-- | assignment-13/uFPL.dcl | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/assignment-13/uFPL.dcl b/assignment-13/uFPL.dcl index c061119..55c9c66 100644 --- a/assignment-13/uFPL.dcl +++ b/assignment-13/uFPL.dcl @@ -1,7 +1,10 @@ definition module uFPL from StdGeneric import :: Bimap -from StdOverloaded import class +, class -, class *, class /, class ==, class < +from StdOverloaded import class +, class -, class *, class /, class ==, class <, class toString + +from Data.Map import :: Map +from Data.Maybe import :: Maybe from uFPL.C import :: CType, :: CExpr, :: CBody, :: CVar, :: CFun, :: CProg @@ -75,9 +78,9 @@ lit :: (t -> Expr t RO) | E.rw: When (Expr Bool rw) [Rule] | (>>>) infixr 2 Trigger [Rule] | E.rwa rwb: SetCursor (Expr Int rwa, Expr Int rwb) - | E.t rw: Print (Expr t rw) & Expr t + | E.t rw: Print (Expr t rw) & Expr, toString t -:: NamedRule = E.r: (:=:) infix 1 String r & gen r CBody & allShares r & TC r +:: NamedRule = E.r: (:=:) infix 1 String r & gen r CBody & run, allShares, TC r class gen f t :: f -> t @@ -97,3 +100,31 @@ instance gen [r] CBody | gen r CBody instance gen NamedRule CFun instance gen NamedRule CProg instance gen [NamedRule] CProg + +:: ShareState = + { val :: Dynamic + , dirty :: Int + , subscriptions :: Int + } + +:: Display = + { size :: (Int, Int) + , cursor :: (Int, Int) + , text :: Map (Int, Int) Char + } + +instance toString Display + +:: State = + { vars :: Map String ShareState + , display :: Display + } + +display :: String Display -> Display +eval :: (Expr t rw) State -> Maybe t | Expr t +evalTrigger :: Trigger State -> Maybe (Bool, State) + +class run r :: r -> State -> Maybe State +instance run [r] | run r +instance run Rule +instance run NamedRule |