{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TemplateHaskell #-}
module Hyper.Unify.Constraints
( TypeConstraints (..)
, HasTypeConstraints (..)
, WithConstraint (..)
, wcConstraint
, wcBody
) where
import Algebra.PartialOrd (PartialOrd (..))
import Data.Kind (Type)
import Hyper (GetHyperType, HyperType, type (#))
import Hyper.Internal.Prelude
class (PartialOrd c, Monoid c) => TypeConstraints c where
generalizeConstraints :: c -> c
toScopeConstraints :: c -> c
class
TypeConstraints (TypeConstraintsOf ast) =>
HasTypeConstraints (ast :: HyperType)
where
type TypeConstraintsOf (ast :: HyperType) :: Type
verifyConstraints ::
TypeConstraintsOf ast ->
ast # h ->
Maybe (ast # WithConstraint h)
data WithConstraint h ast = WithConstraint
{ forall (h :: HyperType) (ast :: AHyperType).
WithConstraint h ast -> TypeConstraintsOf (GetHyperType ast)
_wcConstraint :: TypeConstraintsOf (GetHyperType ast)
, forall (h :: HyperType) (ast :: AHyperType).
WithConstraint h ast -> h ast
_wcBody :: h ast
}
makeLenses ''WithConstraint