{-# LANGUAGE FlexibleContexts, TemplateHaskell #-}
module AST.Unify.Constraints
( TypeConstraints(..)
, MonadScopeConstraints(..)
, HasTypeConstraints(..)
, WithConstraint(..), wcConstraint, wcBody
) where
import Algebra.PartialOrd (PartialOrd(..))
import AST (Tree, Knot, GetKnot)
import Control.Lens (makeLenses)
import Data.Kind (Type)
import Prelude.Compat
class (PartialOrd c, Semigroup c) => TypeConstraints c where
generalizeConstraints :: c -> c
toScopeConstraints :: c -> c
class Monad m => MonadScopeConstraints c m where
scopeConstraints :: m c
class
TypeConstraints (TypeConstraintsOf ast) =>
HasTypeConstraints (ast :: Knot -> *) where
type family TypeConstraintsOf (ast :: Knot -> Type) :: Type
verifyConstraints ::
TypeConstraintsOf ast ->
Tree ast k ->
Maybe (Tree ast (WithConstraint k))
data WithConstraint k ast = WithConstraint
{ _wcConstraint :: TypeConstraintsOf (GetKnot ast)
, _wcBody :: k ast
}
makeLenses ''WithConstraint