on master help sign in
add simple workaround for creation of IntAtoms from tutd

resolves #201

commit015506fef7ca4228d1f2dad6ed50f4b27d3f5d0d authorAgentM <agentm@themactionfaction.com> dateTue 22 May 2018, 23:06 (8 years ago) parent37b059d
2 files changed+10−1
src/lib/ProjectM36/AtomFunctionError.hs+1 src/lib/ProjectM36/AtomFunctions/Primitive.hs+9−1
src/lib/ProjectM36/AtomFunctionError.hs+1
@@ -9,6 +9,7 @@ data AtomFunctionError = AtomFunctionUserError String |
99 AtomFunctionTypeMismatchError |
1010 InvalidIntervalOrderingError |
1111 InvalidIntervalBoundariesError |
12+ InvalidIntBoundError |
1213 AtomFunctionEmptyRelationError |
1314 AtomTypeDoesNotSupportOrderingError Text |
1415 AtomTypeDoesNotSupportIntervalError Text |
src/lib/ProjectM36/AtomFunctions/Primitive.hs+9−1
@@ -43,7 +43,15 @@ primitiveAtomFunctions = HS.fromList [
4343 atomFuncBody = body $ integerAtomFuncLessThan True >=> boolAtomNot},
4444 AtomFunction { atomFuncName = "not",
4545 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+
4755 ]
4856 where
4957 body = AtomFunctionBody Nothing