Hi Alex,

>Ok, then I am officially complaining about the elimination of ++ and
>MonadPlus.  It is a much more radical change than changing default
>default and it will break a lot of MY code at very least.
>
>The existing implementation in hugs allows you to write extremely concise
>and clean code.  If I want to replace Maybe in my code with a list
>implementation then I can do that.  You are taking that away!!
>
>Why are you specializing ++ to lists?  Can you at leat leave ++ as a
>function in a class like:
>
>> class Concat a where
>>  (++)::a->a->a
>
>Or as per my prior mail, define a List class in which I can override ++.
>
>Either way, please please please don't specialize ++ to lists.  It is a
>radical and unwarranted change.

I completely agree with you, but most people thought that it is confusing to
overload "list" functions like (++) and (map) to arbitrary monads. Hopefully
you are not relying on monad-comprehensions, because they have been
unoverloaded as well. You don't have to be desparate though. It is easy to
translate from comprehension- to do-notation.

The do-notation is still there for arbitrary monads, and is now even simpler
because (zero) has been moved from MonadZero to Monad. This is really the
only thing that is hardwired in the language and that you cannot change
yourself. From this point you design your own idealized prelude on top of
what is given by hiding, renaming and adding classes and functions. For
example, for the Concat class you want things would look like:

module Alexander'sPrelude where

import Prelude hiding ((++))
import qualified Prelude

class C a where{ (++) :: a -> a -> a }

instance C ([a]) where { (++) = (Prelude.++) }

-- In non-Hugs Haskell you would use
-- newtype L a = L ([a] -> [a])
-- but then I don't like to wrap and unwrap
-- all those silly constructors.

type L a = ([a] -> [a]) in ccL, toL, fromL

ccL :: L a -> L a -> L a
ccL = (.)

toL :: [a] -> L a
toL as = \as' -> as ++ as'

fromL :: L a -> [a]
fromL as = as []

instance C (L a) where { (++) = ccL }

Do you get the idea? As I said before in an earlier message, an extra level
of indirection keeps the doctor away. The pots (do-notation) and the furnace
(the Haskell core language) must be there and work. There is no disputing
about tastes, so as long as I can spice my own food, I am a happy man.

Erik "Haskell98 burns hotter" Meijer



Reply via email to