Hoogle Search
Within LTS Haskell 24.42 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
deriveGenericFunctions :: Name -> String -> String -> String -> Q [Dec]generics-sop Generics.SOP.TH Like deriveGenericOnly, but don't derive class instance, only functions. Example: If you say
deriveGenericFunctions ''Tree "TreeCode" "fromTree" "toTree"
then you get code that is equivalent to:type TreeCode = '[ '[Int], '[Tree, Tree] ] fromTree :: Tree -> SOP I TreeCode fromTree (Leaf x) = SOP ( Z (I x :* Nil)) fromTree (Node l r) = SOP (S (Z (I l :* I r :* Nil))) toTree :: SOP I TreeCode -> Tree toTree (SOP (Z (I x :* Nil))) = Leaf x toTree (SOP (S (Z (I l :* I r :* Nil)))) = Node l r toTree (SOP (S (S x))) = x `seq` error "inaccessible"
deriveGenericOnly :: Name -> Q [Dec]generics-sop Generics.SOP.TH Like deriveGeneric, but omit the HasDatatypeInfo instance.
deriveGenericOnlySubst :: Name -> (Name -> Q Type) -> Q [Dec]generics-sop Generics.SOP.TH Variant of deriveGenericOnly that allows to restrict the type parameters. Experimental function, exposed primarily for benchmarking.
deriveGenericSubst :: Name -> (Name -> Q Type) -> Q [Dec]generics-sop Generics.SOP.TH Variant of deriveGeneric that allows to restrict the type parameters. Experimental function, exposed primarily for benchmarking.
deriveMetadataType :: Name -> String -> Q [Dec]generics-sop Generics.SOP.TH Derive DatatypeInfo type for the type. Example: If you say
deriveMetadataType ''Tree "TreeDatatypeInfo"
then you get code that is equivalent to:type TreeDatatypeInfo = T.ADT "Main" "Tree" [ T.Constructor "Leaf", T.Constructor "Node" ]
deriveMetadataValue :: Name -> String -> String -> Q [Dec]generics-sop Generics.SOP.TH Deprecated: Use deriveMetadataType and demoteDatatypeInfo instead.
deriveListable :: Name -> DecsQleancheck Test.LeanCheck Derives a Listable instance for a given type Name. Consider the following Stack datatype:
data Stack a = Stack a (Stack a) | Empty
WritingderiveListable ''Stack
will automatically derive the following Listable instance:instance Listable a => Listable (Stack a) where tiers = cons2 Stack \/ cons0 Empty
Warning: if the values in your type need to follow a data invariant, the derived instance won't respect it. Use this only on "free" datatypes. Needs the TemplateHaskell extension.deriveListableCascading :: Name -> DecsQleancheck Test.LeanCheck Derives a Listable instance for a given type Name cascading derivation of type arguments as well. Consider the following series of datatypes:
data Position = CEO | Manager | Programmer data Person = Person { name :: String , age :: Int , position :: Position } data Company = Company { name :: String , employees :: [Person] }WritingderiveListableCascading ''Company
will automatically derive the following three Listable instances:instance Listable Position where tiers = cons0 CEO \/ cons0 Manager \/ cons0 Programmer instance Listable Person where tiers = cons3 Person instance Listable Company where tiers = cons2 Company
-
leancheck Test.LeanCheck.Derive Given a type Name, derives an expression to be placed as the result of list:
concat $ consN C1 \/ consN C2 \/ ... \/ consN CN
deriveListable :: Name -> DecsQleancheck Test.LeanCheck.Derive Derives a Listable instance for a given type Name. Consider the following Stack datatype:
data Stack a = Stack a (Stack a) | Empty
WritingderiveListable ''Stack
will automatically derive the following Listable instance:instance Listable a => Listable (Stack a) where tiers = cons2 Stack \/ cons0 Empty
Warning: if the values in your type need to follow a data invariant, the derived instance won't respect it. Use this only on "free" datatypes. Needs the TemplateHaskell extension.