Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data TypeF a
- type UType = UTerm TypeF IntVar
- data UTerm (t :: Type -> Type) v where
- data UTerm (t :: Type -> Type) v where
- data UTerm (t :: Type -> Type) v where
- data UTerm (t :: Type -> Type) v where
- data UTerm (t :: Type -> Type) v where
- data Poly t = Forall [Identifier] t
- type Polytype = Poly Type
- toUType :: Type -> UType
- toPolytype :: UPolytype -> Polytype
- type Infer = ReaderT Ctx (ExceptT TypeError (IntBindingT TypeF Identity))
- lookup :: Identifier -> Infer UType
- withBinding :: MonadReader Ctx m => Identifier -> UPolytype -> m a -> m a
- fresh :: Infer UType
- data TypeError where
- Unreachable :: TypeError
- UnboundVar :: Identifier -> TypeError
- Infinite :: IntVar -> UType -> TypeError
- ImpossibleBinOpApplication :: UType -> UType -> TypeError
- ImpossibleUnOpApplication :: UType -> TypeError
- Mismatch :: TypeF UType -> TypeF UType -> TypeError
- (=:=) :: UType -> UType -> Infer UType
- applyBindings :: UType -> Infer UType
- mkVarName :: String -> IntVar -> Identifier
- generalize :: UType -> Infer UPolytype
Type
Instances
UType
data UTerm (t :: Type -> Type) v where #
The type of terms generated by structures t
over variables
v
. The structure type should implement Unifiable
and the
variable type should implement Variable
.
The Show
instance doesn't show the constructors, in order to
improve legibility for large terms.
All the category theoretic instances (Functor
, Foldable
,
Traversable
,...) are provided because they are often useful;
however, beware that since the implementations must be pure,
they cannot read variables bound in the current context and
therefore can create incoherent results. Therefore, you should
apply the current bindings before using any of the functions
provided by those classes.
pattern UTVar :: Identifier -> UType | |
pattern UTUnit :: UType | |
pattern UTBool :: UType | |
pattern UTInt :: UType | |
pattern UTFun :: UType -> UType -> UType |
Instances
Foldable t => Foldable (UTerm t) | |
Defined in Control.Unification.Types fold :: Monoid m => UTerm t m -> m # foldMap :: Monoid m => (a -> m) -> UTerm t a -> m # foldMap' :: Monoid m => (a -> m) -> UTerm t a -> m # foldr :: (a -> b -> b) -> b -> UTerm t a -> b # foldr' :: (a -> b -> b) -> b -> UTerm t a -> b # foldl :: (b -> a -> b) -> b -> UTerm t a -> b # foldl' :: (b -> a -> b) -> b -> UTerm t a -> b # foldr1 :: (a -> a -> a) -> UTerm t a -> a # foldl1 :: (a -> a -> a) -> UTerm t a -> a # elem :: Eq a => a -> UTerm t a -> Bool # maximum :: Ord a => UTerm t a -> a # minimum :: Ord a => UTerm t a -> a # | |
Traversable t => Traversable (UTerm t) | |
Functor t => Applicative (UTerm t) | |
Functor t => Functor (UTerm t) | |
Functor t => Monad (UTerm t) | |
(Show v, Show (t (UTerm t v))) => Show (UTerm t v) | |
data UTerm (t :: Type -> Type) v where #
The type of terms generated by structures t
over variables
v
. The structure type should implement Unifiable
and the
variable type should implement Variable
.
The Show
instance doesn't show the constructors, in order to
improve legibility for large terms.
All the category theoretic instances (Functor
, Foldable
,
Traversable
,...) are provided because they are often useful;
however, beware that since the implementations must be pure,
they cannot read variables bound in the current context and
therefore can create incoherent results. Therefore, you should
apply the current bindings before using any of the functions
provided by those classes.
pattern UTVar :: Identifier -> UType | |
pattern UTUnit :: UType | |
pattern UTBool :: UType | |
pattern UTInt :: UType | |
pattern UTFun :: UType -> UType -> UType |
Instances
Foldable t => Foldable (UTerm t) | |
Defined in Control.Unification.Types fold :: Monoid m => UTerm t m -> m # foldMap :: Monoid m => (a -> m) -> UTerm t a -> m # foldMap' :: Monoid m => (a -> m) -> UTerm t a -> m # foldr :: (a -> b -> b) -> b -> UTerm t a -> b # foldr' :: (a -> b -> b) -> b -> UTerm t a -> b # foldl :: (b -> a -> b) -> b -> UTerm t a -> b # foldl' :: (b -> a -> b) -> b -> UTerm t a -> b # foldr1 :: (a -> a -> a) -> UTerm t a -> a # foldl1 :: (a -> a -> a) -> UTerm t a -> a # elem :: Eq a => a -> UTerm t a -> Bool # maximum :: Ord a => UTerm t a -> a # minimum :: Ord a => UTerm t a -> a # | |
Traversable t => Traversable (UTerm t) | |
Functor t => Applicative (UTerm t) | |
Functor t => Functor (UTerm t) | |
Functor t => Monad (UTerm t) | |
(Show v, Show (t (UTerm t v))) => Show (UTerm t v) | |
data UTerm (t :: Type -> Type) v where #
The type of terms generated by structures t
over variables
v
. The structure type should implement Unifiable
and the
variable type should implement Variable
.
The Show
instance doesn't show the constructors, in order to
improve legibility for large terms.
All the category theoretic instances (Functor
, Foldable
,
Traversable
,...) are provided because they are often useful;
however, beware that since the implementations must be pure,
they cannot read variables bound in the current context and
therefore can create incoherent results. Therefore, you should
apply the current bindings before using any of the functions
provided by those classes.
pattern UTVar :: Identifier -> UType | |
pattern UTUnit :: UType | |
pattern UTBool :: UType | |
pattern UTInt :: UType | |
pattern UTFun :: UType -> UType -> UType |
Instances
Foldable t => Foldable (UTerm t) | |
Defined in Control.Unification.Types fold :: Monoid m => UTerm t m -> m # foldMap :: Monoid m => (a -> m) -> UTerm t a -> m # foldMap' :: Monoid m => (a -> m) -> UTerm t a -> m # foldr :: (a -> b -> b) -> b -> UTerm t a -> b # foldr' :: (a -> b -> b) -> b -> UTerm t a -> b # foldl :: (b -> a -> b) -> b -> UTerm t a -> b # foldl' :: (b -> a -> b) -> b -> UTerm t a -> b # foldr1 :: (a -> a -> a) -> UTerm t a -> a # foldl1 :: (a -> a -> a) -> UTerm t a -> a # elem :: Eq a => a -> UTerm t a -> Bool # maximum :: Ord a => UTerm t a -> a # minimum :: Ord a => UTerm t a -> a # | |
Traversable t => Traversable (UTerm t) | |
Functor t => Applicative (UTerm t) | |
Functor t => Functor (UTerm t) | |
Functor t => Monad (UTerm t) | |
(Show v, Show (t (UTerm t v))) => Show (UTerm t v) | |
data UTerm (t :: Type -> Type) v where #
The type of terms generated by structures t
over variables
v
. The structure type should implement Unifiable
and the
variable type should implement Variable
.
The Show
instance doesn't show the constructors, in order to
improve legibility for large terms.
All the category theoretic instances (Functor
, Foldable
,
Traversable
,...) are provided because they are often useful;
however, beware that since the implementations must be pure,
they cannot read variables bound in the current context and
therefore can create incoherent results. Therefore, you should
apply the current bindings before using any of the functions
provided by those classes.
pattern UTVar :: Identifier -> UType | |
pattern UTUnit :: UType | |
pattern UTBool :: UType | |
pattern UTInt :: UType | |
pattern UTFun :: UType -> UType -> UType |
Instances
Foldable t => Foldable (UTerm t) | |
Defined in Control.Unification.Types fold :: Monoid m => UTerm t m -> m # foldMap :: Monoid m => (a -> m) -> UTerm t a -> m # foldMap' :: Monoid m => (a -> m) -> UTerm t a -> m # foldr :: (a -> b -> b) -> b -> UTerm t a -> b # foldr' :: (a -> b -> b) -> b -> UTerm t a -> b # foldl :: (b -> a -> b) -> b -> UTerm t a -> b # foldl' :: (b -> a -> b) -> b -> UTerm t a -> b # foldr1 :: (a -> a -> a) -> UTerm t a -> a # foldl1 :: (a -> a -> a) -> UTerm t a -> a # elem :: Eq a => a -> UTerm t a -> Bool # maximum :: Ord a => UTerm t a -> a # minimum :: Ord a => UTerm t a -> a # | |
Traversable t => Traversable (UTerm t) | |
Functor t => Applicative (UTerm t) | |
Functor t => Functor (UTerm t) | |
Functor t => Monad (UTerm t) | |
(Show v, Show (t (UTerm t v))) => Show (UTerm t v) | |
data UTerm (t :: Type -> Type) v where #
The type of terms generated by structures t
over variables
v
. The structure type should implement Unifiable
and the
variable type should implement Variable
.
The Show
instance doesn't show the constructors, in order to
improve legibility for large terms.
All the category theoretic instances (Functor
, Foldable
,
Traversable
,...) are provided because they are often useful;
however, beware that since the implementations must be pure,
they cannot read variables bound in the current context and
therefore can create incoherent results. Therefore, you should
apply the current bindings before using any of the functions
provided by those classes.
pattern UTVar :: Identifier -> UType | |
pattern UTUnit :: UType | |
pattern UTBool :: UType | |
pattern UTInt :: UType | |
pattern UTFun :: UType -> UType -> UType |
Instances
Foldable t => Foldable (UTerm t) | |
Defined in Control.Unification.Types fold :: Monoid m => UTerm t m -> m # foldMap :: Monoid m => (a -> m) -> UTerm t a -> m # foldMap' :: Monoid m => (a -> m) -> UTerm t a -> m # foldr :: (a -> b -> b) -> b -> UTerm t a -> b # foldr' :: (a -> b -> b) -> b -> UTerm t a -> b # foldl :: (b -> a -> b) -> b -> UTerm t a -> b # foldl' :: (b -> a -> b) -> b -> UTerm t a -> b # foldr1 :: (a -> a -> a) -> UTerm t a -> a # foldl1 :: (a -> a -> a) -> UTerm t a -> a # elem :: Eq a => a -> UTerm t a -> Bool # maximum :: Ord a => UTerm t a -> a # minimum :: Ord a => UTerm t a -> a # | |
Traversable t => Traversable (UTerm t) | |
Functor t => Applicative (UTerm t) | |
Functor t => Functor (UTerm t) | |
Functor t => Monad (UTerm t) | |
(Show v, Show (t (UTerm t v))) => Show (UTerm t v) | |
Polytype
Forall [Identifier] t |
Converters
toPolytype :: UPolytype -> Polytype Source #
Infer
withBinding :: MonadReader Ctx m => Identifier -> UPolytype -> m a -> m a Source #
FreeVars
Errors
Unreachable :: TypeError | |
UnboundVar :: Identifier -> TypeError | |
Infinite :: IntVar -> UType -> TypeError | |
ImpossibleBinOpApplication :: UType -> UType -> TypeError | |
ImpossibleUnOpApplication :: UType -> TypeError | |
Mismatch :: TypeF UType -> TypeF UType -> TypeError |
generalize :: UType -> Infer UPolytype Source #