| Next | Functional Programming in Perl | 27 |
Related note:
I'm trying to write an article explaining monads to Perl programmers
The primary difficulty is syntactic
The notation is impossible
Even with Haskell's super-concise functional notation, it's almost impossible
-- Hardly anyone wants to write this:
eval (Div n d) =
(eval n) >>= \nv -> (eval d) >>= \dv ->
if dv == 0 then raise "Ouch" else return nv / dv
-- Instead:
eval (Div n d) =
do nv <- eval n; dv <- eval d;
if dv == 0 then raise "Ouch" else return nv / dv
And Perl doesn't have this syntactic sugar, so I'm stuck
Monadic programming appears to be impractical in Perl...
Only because of syntactic issues
| Next | ![]() |
Copyright 2005 M. J. Dominus |