123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- (define (scheme-monad-link)
- (anchor [article]
- "http://okmij.org/ftp/Scheme/monad-in-Scheme.html"))
- (define (guile-monad-link)
- (anchor [package]
- "http://git.savannah.gnu.org/cgit/guix.git/tree/guix/monads.scm"))
- (post
- :title "Monads in Scheme!?"
- :date (make-date* 2016 9 12)
- :tags '("monads" "resource" "scheme" "guile" "haskell")
- (h4 [TLDR: Canonical scheme-monad ,(scheme-monad-link);
- A guile-monad ,(guile-monad-link) exists!])
- (h3 [Some Motivation])
- (p [Hi all, if you are like me, you
- started trying out Haskell, and were immediately confronted with
- the ominous IOMonad.
- To get by, I simply just remembered to use the <- syntax for output,
- and that Monads were Haskell's way to model imperative programming
- in a fully functional domain.])
- (p [But learning Haskell -> leaning monads, so I soon wanted to look under
- the hood and implement one.
- I parsed through quite a few monad introductions/tutorials.
- Turns out monads are a construct in category theory that
- implements the functions bind (<<=) and return. Soon enough I had
- written my first monad. I didn't really understand what I was doing
- though, mostly because Haskell monads
- are surrounded by ample sugar, which is good for fast development,
- but didn't help me picture its lambda calculus representation.
- The tutorials didn't help much here either.])
- (p [Of course, I could have given Haskell more time, but I stumbled upon a simple
- and elucidating ,(scheme-monad-link) using monads in Scheme!])
- (p [I highly recommend reading the source. The first half
- implements a monad using basic lambda expressions, and the second
- half develops the syntactic sugar to make working with monads
- like working with standard procedures. It then uses these forms to create
- a really cool binary tree that tags each node with a unique
- value, without exposing the tagging system to the user. If you
- haven't seen something like this before, it will honestly blow your
- mind.])
- (h3 [Monad support in Scheme?])
- (p [It's nice seeing a monad implemented in a simple language like Scheme,
- since its basic implementation, and syntactic extension are
- easy to read, and not a built-in language feature.
- Other than for learning though, is it worth having monads in Scheme?
- It is already imperative, and has simple patterns for IO, unlike
- Haskell, which
- requires them. Yet after reading the article above,
- monads are an elegant choice for solving certain types of problems.
- Only problem is, no one has implemented a basic monad library.])
- (h3 [Monad package in Scheme!?])
- (p [That was until while working on a Guix package, I stumbled on a pretty
- amazing monad library hidden within its core ,(guile-monad-link). Thank you
- civodul from #guix for writing this! It's def worth reading; it
- implements some of the popular monads from Haskell.])
- (p [As I continue to use Scheme, I hope to take advantage of and add to this library.
- Look forward to a standalone monad package!]))
|