Remove use of CPP inside functions
This commit is contained in:
parent
840eae8cfe
commit
518a2715be
1 changed files with 17 additions and 12 deletions
|
@ -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)
|
(rtime T.defaultTimeLocale fmt)
|
||||||
#if !MIN_VERSION_time(1,5,0)
|
str)
|
||||||
(T.readsTime T.defaultTimeLocale fmt)
|
|
||||||
#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
|
||||||
|
|
Loading…
Reference in a new issue