Skip to content

Doesn't accept type

import Data.Kind
import qualified Control.Category as Cat

newtype Transformer f g where
  Transform :: (forall i. f i ~> g i) -> Transformer f g

type family 
  (~>) :: k -> k -> Type where
  (~>) = (->)
  (~>) = Transformer
 
instance 
  Cat.Category ((~>) :: k -> k -> Type) 
  => 
  Cat.Category (Transformer :: (i -> k) -> (i -> k) -> Type) where

  id :: forall (f :: i -> k). Transformer f f
  id = Transform Cat.id

works, as well as omitting the instance signature:

  id = Transform Cat.id

Implicitly quantifying f or omitting its kind signature result in the same error:

  id :: Transformer f f 
  id = Transform Cat.id

--     • Could not deduce (Cat.Category (~>))
--         arising from a use of ‘Cat.id’
--       from the context: Cat.Category (~>)
--         bound by the instance declaration at /tmp/tX81.hs:(13,3)-(15,60)
--     • In the first argument of ‘Transform’, namely ‘Cat.id’
--       In the expression: Transform Cat.id
--       In an equation for ‘id’: id = Transform Cat.id
-- Compilation failed.

Should it compile

Trac metadata
Trac field Value
Version 8.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
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