Implict parameters and monomorphism

Marcin 'Qrczak' Kowalczyk qrczak@knm.org.pl
4 May 2001 18:50:30 GMT


Fri, 4 May 2001 11:27:07 -0700, John Meacham <john@foo.net> pisze:

> My idea was to allow '_' to be used in type signatures and represent
> any type.

I like it. There were also proposals for '..'.

It would be useful in cases analogous to this:

import IArray
import MArray

f:: (IArray a e, Ix i) => a i e -> a i e
f arr = runST (do
    marr <- thaw arr
    do some stateful operations on marr
    freeze marr)

where the type of thaw and freeze make the mutable array type
ambiguous. A type signature to disambiguate it would have to mention
element and index types, which are type variables bound outside, and
the state token, which is eaten by runST. So you have to either use
a ghc/Hugs extension of pattern or result type signatures, to bind
all these types to names, and move the body to a separate function,
so the state token is visible - or specify a polymorphic function type
signature on freeze alone or use a specialized variant of freeze.
It would be nice to write just (marr :: STArray _ _ _) without having
to invent types for the state, index and element.

-- 
 __("<  Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK