Implementing functional programming in Perl

后端 未结 4 633
执笔经年
执笔经年 2021-02-05 08:33

I am trying to learn pure functional programming language like Haskell as I am from Perl background and read that Perl can also implement functional programming techniques. So f

4条回答
  •  孤独总比滥情好
    2021-02-05 08:48

    Functional programming is just programming, you can do it in any language. If you like how the Haskell API is laid out, you might like my Data::Monad module, which provides Moose roles for various Haskell typeclasses including Monad. (Unlike Haskell, though, there is no "fail" in my Monad, and all Monads are Functors.)

    Here's an example of exercising the various typeclasses in the context of a data structure that handles success or failure (like Control.Monad.Error):

    http://github.com/jrockway/data-monad/blob/master/t/error.t

    Note that it has the ability to convert usual Perl computations that can fail with an exception to a pure procedure that you can bind to other procedures. This lets "regular Perl" work inside a program designed to have a more functional control flow.

提交回复
热议问题