1 {-# LANGUAGE ConstraintKinds #-}
2 {-# LANGUAGE DataKinds #-}
3 {-# LANGUAGE ExistentialQuantification #-}
4 {-# LANGUAGE TypeFamilies #-}
5 module Control.Monad.Classes.Instance where
6 import Data.Bool (Bool(..))
7 import GHC.Prim (Constraint)
9 -- | A data type to existentially wrap a value of type @ty@,
10 -- when it is an instance of the type class @cl@.
11 data Instance (cl:: * -> Constraint)
12 = forall ty. cl ty => Instance ty
14 -- | An open type family to know (at the type level) whether a type @ty@
15 -- has an instance of the type class @cl@.
17 -- NOTE: currently, users have to manually define type family instances of 'Class'
18 -- to indicate to the compiler which type support which type class.
19 -- It is definitively redundant to have to define
20 -- both a type class instance and a type family instance,
21 -- but I cannot find a way to automatically synchronize
22 -- the compiler's knowledge between these two levels.
23 type family Class (cl:: * -> Constraint) (ty:: *) :: Bool