@@ -17,7 +17,9 @@ import Data.Vector.Binary()
17import ProjectM36.HashSetBinary ()
17import ProjectM36.HashSetBinary ()
18import Data.Time.Clock
18import Data.Time.Clock
19import Data.Time.Clock.POSIX
19import Data.Time.Clock.POSIX
20+import Data.Time.Calendar (Day,toGregorian,fromGregorian)
20import Data.Hashable.Time ()
21import Data.Hashable.Time ()
22+import Control.Monad (liftM)
22type StringType = T.Text
24type StringType = T.Text
@@ -25,7 +27,9 @@ data Atom = StringAtom StringType |
25 IntAtom Int |
27 IntAtom Int |
26 BoolAtom Bool |
28 BoolAtom Bool |
27 RelationAtom Relation |
29 RelationAtom Relation |
28− DateTimeAtom UTCTime
30+ DateTimeAtom UTCTime |
29 deriving (Show, Eq, Generic)
33 deriving (Show, Eq, Generic)
31--not so great orphan instance
35--not so great orphan instance
@@ -34,6 +38,12 @@ instance Binary UTCTime where
35 r <- get :: Get Rational
39 r <- get :: Get Rational
36 return (posixSecondsToUTCTime (fromRational r))
40 return (posixSecondsToUTCTime (fromRational r))
42+instance Binary Day where
43+ put day = put $ toGregorian day
45+ (y,m,d) <- get :: Get (Integer, Int, Int)
46+ return $ fromGregorian y m d
38instance NFData Atom where rnf = genericRnf
48instance NFData Atom where rnf = genericRnf
@@ -46,6 +56,8 @@ data AtomType = StringAtomType |
46 BoolAtomType |
56 BoolAtomType |
47 RelationAtomType Attributes |
57 RelationAtomType Attributes |
48 DateTimeAtomType |
58 DateTimeAtomType |
49 AnyAtomType --AnyAtomType is used as a wildcard
61 AnyAtomType --AnyAtomType is used as a wildcard
50 deriving (Eq, Show, Generic)
62 deriving (Eq, Show, Generic)