haskell / haskell/error-messages
Unhelpful error with associated types
- Dominant language
- No language data
- Stars
- 76
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
In [this stackoverflow question](https://stackoverflow.com/q/68896181/15207568) the asker presents this code:
```haskell
{-# LANGUAGE TypeFamilies #-}
class Reproductive a where
-- | A sequence of genetic information for an agent.
type Strand a
-- | Full set (both strands) of genetic information for an organism.
type Genome a = (Strand a, Strand a)
```
But this produces the unhelpful error message (I was confused for a minute):
```
Assoc.hs:20:8: error:
‘Genome’ is not a (visible) associated type of class ‘Reproductive’
|
20 | type Genome a = (Strand a, Strand a)
| ^^^^^^
```
As a user I'm thinking that I'm defining an associated type, but this error message says that it expects the type to already be defined.
I now understand that you can easily solve this by writing a separate "kind signature" where the signature part can be omitted because it defaults to `*`:
```haskell
{-# LANGUAGE TypeFamilies #-}
class Reproductive a where
-- | A sequence of genetic information for an agent.
type Strand a
-- | Full set (both strands) of genetic information for an organism.
type Genome a
type Genome a = (Strand a, Strand a)
```
I think this warning can be improved, but I'm not sure how, yet.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.