aboutsummaryrefslogtreecommitdiff
path: root/src/context.hs
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-03-14 12:41:34 +0100
committerCharles <sircharlesaze@gmail.com>2020-03-14 12:41:34 +0100
commit18c9cfd7c1fb4baf1789f178a8d56ddb8f0f1456 (patch)
tree7ad79406c98e0ed520a852616e9d8d48de6ab54d /src/context.hs
parente0ade28ab642c043501493fe7192b626a6a68115 (diff)
downloadcomputorv2-18c9cfd7c1fb4baf1789f178a8d56ddb8f0f1456.tar.gz
computorv2-18c9cfd7c1fb4baf1789f178a8d56ddb8f0f1456.tar.bz2
computorv2-18c9cfd7c1fb4baf1789f178a8d56ddb8f0f1456.zip
Draft expr compatibility
Diffstat (limited to 'src/context.hs')
-rw-r--r--src/context.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/context.hs b/src/context.hs
new file mode 100644
index 0000000..c5abfe0
--- /dev/null
+++ b/src/context.hs
@@ -0,0 +1,22 @@
+module Context where
+
+import Data.List
+import Control.Alternative
+
+type Label = String
+data State a = State [a]
+data Context a = Context [Decl] a
+
+instance Functor Context where
+ fmap f (Context state x) = Context (f x) state
+
+getLabel :: Declaration a => State a -> Label -> Maybe a
+getLabel (State decls) l = find (label . (l ==)) decls
+
+class Declaration a where
+ label :: a -> Label
+ -- value for variable
+ -- partial expression where the only variable left is the argument
+ resolve :: a -> State -> b
+
+