@@ -12,8 +12,7 @@
1212
1313module Gen.Syntax where
1414
15−import Control.Lens hiding (iso, mapping, op, pre,
16− strict)
15+import Control.Lens hiding (iso, mapping, op, pre, strict)
1716import Data.Either
1817import Data.Foldable (foldl', foldr')
1918import qualified Data.HashMap.Strict as Map
@@ -25,9 +24,7 @@ import qualified Data.Text as Text
2524import Data.Text.Manipulate
2625import Gen.Text
2726import Gen.Types
28−import Language.Haskell.Exts.Build (app, appFun, infixApp, lamE,
29− listE, name, noBinds, paren,
30− patBind, pvar, sfun, strE, sym,
27+import Language.Haskell.Exts.Build (app, appFun, infixApp, lamE, listE, name, noBinds, paren, patBind, pvar, sfun, strE, sym,
3128 var)
3229import Language.Haskell.Exts.SrcLoc
3330import Language.Haskell.Exts.Syntax hiding (Alt, Int, Lit)
@@ -558,47 +555,47 @@ internalType = \case
558555
559556externalLit :: Lit -> Type
560557externalLit = \case
561− Text -> TyCon "Text"
562− Bool -> TyCon "Bool"
563− Time -> TyCon "TimeOfDay"
564− Date -> TyCon "Day"
565− DateTime -> TyCon "UTCTime"
566− Nat -> TyCon "Natural"
567− Float -> TyCon "Double"
568− Double -> TyCon "Double"
569− Byte -> TyCon "ByteString"
570− UInt32 -> TyCon "Word32"
571− UInt64 -> TyCon "Word64"
572− Int32 -> TyCon "Int32"
573− Int64 -> TyCon "Int64"
574− Alt t -> TyCon (unqual (Text.unpack t))
575− RqBody -> TyCon "RequestBody"
576− RsBody -> TyCon "Stream"
577− JSONValue -> TyCon "JSONValue"
578− FieldMask -> TyCon "FieldMask"
579− Duration -> TyCon "Scientific"
558+ Text -> TyCon "Text"
559+ Bool -> TyCon "Bool"
560+ Time -> TyCon "TimeOfDay"
561+ Date -> TyCon "Day"
562+ DateTime -> TyCon "UTCTime"
563+ Nat -> TyCon "Natural"
564+ Float -> TyCon "Double"
565+ Double -> TyCon "Double"
566+ Byte -> TyCon "ByteString"
567+ UInt32 -> TyCon "Word32"
568+ UInt64 -> TyCon "Word64"
569+ Int32 -> TyCon "Int32"
570+ Int64 -> TyCon "Int64"
571+ Alt t -> TyCon (unqual (Text.unpack t))
572+ RqBody -> TyCon "RequestBody"
573+ RsBody -> TyCon "Stream"
574+ JSONValue -> TyCon "JSONValue"
575+ GFieldMask -> TyCon "GFieldMask"
576+ GDuration -> TyCon "Scientific"
580577
581578internalLit :: Lit -> Type
582579internalLit = \case
583− Text -> TyCon "Text"
584− Bool -> TyCon "Bool"
585− Time -> TyCon "Time'"
586− Date -> TyCon "Date'"
587− DateTime -> TyCon "DateTime'"
588− Nat -> TyApp (TyCon "Textual") (TyCon "Nat")
589− Float -> TyApp (TyCon "Textual") (TyCon "Double")
590− Double -> TyApp (TyCon "Textual") (TyCon "Double")
591− Byte -> TyCon "Bytes"
592− UInt32 -> TyApp (TyCon "Textual") (TyCon "Word32")
593− UInt64 -> TyApp (TyCon "Textual") (TyCon "Word64")
594− Int32 -> TyApp (TyCon "Textual") (TyCon "Int32")
595− Int64 -> TyApp (TyCon "Textual") (TyCon "Int64")
596− Alt t -> TyCon (unqual (Text.unpack t))
597− RqBody -> TyCon "RequestBody"
598− RsBody -> TyCon "Stream"
599− JSONValue -> TyCon "JSONValue"
600− FieldMask -> TyCon "FieldMask"
601− Duration -> TyCon "Duration"
580+ Text -> TyCon "Text"
581+ Bool -> TyCon "Bool"
582+ Time -> TyCon "Time'"
583+ Date -> TyCon "Date'"
584+ DateTime -> TyCon "DateTime'"
585+ Nat -> TyApp (TyCon "Textual") (TyCon "Nat")
586+ Float -> TyApp (TyCon "Textual") (TyCon "Double")
587+ Double -> TyApp (TyCon "Textual") (TyCon "Double")
588+ Byte -> TyCon "Bytes"
589+ UInt32 -> TyApp (TyCon "Textual") (TyCon "Word32")
590+ UInt64 -> TyApp (TyCon "Textual") (TyCon "Word64")
591+ Int32 -> TyApp (TyCon "Textual") (TyCon "Int32")
592+ Int64 -> TyApp (TyCon "Textual") (TyCon "Int64")
593+ Alt t -> TyCon (unqual (Text.unpack t))
594+ RqBody -> TyCon "RequestBody"
595+ RsBody -> TyCon "Stream"
596+ JSONValue -> TyCon "JSONValue"
597+ GFieldMask -> TyCon "GFieldMask"
598+ GDuration -> TyCon "GDuration"
602599
603600mapping :: TType -> Exp -> Exp
604601mapping t e = infixE e "." (go t)
@@ -613,21 +610,21 @@ mapping t e = infixE e "." (go t)
613610
614611iso :: TType -> Maybe Exp
615612iso = \case
616− TList {} -> Just (var "_Coerce")
617− TMap {} -> Just (var "_Coerce")
618− TLit Nat -> Just (var "_Coerce")
619− TLit Time -> Just (var "_Time")
620− TLit Date -> Just (var "_Date")
621− TLit DateTime -> Just (var "_DateTime")
622− TLit Duration -> Just (var "_Duration")
623− TLit Float -> Just (var "_Coerce")
624− TLit Double -> Just (var "_Coerce")
625− TLit Byte -> Just (var "_Bytes")
626− TLit UInt32 -> Just (var "_Coerce")
627− TLit UInt64 -> Just (var "_Coerce")
628− TLit Int32 -> Just (var "_Coerce")
629− TLit Int64 -> Just (var "_Coerce")
630− _ -> Nothing
613+ TList {} -> Just (var "_Coerce")
614+ TMap {} -> Just (var "_Coerce")
615+ TLit Nat -> Just (var "_Coerce")
616+ TLit Time -> Just (var "_Time")
617+ TLit Date -> Just (var "_Date")
618+ TLit DateTime -> Just (var "_DateTime")
619+ TLit GDuration -> Just (var "_GDuration")
620+ TLit Float -> Just (var "_Coerce")
621+ TLit Double -> Just (var "_Coerce")
622+ TLit Byte -> Just (var "_Bytes")
623+ TLit UInt32 -> Just (var "_Coerce")
624+ TLit UInt64 -> Just (var "_Coerce")
625+ TLit Int32 -> Just (var "_Coerce")
626+ TLit Int64 -> Just (var "_Coerce")
627+ _ -> Nothing
631628
632629require :: TType -> TType
633630require (TMaybe t) = t