-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Test instance context
--
-- Use these functions to decide an a not-quite naive fashion whether an
-- instance already exists that satisfies a given context. This can be
-- used to decide whether an instance needs to be generated, as in
-- th-reify-many. Known limitation: the instances inserted into the
-- InstMap are not fully recognized when computing the context.
@package th-context
@version 0.24
-- | The Expanded class helps keep track of which Type
-- values have been fully expanded to a canonical form. This lets us use
-- the Eq and Ord relationships on Type and
-- Pred values when reasoning about instance context. What the
-- expandType function does is use the function from
-- th-desugar to replace occurrences of ConT name with
-- the associated Type if name is a declared type synonym
-- TySynD name _ typ. For convenience, a wrapper type E
-- is provided, along with the Expanded instances E
-- Type and E Pred. Now the expandType and
-- expandPred functions can be used to return values of type E
-- Type and E Pred respectively.
--
-- Instances Expanded Type Type and Expanded Pred Pred
-- are provided in Language.Haskell.TH.Context.Unsafe, for when
-- less type safety is required.
module Language.Haskell.TH.Expand
-- | A concrete type used to mark type which have been expanded
newtype E a
E :: a -> E a
[_unE] :: E a -> a
unE :: forall a_alLT a_apwG. Iso (E a_alLT) (E a_apwG) a_alLT a_apwG
-- | The state type used to memoize expansions.
type ExpandMap = Map Type (E Type)
-- | Apply the th-desugar expand function to a Type and mark it as
-- expanded.
expandType :: (DsMonad m, MonadStates ExpandMap m) => Type -> m (E Type)
-- | Apply the th-desugar expand function to a Pred and mark it as
-- expanded. Note that the definition of Pred changed in
-- template-haskell-2.10.0.0.
expandPred :: (DsMonad m, MonadStates ExpandMap m) => Type -> m (E Type)
-- | Expand a list of Type and build an expanded ClassP
-- Pred.
expandClassP :: forall m. (DsMonad m, MonadStates ExpandMap m) => Name -> [Type] -> m (E Type)
pprint1 :: (Ppr a, Data a) => a -> [Char]
instance Data.Data.Data a => Data.Data.Data (Language.Haskell.TH.Expand.E a)
instance GHC.Show.Show a => GHC.Show.Show (Language.Haskell.TH.Expand.E a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Language.Haskell.TH.Expand.E a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Language.Haskell.TH.Expand.E a)
instance Language.Haskell.TH.Ppr.Ppr a => Language.Haskell.TH.Ppr.Ppr (Language.Haskell.TH.Expand.E a)
instance Language.Haskell.TH.Syntax.Lift (Language.Haskell.TH.Expand.E Language.Haskell.TH.Syntax.Type)
-- | ATP instances for the template haskell type Type, and the
-- conjunction of such types, [Type]. In these instances, almost
-- every role is played by Type. It might a case where the tagged
-- package could be used to advantage. A list represents conjunction, but
-- there is no disjunction operation, nor any derived from it like
-- implication or equivalence.
module Data.Logic.ATP.TH
-- | Helper function to interpret a type application: unfoldApply (AppT
-- (AppT (AppT (VarT (mkName "a")) StarT) ListT) ArrowT) -> (VarT
-- (mkName "a"), [StarT, ListT, ArrowT]) The inverse is uncurry
-- . foldl AppT.
unfoldApply :: Type -> [Type] -> (Type, [Type])
expandBindings :: Map Pred Pred -> Pred -> Pred
instance GHC.Show.Show Data.Logic.ATP.TH.Context
instance GHC.Classes.Ord Data.Logic.ATP.TH.Context
instance GHC.Classes.Eq Data.Logic.ATP.TH.Context
instance Data.Logic.ATP.Pretty.HasFixity Language.Haskell.TH.Syntax.Type
instance Text.PrettyPrint.HughesPJClass.Pretty Language.Haskell.TH.Syntax.Type
instance Text.PrettyPrint.HughesPJClass.Pretty Data.Logic.ATP.TH.Context
instance Data.Logic.ATP.Formulas.IsAtom Language.Haskell.TH.Syntax.Type
instance Data.Logic.ATP.Formulas.IsAtom Data.Logic.ATP.TH.Context
instance Data.String.IsString Language.Haskell.TH.Syntax.Type
instance Data.String.IsString Data.Logic.ATP.TH.Context
instance Data.Logic.ATP.Term.IsVariable Language.Haskell.TH.Syntax.Type
instance Data.Logic.ATP.Term.IsFunction Language.Haskell.TH.Syntax.Type
instance Data.Logic.ATP.Apply.IsPredicate Language.Haskell.TH.Syntax.Type
instance Data.Logic.ATP.Term.IsTerm Language.Haskell.TH.Syntax.Type
instance Data.Logic.ATP.Apply.HasApply Language.Haskell.TH.Syntax.Type
instance Data.Logic.ATP.Equate.HasEquate Language.Haskell.TH.Syntax.Type
instance Data.Logic.ATP.Formulas.IsFormula Language.Haskell.TH.Syntax.Type
instance Data.Logic.ATP.Lit.IsLiteral Language.Haskell.TH.Syntax.Type
instance Data.Logic.ATP.Lit.JustLiteral Language.Haskell.TH.Syntax.Type
instance Data.Logic.ATP.Pretty.HasFixity Data.Logic.ATP.TH.Context
instance Data.Logic.ATP.Formulas.IsFormula Data.Logic.ATP.TH.Context
instance Data.Logic.ATP.Lit.IsLiteral Data.Logic.ATP.TH.Context
instance Data.Logic.ATP.Prop.IsPropositional Data.Logic.ATP.TH.Context
instance GHC.Base.Monad m => Data.Logic.ATP.Unif.Unify m Language.Haskell.TH.Syntax.Type
instance GHC.Base.Monad m => Data.Logic.ATP.Unif.Unify m [Language.Haskell.TH.Syntax.Type]
-- | Compute whether any existing instance satisfies some context in a
-- nearly correct fashion. instance A m => B m where ... I
-- say "nearly correct" because there are cases which are not handled
-- exactly the way GHC behaves, which may lead to false (positives?
-- negatives?)
module Language.Haskell.TH.Context
type InstMap = Map (E Pred) [DecStatus InstanceDec]
-- | Combine the DsMonad (desugaring), which includes the Q monad, and
-- state to record declared instances, type expansions, and a string for
-- debugging messages.
class (DsMonad m, MonadStates InstMap m, MonadStates ExpandMap m, MonadStates String m) => ContextM m
-- | Did we get this instance from the Q monad or does it still need to be
-- spliced?
data DecStatus a
-- | An instance we found in the Q monad
Declared :: a -> DecStatus a
[instanceDec] :: DecStatus a -> a
-- | An instance we inserted via tellInstance
Undeclared :: a -> DecStatus a
[instanceDec] :: DecStatus a -> a
-- | Like qReifyInstances, looks up all the instances that match the
-- given class name and argument types. Unlike qReifyInstances,
-- only the ones that satisfy all the instance context predicates in the
-- environment are returned. If there is already an instance that
-- satisfies the predicate built from the name and types it is returned.
-- If not, this new predicate is inserted into the state monad
-- InstMap, associated with an empty list of predicates, and the
-- empty list is returned. Later the caller can use tellInstance
-- to associate instances with the predicate.
reifyInstancesWithContext :: forall m. ContextM m => Name -> [Type] -> m [InstanceDec]
-- | Declare an instance in the state monad, marked Undeclared. After this,
-- the instance predicate (constructed from class name and type
-- parameters) will be considered part of the context for subsequent
-- calls to reifyInstancesWithContext.
tellInstance :: ContextM m => Dec -> m ()
-- | After all the declared and undeclared instances have been added to the
-- instance map using tellInstance, this returns the undeclared instances
-- only, not the ones that were discovered by reifyInstances, and tells
-- them to the writer monad.
tellUndeclared :: (MonadWriter [Dec] m, MonadStates InstMap m) => m ()
noInstance :: forall m. ContextM m => Name -> Name -> m Bool
instance GHC.Show.Show a => GHC.Show.Show (Language.Haskell.TH.Context.DecStatus a)
instance Language.Haskell.TH.Context.ContextM m => Language.Haskell.TH.Context.ContextM (Control.Monad.Trans.Reader.ReaderT r m)
instance (Language.Haskell.TH.Context.ContextM m, GHC.Base.Monoid w) => Language.Haskell.TH.Context.ContextM (Control.Monad.Trans.Writer.Lazy.WriterT w m)
instance Language.Haskell.TH.Ppr.Ppr a => Language.Haskell.TH.Ppr.Ppr (Language.Haskell.TH.Context.DecStatus a)