@@ -1,13 +1,14 @@
1{-# LANGUAGE DerivingVia #-}
1{-# LANGUAGE DerivingVia #-}
2+{-# LANGUAGE NamedFieldPuns #-}
2{-# LANGUAGE RecordWildCards #-}
3{-# LANGUAGE RecordWildCards #-}
3{-# LANGUAGE StandaloneDeriving #-}
4{-# LANGUAGE StandaloneDeriving #-}
4{-# OPTIONS_GHC -fno-warn-orphans #-}
5{-# OPTIONS_GHC -fno-warn-orphans #-}
6−module Flat.Orphans where
8+module Flat.Instances where
8import Data.Fixed
10import Data.Fixed
9import Data.Time
11import Data.Time
11import Flat as F
12import Flat as F
@@ -19,7 +20,7 @@ instance Flat DiffTime where
19 size = F.size . diffTimeToPicoseconds
20 size = F.size . diffTimeToPicoseconds
21utcTimeToTuple :: UTCTime -> (Day, DiffTime)
22utcTimeToTuple :: UTCTime -> (Day, DiffTime)
22−utcTimeToTuple UTCTime{..} = (utctDay, utctDayTime)
23+utcTimeToTuple = ((,) <$> utctDay <*> utctDayTime)
24instance Flat UTCTime where
25instance Flat UTCTime where
25 encode = F.encode . utcTimeToTuple
26 encode = F.encode . utcTimeToTuple
@@ -65,5 +66,3 @@ instance Flat ZonedTime where
65 size = F.size . zonedTimeToTuple
66 size = F.size . zonedTimeToTuple
66 encode = F.encode . zonedTimeToTuple
67 encode = F.encode . zonedTimeToTuple
67 decode = uncurry ZonedTime <$> F.decode
68 decode = uncurry ZonedTime <$> F.decode
69−deriving via (AsArray (Vector a)) instance Flat a => Flat (Vector a)