Simon (PJ) sez:
> Is this a storm in a teacup? Much huff and puff for a seldom-occurring
> situation?  No!  It happens to me ALL THE TIME.

I have to join Simon out of the closet, and confess that I write
Clunky Functions rather a lot too, or at least find myself going to
significant lengths to avoid them.  (No coincidence that the first
ghc-2.02 bug I noticed was that "maybe" was missing...)

Syntax:  I think what Simon proposes is reasonable, though I have minor
reservations about the use of "<-".  The monadic rationale seems a bit
thin, but will do in a pinch.  Simon's examples alternate between using
comma-separation, and layout separation:  I assume the latter is a
Freudian typo, but might be a viable alternative.

Heribert Schutz's suggestions I'm more wary of; I can't immediately
think of any example which would require syntax this general, and it's
also hard to come up with a more readable alternative.  I can see
the attraction of turning pattern-guards into an actual monad, Maybe
or otherwise, but I think it'd require some sugaring of the unit case,
which is after all what will be written 99% of the time, reviving
the issue of what syntax to use for it.  The example using this
syntax, in fact, doesn't make essential use of pattern guards at all,
so I'm as yet agnostic about how much it buys.

Slainte,
Alex.
--

>     -- version 5a
>     simplify (Plus e e') = fromJust ( [s' | Val 0 <- Just s ]
>                                    ++ [s  | Val 0 <- Just s']
>                                    ++ Just (Plus s s') )
>                            where
>                            s  = simplify e
>                            s' = simplify e'
>     simplify e           = e



Reply via email to