What is the grammar rule for this Haskell code?

I have some basic knowledge of Haskell (so forgive me if my question seems trivial for Haskellers here) and have been studying Haskell syntax lately. There is only one place in the Haskell 2010 report that uses the "type" keyword:

topdecl ::= "type" simpletype "=" type 

And as you can see, "=" always required. In one Haskell file, I see this piece of code:

 type Key m :: * 

taken from TrieMap.hs line 61.

which does not comply with the rule. I suspect this is a GHC extension or something similar. Can someone tell me which grammar this piece of code rules with? BTW, I did not find grammar rules for extensions and had to guess many of them, somewhere registered somewhere?

+5
source share
1 answer

This is a related declaration of the type family , part of the TypeFamilies extension.

It is mainly used inside a class declaration to say that a class has a type associated with each instance of it.

I don’t remember a single place that laid out the BNF grammar for extensions well, although I once found the GHC Happy grammar in my repository.

+7
source

Source: https://habr.com/ru/post/1213923/


All Articles