Problem with prepose.lhs and ghc6.10.1

../haskell/prepose.lhs:707:0: Parse error in pattern which is pointing at: normalize a :: M s a = M (mod a (modulus (undefined :: s)))
The code indeed used lexically scoped type variables -- which GHC at that time implemented differently. Incidentally, on the above line, M s a is the type annotation on the result of (normalize a) rather than on the argument 'a'. Therefore, putting a parentheses like (a :: M s a) is wrong. Since the implementation of local type variables in GHC changed over the years, it's best to get rid of them. Here is the same line in the Hugs version of the code
normalize :: (Modular s a, Integral a) => a -> M s a normalize a = r a __ where r :: (Modular s a, Integral a) => a -> s -> M s a r a s = M (mod a (modulus s))
Of course the signature for normalize can be omitted. Hugs did not support lexically scoped type variables then (and probably doesn't support now). Today I would have written this definition simpler:
normalize :: (Modular s a, Integral a) => a -> M s a normalize a = r where r = M (mod a (modulus (tcar2 r)))
tcar2:: f s x -> s tcar2 = undefined
(the function tcar2 is used in a few other places in the Hugs code, for a similar purpose).

Hugs did not support lexically scoped type variables then (and probably doesn't support now).
I may be misremembering, but I think Hugs had them first;-) http://cvs.haskell.org/Hugs/pages/hugsman/exts.html#sect7.3.3 It is just that Hugs and GHC interpret the language extension differently (as usual), so it doesn't quite support the same code in both. That is made worse by differences in other language features relevant to using this extension. Not to mention that all of that keeps evolving over time. Claus
participants (2)
-
Claus Reinke
-
oleg@okmij.org