I have basic knowledge of Haskell (so forgive me if my question looks trivial for Haskellers here) and recently have been looking into the syntax of Haskell. In the Haskell 2010 report there is only one place that keyword "type" is used:
topdecl ::= "type" simpletype "=" type
And as can be seen, there is always a "="
is required. In one Haskell file, I see this piece of code:
type Key m :: *
taken from TrieMap.hs line 61.
which doesn't comply to the rule. I suspect this is a GHC extension or something similar. Can someone point out to me which grammar rule this piece of code conforms to? BTW, I didn't find the grammar rules for extensions and had to guess many of them, are there documented somewhere?
That's an associated type family declaration, part of the TypeFamilies
extension.
It's basically used inside a class declaration to tell that the class has a type associated to each instance of it.
I don't remember any place that has nicely laid out BNF grammar for extensions, although I did once find GHC's Happy grammar in its repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With