[Haskell-cafe] GHCi vs. Hugs (record syntax)

Claus Reinke claus.reinke at talk21.com
Sun May 31 06:39:08 EDT 2009


> head[[]{}]
> 
> GHCi: []
> Hugs: ERROR - Empty field list in update
> 
> What is the correct behavior?

Seems as if GHC interprets []{} as labelled construction instead
of labelled update - 3 Expressions (the grammar productions):

    | qcon { fbind1 , ... , fbindn } (labeled construction, n>=0) 
    | aexp<qcon> { fbind1 , ... , fbindn } (labeled update, n >= 1) 

But the grammar (3.2) makes [] and () into exceptions (gcon, not qcon)

    gcon -> () 
        | [] 
        | (,{,}) 
        | qcon 

(though interpreting them as nullary constructors may be more
consistent..).

Btw, the language report is recommended browsing for all Haskellers:
http://www.haskell.org/haskellwiki/Language_and_library_specification

In addition to fun puzzles like the above, it also answers many beginner 
questions frequently asked on this list and provides lots of small code
snippets.

What do I win?-)
Claus




More information about the Haskell-Cafe mailing list