on 52182bc help sign in
17 lines 918 B history raw
1module ProjectM36.DataTypes.Day where
2import ProjectM36.Base
3import ProjectM36.AtomFunctionBody
4import qualified Data.HashSet as HS
5import Data.Time.Calendar
7dayAtomFunctions :: AtomFunctions
8dayAtomFunctions = HS.fromList [
9 AtomFunction { atomFuncName = "fromGregorian",
10 atomFuncType = [IntegerAtomType, IntegerAtomType, IntegerAtomType, DayAtomType],
11 atomFuncBody = compiledAtomFunctionBody $ \(IntegerAtom year:IntegerAtom month:IntegerAtom day:_) -> pure $ DayAtom (fromGregorian (fromIntegral year) (fromIntegral month) (fromIntegral day))
12 },
13 AtomFunction { atomFuncName = "dayEarlierThan",
14 atomFuncType = [DayAtomType, DayAtomType, BoolAtomType],
15 atomFuncBody = compiledAtomFunctionBody $ \(ConstructedAtom _ _ (IntAtom dayA:_):ConstructedAtom _ _ (IntAtom dayB:_):_) -> pure (BoolAtom (dayA < dayB))
16 }
17 ]