{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveLift #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Test.Amazonka.TH where
import Amazonka.Core
import Amazonka.Lens (view)
import Data.Time (Day (..), DiffTime, UTCTime (..))
import Language.Haskell.TH
import Language.Haskell.TH.Syntax
mkTime :: Text -> Q Exp
mkTime :: Text -> Q Exp
mkTime Text
x =
case Text -> Either String ISO8601
forall a. FromText a => Text -> Either String a
fromText Text
x :: Either String ISO8601 of
Left String
e -> String -> Q Exp
forall a. HasCallStack => String -> a
error (String -> String
forall a. Show a => a -> String
show String
e)
Right ISO8601
t -> [|view _Time t|]
deriving instance Lift (Time a)
deriving instance Lift UTCTime
deriving instance Lift Day
#if MIN_VERSION_template_haskell(2,16,0)
instance Lift DiffTime where
liftTyped :: DiffTime -> Q (TExp DiffTime)
liftTyped DiffTime
x = [||toEnum $$(liftTyped (fromEnum x))||]
#else
instance Lift DiffTime where
lift x = [|toEnum $(lift (fromEnum x))|]
#endif