on ca59541 help sign in
22 lines 882 B history raw
1module ProjectM36.DataTypes.Maybe where
2import ProjectM36.Base
3import qualified Data.HashSet as HS
4import qualified Data.Map as M
6maybeAtomType :: AtomType -> AtomType
7maybeAtomType arg = ConstructedAtomType "Maybe" (M.singleton "a" arg)
8
9maybeTypeConstructorMapping :: TypeConstructorMapping
10maybeTypeConstructorMapping = [(ADTypeConstructorDef "Maybe" ["a"],
11 [DataConstructorDef "Nothing" [],
12 DataConstructorDef "Just" [DataConstructorDefTypeVarNameArg "a"]])
13 ]
15maybeAtomFunctions :: AtomFunctions
16maybeAtomFunctions = HS.fromList [
17 AtomFunction {
18 atomFuncName ="isJust",
19 atomFuncType = [maybeAtomType AnyAtomType, BoolAtomType],
20 atomFuncBody = AtomFunctionBody Nothing $ \((ConstructedAtom dConsName _ _):_) -> BoolAtom (dConsName == "Nothing")
21 }
22 ]