Skip to content

Terrible error message with fundeps and PolyKinds

Hello! Let's look at this small example:

class ConsByIdx2 x a m cls | x -> m where
    consByIdx2 :: x -> a -> m cls


instance ConsByIdx2 Int a Proxy cls where
    consByIdx2 _ _ = Proxy

It fails to compile with the following error:

    Illegal instance declaration for ‘ConsByIdx2 Int a Proxy cls’
      The liberal coverage condition fails in class ‘ConsByIdx2’
        for functional dependency: ‘x -> m’
      Reason: lhs type ‘Int’ does not determine rhs type ‘Proxy’
    In the instance declaration for ‘ConsByIdx2 Int a Proxy cls’

But Int determines the Proxy in a nice way.

Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information