> ghc-4.01, linux, binary for i386   says
> 
>   panic! (the `impossible' happened):
>           tcLookupGlobalValue: T.name{-r1n,x-} ...

It's a GHC bug all right...

> when compiling
> -------------------------------------------------------------
> data S a = S {longFieldName :: a}
> 
> f :: S String -> S String 
> f    s        = 
>                  let  S {name = x} = s  in  S {name = tail x}
> 
> name = longFieldName   -- local for this module
> -------------------------------------------------------------
> 
> 
> Otherwise, how can one introduce a short local synonym for 
> longFieldName ?

You can't!  When it's used as an ordinary *function* (i.e. selector) you
can,
but not when it's used as a field name in a pattern or record
construction or update.  It's just an infelicity in Haskell I'm afraid.

You can use qualified names, though:

        module L where
                data A a = S { short :: a }

        module Main where
                import L

                f s = let S {L.short = x} = s in S {L.short = tail x}


Simoin

> I thought, the record field is treated as a function ...
> And the long global names for the record fields, they look in-
> avoidible in Haskell-98. Because, as, say, in the above example, many 
> different kinds of object modelled by records are likely to have a 
> field called `name'.

Reply via email to