Reputation: 89043
Ran into this issue when playing with today's advent of code problem.
Say I have:
data Cache = Cache { _a :: Int, _b :: Int }
makeLenses ''Cache
type Register = Lens' Cache Int
Using Parsec, I can parse the character 'a' as a :: Register
and the character 'b' as b :: Register
.
register = a <$ char 'a' <|> b <$ char 'b'
which, alone, compiles just fine.
The trouble is when I give register
the explicit type Stream s m Char => ParsecT s u m Register
, ghc complains that it wants to give it the type (Functor f, Stream s m Char) => ParsecT s u m ((Int -> f Int) -> Cache -> f Cache)
.
I think I understand its reasoning - it wants to float the typeclass constraints out as a far as possible; this is just slightly inconvenient to me for purposes of documenting register
.
Is there a standard workaround for situations like this?
Upvotes: 1
Views: 75