-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A framework for generating singleton types -- -- singletons-th defines Template Haskell functionality that -- allows promotion of term-level functions to type-level -- equivalents and singling functions to dependently typed -- equivalents. This library was originally presented in Dependently -- Typed Programming with Singletons, published at the Haskell -- Symposium, 2012. -- (https://cs.brynmawr.edu/~rae/papers/2012/singletons/paper.pdf) -- See also the paper published at Haskell Symposium, 2014, which -- describes how promotion works in greater detail: -- https://cs.brynmawr.edu/~rae/papers/2014/promotion/promotion.pdf. -- -- singletons-th generates code that relies on bleeding-edge GHC -- language extensions. As such, singletons-th only supports the -- latest major version of GHC (currently GHC 9.0). For more information, -- consult the singletons README. -- -- You may also be interested in the following related libraries: -- --
-- $(genSingletons [''Bool, ''Maybe, ''Either, ''[]]) ---- -- to generate singletons for Prelude types. genSingletons :: OptionsMonad q => [Name] -> q [Dec] -- | Promote every declaration given to the type level, retaining the -- originals. See the README for further explanation. promote :: OptionsMonad q => q [Dec] -> q [Dec] -- | Promote each declaration, discarding the originals. Note that a -- promoted datatype uses the same definition as an original datatype, so -- this will not work with datatypes. Classes, instances, and functions -- are all fine. promoteOnly :: OptionsMonad q => q [Dec] -> q [Dec] -- | Generate defunctionalization symbols for each of the provided -- type-level declaration Names. See the "Promotion and partial -- application" section of the singletons README -- for further explanation. genDefunSymbols :: OptionsMonad q => [Name] -> q [Dec] -- | Generate promoted definitions for each of the provided type-level -- declaration Names. This is generally only useful with classes. genPromotions :: OptionsMonad q => [Name] -> q [Dec] -- | Produce instances for PEq from the given types promoteEqInstances :: OptionsMonad q => [Name] -> q [Dec] -- | Produce an instance for PEq from the given type promoteEqInstance :: OptionsMonad q => Name -> q [Dec] -- | Create instances of SEq for the given types singEqInstances :: OptionsMonad q => [Name] -> q [Dec] -- | Create instance of SEq for the given type singEqInstance :: OptionsMonad q => Name -> q [Dec] -- | Create instances of SDecide, TestEquality, and -- TestCoercion for each type in the list. singDecideInstances :: OptionsMonad q => [Name] -> q [Dec] -- | Create instances of SDecide, TestEquality, and -- TestCoercion for the given type. singDecideInstance :: OptionsMonad q => Name -> q [Dec] -- | Produce instances for POrd from the given types promoteOrdInstances :: OptionsMonad q => [Name] -> q [Dec] -- | Produce an instance for POrd from the given type promoteOrdInstance :: OptionsMonad q => Name -> q [Dec] -- | Create instances of SOrd for the given types singOrdInstances :: OptionsMonad q => [Name] -> q [Dec] -- | Create instance of SOrd for the given type singOrdInstance :: OptionsMonad q => Name -> q [Dec] -- | Produce instances for PBounded from the given types promoteBoundedInstances :: OptionsMonad q => [Name] -> q [Dec] -- | Produce an instance for PBounded from the given type promoteBoundedInstance :: OptionsMonad q => Name -> q [Dec] -- | Create instances of SBounded for the given types singBoundedInstances :: OptionsMonad q => [Name] -> q [Dec] -- | Create instance of SBounded for the given type singBoundedInstance :: OptionsMonad q => Name -> q [Dec] -- | Produce instances for PEnum from the given types promoteEnumInstances :: OptionsMonad q => [Name] -> q [Dec] -- | Produce an instance for PEnum from the given type promoteEnumInstance :: OptionsMonad q => Name -> q [Dec] -- | Create instances of SEnum for the given types singEnumInstances :: OptionsMonad q => [Name] -> q [Dec] -- | Create instance of SEnum for the given type singEnumInstance :: OptionsMonad q => Name -> q [Dec] -- | Produce instances for PShow from the given types promoteShowInstances :: OptionsMonad q => [Name] -> q [Dec] -- | Produce an instance for PShow from the given type promoteShowInstance :: OptionsMonad q => Name -> q [Dec] -- | Create instances of SShow for the given types -- -- (Not to be confused with showSingInstances.) singShowInstances :: OptionsMonad q => [Name] -> q [Dec] -- | Create instance of SShow for the given type -- -- (Not to be confused with showShowInstance.) singShowInstance :: OptionsMonad q => Name -> q [Dec] -- | Create instances of Show for the given singleton types -- -- (Not to be confused with singShowInstances.) showSingInstances :: OptionsMonad q => [Name] -> q [Dec] -- | Create instance of Show for the given singleton type -- -- (Not to be confused with singShowInstance.) showSingInstance :: OptionsMonad q => Name -> q [Dec] -- | Create an instance for SingI TyCon{N}, where -- N is the positive number provided as an argument. -- -- Note that the generated code requires the use of the -- QuantifiedConstraints language extension. singITyConInstances :: DsMonad q => [Int] -> q [Dec] -- | Create an instance for SingI TyCon{N}, where -- N is the positive number provided as an argument. -- -- Note that the generated code requires the use of the -- QuantifiedConstraints language extension. singITyConInstance :: DsMonad q => Int -> q Dec -- | The function cases generates a case expression where each -- right-hand side is identical. This may be useful if the type-checker -- requires knowledge of which constructor is used to satisfy equality or -- type-class constraints, but where each constructor is treated the -- same. cases :: DsMonad q => Name -> q Exp -> q Exp -> q Exp -- | The function sCases generates a case expression where each -- right-hand side is identical. This may be useful if the type-checker -- requires knowledge of which constructor is used to satisfy equality or -- type-class constraints, but where each constructor is treated the -- same. For sCases, unlike cases, the scrutinee is a -- singleton. But make sure to pass in the name of the original -- datatype, preferring ''Maybe over ''SMaybe. sCases :: OptionsMonad q => Name -> q Exp -> q Exp -> q Exp -- | Members of the SDecide "kind" class support decidable equality. -- Instances of this class are generated alongside singleton definitions -- for datatypes that derive an Eq instance. class SDecide k -- | Compute a proof or disproof of equality, given two singletons. (%~) :: forall (a :: k) (b :: k). SDecide k => Sing a -> Sing b -> Decision (a :~: b) infix 4 %~ -- | Propositional equality. If a :~: b is inhabited by some -- terminating value, then the type a is the same as the type -- b. To use this equality in practice, pattern-match on the -- a :~: b to get out the Refl constructor; in the body -- of the pattern-match, the compiler knows that a ~ b. data (a :: k) :~: (b :: k) [Refl] :: forall {k} (a :: k). a :~: a infix 4 :~: -- | Uninhabited data type data Void -- | Because we can never create a value of type Void, a function -- that type-checks at a -> Void shows that objects of type -- a can never exist. Thus, we say that a is -- Refuted type Refuted a = a -> Void -- | A Decision about a type a is either a proof of -- existence or a proof that a cannot exist. data Decision a -- | Witness for a Proved :: a -> Decision a -- | Proof that no a exists Disproved :: Refuted a -> Decision a -- | This class (which users should never see) is to be instantiated in -- order to use an otherwise-unused data constructor, such as the -- "kind-inference" data constructor for defunctionalization symbols. class SuppressUnusedWarnings (t :: k) suppressUnusedWarnings :: SuppressUnusedWarnings t => () -- | This file implements singletonStar, which generates a datatype -- Rep and associated singleton from a list of types. The -- promoted version of Rep is kind * and the Haskell -- types themselves. This is still very experimental, so expect unusual -- results! -- -- See also Data.Singletons.Base.CustomStar from -- singletons-base, a variant of this module that also -- re-exports related definitions from Prelude.Singletons. module Data.Singletons.TH.CustomStar -- | Produce a representation and singleton for the collection of types -- given. -- -- A datatype Rep is created, with one constructor per type in -- the declared universe. When this type is promoted by the -- singletons-th library, the constructors become full types in -- *, not just promoted data constructors. -- -- For example, -- --
-- $(singletonStar [''Nat, ''Bool, ''Maybe]) ---- -- generates the following: -- --
-- data Rep = Nat | Bool | Maybe Rep deriving (Eq, Ord, Read, Show) ---- -- and its singleton. However, because Rep is promoted to -- *, the singleton is perhaps slightly unexpected: -- --
-- data SRep (a :: *) where -- SNat :: Sing Nat -- SBool :: Sing Bool -- SMaybe :: Sing a -> Sing (Maybe a) -- type instance Sing = SRep ---- -- The unexpected part is that Nat, Bool, and -- Maybe above are the real Nat, Bool, and -- Maybe, not just promoted data constructors. -- -- Please note that this function is very experimental. Use at -- your own risk. singletonStar :: OptionsMonad q => [Name] -> q [Dec]