haskell / haskell/error-messages

The constraint ... is no smaller than the instance head... (Use UndecidableInstances ...)

Open
#55 7 comments 0 reactions 0 assignees View on GitHub
status:Composing error message tool:GHC type:error-message
Dominant language
No language data
Stars
76
Forks
19
PR merge metrics
No merged PRs in 30d

Description

Example:

```
{-# language FlexibleInstances #-}

module Main where

class X x where
x :: x

class Y y where
y :: y

instance X a => Y a where
y = undefined
```

The error is:

```
/home/noon/tmp/err/src/Main.hs:11:10: error:
• The constraint ‘X a’ is no smaller than the instance head ‘Y a’
(Use UndecidableInstances to permit this)
• In the instance declaration for ‘Y a’
|
11 | instance X a => Y a where
```

Of course, `UndecidableInstances` is perhaps one fix, but a "better" one, as I understand it, [is the newtype wrapper](https://stackoverflow.com/a/7198951).

Maybe this error message could change to make this suggestion?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.