haskell / haskell/error-messages

"X has fields" error doesn't tell me what the problem is (`-XOverloadedRecordDot`)

Open
#53 4 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

I have the following:

```haskell
instance HasField x a b => HasField (x :: Symbol) (Behavior a) (Behavior b) where
getField behavior = behavior <&> getField @x
```

Yet when I compile this I get

```
lib/Reactive/Banana/Orphans.hs:36:28: error:
• Illegal instance declaration for
‘HasField x (Behavior a) (Behavior b)’
Behavior has fields
• In the instance declaration for
‘HasField (x :: Symbol) (Behavior a) (Behavior b)’
|
36 | instance HasField x a b => HasField (x :: Symbol) (Behavior a) (Behavior b) where
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

which just leaves me confused.

Why is the instance illegal? "Behavior has fields" - yes, and? Is that a problem? Also `Behavior` *doesn't* have even fields - it's an [opaque type](https://hackage.haskell.org/package/reactive-banana-1.3.0.0/docs/Reactive-Banana-Combinators.html#t:Behavior)!

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.