Skip to content

Polymorphic kind annotations on type classes don't always work as expected

Consider the following code for defining Atkey-style parameterised monads:

{-# LANGUAGE
    PolyKinds
 #-}

class PMonad m where
  ret  :: a -> m i i a
  bind :: m i j a -> (a -> m j k b) -> m i k b
class PMonad' (m :: i -> i -> * -> *) where
  ret'  :: a -> m i i a
  bind' :: m i j a -> (a -> m j k b) -> m i k b

The following types are inferred for ret and ret':

*Main> :t ret
ret :: PMonad * m => a -> m i i a
*Main> :t ret'
ret' :: PMonad' m => a -> m BOX BOX a

But ret' should have the former type.

Trac metadata
Trac field Value
Version 7.6.1-rc1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information