on master help sign in
add simple workaround for creation of IntAtoms from tutd
015506fAgentM
src/lib/ProjectM36/AtomFunctionError.hs+1
@@ -9,6 +9,7 @@ data AtomFunctionError = AtomFunctionUserError String |
9 AtomFunctionTypeMismatchError |
9 AtomFunctionTypeMismatchError |
10 InvalidIntervalOrderingError |
10 InvalidIntervalOrderingError |
11 InvalidIntervalBoundariesError |
11 InvalidIntervalBoundariesError |
12+ InvalidIntBoundError |
12 AtomFunctionEmptyRelationError |
13 AtomFunctionEmptyRelationError |
13 AtomTypeDoesNotSupportOrderingError Text |
14 AtomTypeDoesNotSupportOrderingError Text |
14 AtomTypeDoesNotSupportIntervalError Text |
15 AtomTypeDoesNotSupportIntervalError Text |
src/lib/ProjectM36/AtomFunctions/Primitive.hs+9−1
@@ -43,7 +43,15 @@ primitiveAtomFunctions = HS.fromList [
43 atomFuncBody = body $ integerAtomFuncLessThan True >=> boolAtomNot},
43 atomFuncBody = body $ integerAtomFuncLessThan True >=> boolAtomNot},
44 AtomFunction { atomFuncName = "not",
44 AtomFunction { atomFuncName = "not",
45 atomFuncType = [BoolAtomType, BoolAtomType],
45 atomFuncType = [BoolAtomType, BoolAtomType],
46− atomFuncBody = body $ \(b:_) -> boolAtomNot b }
46+ atomFuncBody = body $ \(b:_) -> boolAtomNot b },
47+ AtomFunction { atomFuncName = "int",
48+ atomFuncType = [IntegerAtomType, IntAtomType],
49+ atomFuncBody = body $ \(IntegerAtom v:_) -> if v < fromIntegral (maxBound :: Int) then
50+ pure (IntAtom (fromIntegral v))
51+ else
52+ Left InvalidIntBoundError
53+ }
54+
47 ]
55 ]
48 where
56 where
49 body = AtomFunctionBody Nothing
57 body = AtomFunctionBody Nothing