AZMCode
            
          
          
          
              
              
          #1
          
         
        
          I find myself wanting to define something like
type MonadErrorV :: Row -> (Type -> Type) -> Type -> Constraint
type MonadErrorV r m = MonadThrow (Variant r) m
or
type MonadErrorV :: Row -> (Type -> Type) -> Type -> Constraint
type MonadErrorV r m a = MonadThrow (Variant r) m a
To clean up some function signatures, but I can’t seem to find a way. Any pointers I could use?
         
        
          
        
           
           
           
         
         
            
            
          
       
      
        
          
          
            smilack
            
          
          
          
              
              
          #2
          
         
        
          I’m not 100% sure but I think you can do it by creating a typeclass with no definitions¹ like this:
class MonadErrorV :: Row Type -> (Type -> Type) -> Constraint
class MonadThrow (Variant r) m <= MonadErrorV r m
(also the kind of Row in this case is Row Type, and note that MonadErrorV is on the right side of the arrow²)
I believe that would make these two function signatures equivalent:
f :: forall r m a
   . MonadThrow (Variant r) m
  => a
  -> m a
g :: forall r m a
   . MonadErrorV r m
  => a
  -> m a
¹ Jordan’s Reference: 05-Typeclasses-with-No-Definitions.purs
² PureScript Documentation: Type Classes: Superclasses