
Hey, welcome to to the group who have reinvented Church encoding of data types. :) -- Lennart On Mar 7, 2007, at 22:32 , Joachim Breitner wrote:
[Also on http://www.joachim-breitner.de/blog/archives/229-A- different-Maybe-maybe.html]
Hi,
For a while I have been thinking: Isn’t there a way to get rid of the intermediate Maybe construct in a common expression like “fromMaybe default . lookup”. It seems that a way to do that would be to pass more information to the Maybe-generating function: What to do with a Just-Value, and what to return in case of Nothing. This leads to a new definion of the Maybe data type as a function. Later I discovered that this seems to work for any algebraic data type.
This is probably nothing new, but was offline at the time of writing, so I didn’t check. This means that this might also be total rubbish. Enjoy.
* “Algebraic Data Type Done Differently” (PDF-File) at http://www.joachim-breitner.de/various/FunctionalMaybe.pdf * “Algebraic Data Type Done Differently” (Literate Haskell Source) at http://www.joachim-breitner.de/various/FunctionalMaybe.lhs
Comments are appreciated.
Greetings from my holidays, Joachim
-- Joachim "nomeata" Breitner mail: mail@joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C JID: joachimbreitner@amessage.de | http://www.joachim-breitner.de/ Debian Developer: nomeata@debian.org _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe