1module ProjectM36.DataTypes.Maybe where
3import ProjectM36.DataTypes.Primitive
4import qualified Data.HashSet as HS
5import qualified Data.Map as M
8maybeAtomType :: AtomType -> AtomType
9maybeAtomType arg = ConstructedAtomType "Maybe" (M.singleton "a" arg)
11maybeTypeConstructorMapping :: TypeConstructorMapping
12maybeTypeConstructorMapping = [(ADTypeConstructorDef "Maybe" ["a"],
13 [DataConstructorDef "Nothing" [],
14 DataConstructorDef "Just" [DataConstructorDefTypeVarNameArg "a"]])
17maybeAtomFunctions :: AtomFunctions
18maybeAtomFunctions = HS.fromList [
20 atomFuncName ="isJust",
21 atomFuncType = [maybeAtomType AnyAtomType, BoolAtomType],
22 atomFuncBody = AtomFunctionBody Nothing $ \((ConstructedAtom dConsName _ _):_) -> BoolAtom (dConsName /= "Nothing")
25 atomFuncName = "fromMaybe",
26 atomFuncType = [AnyAtomType, maybeAtomType AnyAtomType, AnyAtomType], -- this really should be more specific, but we don't have type checker handling for this yet
27 atomFuncBody = AtomFunctionBody Nothing $ \(defaultAtom:(ConstructedAtom dConsName _ (atomVal:_)):_) -> if atomTypeForAtom defaultAtom /= atomTypeForAtom atomVal then error "poop" else if dConsName == "Nothing" then defaultAtom else atomVal
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list