Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the grammar rule for this Haskell code?

Tags:

syntax

haskell

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?

like image 973
Wickoo Avatar asked Feb 22 '15 18:02

Wickoo


1 Answers

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.

like image 114
Ørjan Johansen Avatar answered Oct 06 '22 01:10

Ørjan Johansen