File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -487,6 +487,30 @@ data HaskellType code
487487 -- ^ Dhall code that evaluates to a type
488488 }
489489 -- | Generate some Haskell types within a restricted scope.
490+ --
491+ -- Suppose generate your types using the following code:
492+ --
493+ -- > data MyBool = MyFalse | MyTrue
494+ -- >
495+ -- > Dhall.TH.makeHaskellTypes
496+ -- > [ SingleConstructor "ListOfBool" "ListOfBool" "List Bool"
497+ -- > , Scoped
498+ -- > [ Predefined (TH.ConT ''MyBool) "Bool"
499+ -- > , SingleConstructor "ListOfMyBool" "ListOfMyBool" "List Bool"
500+ -- > ]
501+ -- > , SingleConstructor "ListOfBoolAgain" "ListOfBoolAgain" "List Bool"
502+ -- > ]
503+ --
504+ -- This generates the following Haskell types:
505+ --
506+ -- > data ListOfBool = ListOfBool Bool
507+ -- > data ListOfMyBool = ListOfMyBool MyBool
508+ -- > data ListOfBoolAgain = ListOfBoolAgain Bool
509+ --
510+ -- Therefore @Scoped@ allows you to override the type mapping locally. This
511+ -- is especially handy in conjunction with @Predefined@, as it allows you to
512+ -- use different representations of a Dhall type, e.g. a Dhall @List@ can be
513+ -- a Haskell @Vector@, @Seq@ or a good old linked list.
490514 | Scoped [HaskellType code ]
491515 deriving (Functor , Foldable , Traversable )
492516
You can’t perform that action at this time.
0 commit comments