Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE GADTs #-}
- module Lib where
- import Data.Map.Strict
- data Value
- = ValueBool Bool
- | ValueText String
- | ValueObject (Map String Value)
- data Expr t where
- ExprBool :: Bool -> Expr Bool
- ExprBoolOr :: Expr Bool -> Expr Bool -> Expr Bool
- ExprText :: String -> Expr String
- ExprTextAppend :: Expr String -> Expr String -> Expr String
- ExprObject :: Map String Value -> String -> Expr Value
- eval :: Expr t -> t
- eval (ExprBool value) = value
- eval (ExprBoolOr lft rgt) = eval lft || eval rgt
- eval (ExprText value) = value
- eval (ExprTextAppend lft rgt) = eval lft <> eval rgt
- eval (ExprObject map fieldName) = map ! fieldName
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement