Language.PureScript.TypeChecker.Entailment

purescript-0.15.15: PureScript Programming Language Compiler

Safe Haskell | None
Language | Haskell2010

Language.PureScript.TypeChecker.Entailment

Description

Type class entailment

Synopsis

- type InstanceContext = Map QualifiedBy (Map (Qualified (ProperName 'ClassName)) (Map (Qualified Ident) (NonEmpty NamedDict)))
- data SolverOptions = SolverOptions {
  - solverShouldGeneralize :: Bool
  - solverDeferErrors :: Bool
  }
- replaceTypeClassDictionaries :: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadSupply m) => Bool -> Expr -> m (Expr, [(Ident, InstanceContext, SourceConstraint)])
- newDictionaries :: MonadState CheckState m => [(Qualified (ProperName 'ClassName), Integer)] -> Qualified Ident -> SourceConstraint -> m [NamedDict]
- entails :: forall (m :: Type -> Type). (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadSupply m) => SolverOptions -> SourceConstraint -> InstanceContext -> [ErrorMessageHint] -> WriterT (Any, [(Ident, InstanceContext, SourceConstraint)]) (StateT InstanceContext m) Expr
- findDicts :: InstanceContext -> Qualified (ProperName 'ClassName) -> QualifiedBy -> [TypeClassDict]

# Documentation

type InstanceContext = Map QualifiedBy (Map (Qualified (ProperName 'ClassName)) (Map (Qualified Ident) (NonEmpty NamedDict))) #

The `InstanceContext` tracks those constraints which can be satisfied.

data SolverOptions #

Options for the constraint solver

Constructors

SolverOptions |
Fields solverShouldGeneralize :: Bool Should the solver be allowed to generalize over unsolved constraints? solverDeferErrors :: Bool Should the solver be allowed to defer errors by skipping constraints?

replaceTypeClassDictionaries :: (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadSupply m) => Bool -> Expr -> m (Expr, [(Ident, InstanceContext, SourceConstraint)]) #

Replace type class dictionary placeholders with inferred type class dictionaries

newDictionaries :: MonadState CheckState m => [(Qualified (ProperName 'ClassName), Integer)] -> Qualified Ident -> SourceConstraint -> m [NamedDict] #

Add a dictionary for the constraint to the scope, and dictionaries for all implied superclass instances.

entails #

Arguments

:: forall (m :: Type -> Type). (MonadState CheckState m, MonadError MultipleErrors m, MonadWriter MultipleErrors m, MonadSupply m) |
=> SolverOptions | Solver options
-> SourceConstraint | The constraint to solve
-> InstanceContext | The contexts in which to solve the constraint
-> [ErrorMessageHint] | Error message hints to apply to any instance errors
-> WriterT (Any, [(Ident, InstanceContext, SourceConstraint)]) (StateT InstanceContext m) Expr |

Check that the current set of type class dictionaries entail the specified type class goal, and, if so, return a type class dictionary reference.

findDicts :: InstanceContext -> Qualified (ProperName 'ClassName) -> QualifiedBy -> [TypeClassDict] #