yesodweb / yesodweb/persistent
Deriving Typeclasses with Arguments
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 486
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
Version: 2.14.0.0
Stack LTS: 19.5
Take the following typeclass:
class Pointless a b where
lol :: a -> b -> ()
lol = const $ const ()
This could be derived as follows:
data Something = Something
{ a :: Int
, b :: Int
} deriving (Pointless Int)
However the following fails as a persistent template:
Person
name String
age Int
deriving Show (Pointless Int)
The error given is Illegal type constructor or class name: ‘Pointless Int’.
And the deriving statements appear to be expanded to:
deriving stock Show
deriving anyclass Pointless Int
I assume it's due to the omission of the brackets in the generated code? Is there a way I can get persistent to keep them, is this a bug or just not something that is supported?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the persistent template expansion that emits the deriving clauses, then compare the source deriving (Pointless Int) with generated deriving anyclass Pointless Int. Done means either generated Haskell preserves the parentheses and compiles, or the issue is documented as unsupported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- database, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100