Type system compiler flags

Daniel Fischer daniel.is.fischer at googlemail.com
Tue Feb 1 12:34:09 CET 2011


On Tuesday 01 February 2011 11:45:58, Julian Bean wrote:
> > It indeed does, even though I doubted it at first.  As far as I
> > remember the type in
> >
> >    getnArrayST n bs :: ST s (Maybe (UArray Int Word8, [Word8])) =
> >
> > used to be necessary to bind the type variable s.  Apparently things
> > have become easier.
>
> The higher-rank inference has been changed quite a bit, but I think
> -XPatternSignatures is all you were missing to get your original code to
> compiler (well, at least to parse).

No, I tried, the parser still choked on the above signature. You can get 
the other one, (a :: STUArray s Int Word8), to be parsed with 
PatternSignatures, but

    A pattern type signature cannot bind scoped type variables `s'
      unless the pattern has a rigid type context
    In the pattern: a :: STUArray s Int Word8
    In a stmt of a 'do' expression:
        (a :: STUArray s Int Word8) <- newArray_ (0, n - 1)
    In the expression:
        do { (a :: STUArray s Int Word8) <- newArray_ (0, n - 1);
             let loop k bs
                        | k == n = ...
                        | k < n = ...;
             loop 0 bs }

even if you remove the forall from getnArrayST's type signature. I don't 
know why `s' is a scoped type variable without the forall and 
ScopedTypeVariables, but that's what 6.12.3 says. 7.0.1 complains about

    No instance for (MArray (STUArray s) Word8 (ST s1))

which I understand.

>
> Jules




More information about the Glasgow-haskell-users mailing list