-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Tree representations of datatypes -- -- type-tree provides TH splices for generating tree -- representations of the types contained in datatypes. This is useful -- for, for example, generating class instances for a deeply nested -- datatype. @package type-tree @version 0.1.0.0 module Language.Haskell.TypeTree class IsDatatype a -- | Produce binding info and a list of type arguments asDatatype :: IsDatatype a => a -> Q (Binding, [Type]) -- | More ergonomic representation of bound and unbound names of things. data Binding -- | We know this name refers to a specific thing (i.e. it's a constructor) Bound :: Name -> Binding [unBinding] :: Binding -> Name -- | We don't know what this is (i.e. a type variable) Unbound :: Name -> Binding [unBinding] :: Binding -> Name -- | Convenience function. guess :: Name -> Binding -- | Build a "type tree" of the given datatype. -- -- Concrete types will appear in the tree as ConL. Unbound -- variables will appear as VarL. If the datastructure is -- recursive, occurrences of the node after the first will be wrapped in -- Recursive. ttReify :: IsDatatype t => t -> Q (Tree Leaf) -- | ttReify with the provided options. ttReifyOpts :: IsDatatype t => ReifyOpts -> t -> Q (Tree Leaf) -- | Embed the produced tree as an expression. ttLit :: IsDatatype t => t -> ExpQ -- | ttLit with provided opts. ttLitOpts :: IsDatatype t => ReifyOpts -> t -> ExpQ -- | Produces a string literal representing a type tree. Useful for -- debugging purposes. ttDescribe :: IsDatatype t => t -> ExpQ -- | ttDescribe with the given options. ttDescribeOpts :: IsDatatype t => ReifyOpts -> t -> ExpQ -- | Some type and its arguments, as representable in a graph. type Key = (Name, [Type]) -- | Type constructor arity. type Arity = Int -- |
-- $(ttEdges ''Foo) :: [((Name, Arity), Key, [Key])] ---- -- $(ttEdges ''Foo) produces a list suitable for passing to -- graphFromEdges. ttEdges :: IsDatatype t => t -> ExpQ -- |
-- $(ttConnComp ''Foo) :: [SCC (Name, Arity)] ---- -- $(ttConnComp ''Foo) produces a topologically sorted list of -- the strongly connected components of the graph representing -- Foo. ttConnComp :: IsDatatype t => t -> ExpQ data Leaf -- | TypeL (name, xs) is a field with type name applied -- to types xs. TypeL :: (Binding, [Type]) -> Leaf -- | Recursive field. Recursive :: Leaf -> Leaf data ReifyOpts ReifyOpts :: Bool -> Set Name -> ReifyOpts -- | Descend into primitive type constructors? [expandPrim] :: ReifyOpts -> Bool -- | If a name in this set is encountered, stop descending. [terminals] :: ReifyOpts -> Set Name -- | Default reify options. -- --
-- defaultOpts = ReifyOpts
-- { expandPrim = False
-- , terminals = mempty
-- }
--
defaultOpts :: ReifyOpts
instance GHC.Show.Show Language.Haskell.TypeTree.ReifyEnv
instance GHC.Classes.Eq Language.Haskell.TypeTree.ReifyOpts
instance GHC.Show.Show Language.Haskell.TypeTree.ReifyOpts