Remove use of CPP inside functions

This commit is contained in:
Alex Mason 2016-09-02 16:14:25 +10:00
parent 840eae8cfe
commit 518a2715be

View file

@ -52,18 +52,12 @@ instance (KnownSymbol format, T.FormatTime t) => Show (FTime format t) where
showsPrec i t = showParen (i > 1) (renderTime t ++) showsPrec i t = showParen (i > 1) (renderTime t ++)
instance (KnownSymbol format, T.ParseTime t) => Read (FTime format t) where instance (KnownSymbol format, T.ParseTime t) => Read (FTime format t) where
readsPrec i str = res readsPrec i str = res where
where
fmt = symbolVal (Proxy :: Proxy format) fmt = symbolVal (Proxy :: Proxy format)
res = fmap (first FTime) res = fmap (first FTime)
(readParen (i > 1) (readParen (i > 1)
#if !MIN_VERSION_time(1,5,0) (rtime T.defaultTimeLocale fmt)
(T.readsTime T.defaultTimeLocale fmt) str)
#else
(T.readSTime False T.defaultTimeLocale fmt)
#endif
str
)
instance (KnownSymbol format, T.FormatTime t) => ToHttpApiData (FTime format t) where instance (KnownSymbol format, T.FormatTime t) => ToHttpApiData (FTime format t) where
@ -103,6 +97,17 @@ parseTime str = res
toFTimeTy :: Either Text (FTime format t) -> FTime format a toFTimeTy :: Either Text (FTime format t) -> FTime format a
toFTimeTy _ = undefined toFTimeTy _ = undefined
ptime :: T.ParseTime t => T.TimeLocale -> String -> String -> Maybe t
rtime :: T.ParseTime t => T.TimeLocale -> String -> ReadS t
#if !MIN_VERSION_time(1,5,0)
ptime = T.parseTime
rtime = T.readsTime
#else
ptime = T.parseTimeM False
rtime = T.readSTime False
#endif
-- $setup -- $setup
-- >>> import Servant.API -- >>> import Servant.API
-- >>> import Data.Aeson -- >>> import Data.Aeson