On Tue, 5 Oct 1999, Theo Norvell wrote:
> On Tue, 5 Oct 1999, Kevin Atkinson wrote:
>
> > If there is enough interest I could repost this code as well as an
> > explanation of the many "hacks" I had to due to get around ambiguity
> > arising fro the use of multiple parameter classes and other
> > limitations of Haskell.
>
> Rather than repost all the code, could you post just enough to show the
> source of the difficulty?
Ok, here is the biggest one.
I have a generic mutable array class which has a few basic methods:
class MArray ... where
newArray :: Int -> m (mutArray st el)
write :: mutArray st el -> Int -> el -> m ()
read :: mutArray st el -> Int -> m el
freeze :: m mutArray st el -> m array el
thaw :: m array el -> m mutArray st el
and it turns out that it is possible to create a full fledge
non-mutable array based on the mutable array class with the help of
this method:
thawRunFreeze :: Array el
-> (m mutArray st el -> m ())
-> Array el
Which will, as the signature suggests and name suggest, thaw an array,
perform some actions on the mutable array, and then freeze it,
returning the new array.
The only problem is that it is impossible to have a generic
thawRunFreeze method in Haskell. So I had to resort to some ugly code
generation.
If I have time I will put together a more detailed report of exactly
Why Haskell can't do it. However in the mean time this should give
you an idea of the sharp limitations of Haskell current type system.
The original post can be found at
http://www.dcs.gla.ac.uk/mail-www/haskell/msg01592.html.
---
Kevin Atkinson
[EMAIL PROTECTED]
http://metalab.unc.edu/kevina/