[Haskell-cafe] Replace data constructors via meta programming

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Sun Feb 18 13:09:25 UTC 2018


> -- Not valid Haskell!! Can't pattern match on constructor only...
> magic = \case
>     Var -> id
>     Not -> not
>     And -> (&&)
>     Or -> (||)
>     If -> (==>)
>     Iff -> (==)

This has often seemed to me to be a natural extension of case syntax.  There
is a short analysis in the following Reddit post:

    https://www.reddit.com/r/haskell/comments/7s0ski/lambdacase_in_the_wild/dt1zzyy/

I would be strongly in favour of adding an extension to do this (unless
someone can find a reason that it couldn't work).

Tom


More information about the Haskell-Cafe mailing list