haskell / haskell/error-messages

Better MonadFail

Open
#29 1 comment 3 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

*from Haskell GameDev discord*

Given a failable `... <- ...` pattern on sum type `Request` with two variants:

![unknown](https://user-images.githubusercontent.com/13222800/149454513-160fda60-8a37-46c1-b381-45bfcc3a337b.png)

Most users probably don't want to implement a `MonadFail` instance for monads defined in a library. The following would be more helpful:

```
• Failable pattern in non-failable do statement
`(HaulRequest (resource, requiredAmount) amount)`
This pattern fails on:
`ConstructionRequest`
• Note: the left pattern of `<-` must succeed on
all variants unless `MonadFail` is defined
• Perhaps you intended to handle each variant with `case`:
`r0 <- get building
case r0 of
HaulRequest ...
ConstructionRequest ...`
• Perhaps you intended to define a
`MonadFail (SystemT World IO)` instance to
handle failable patterns
```

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.