Skip to content
Parser Combinators, Maybe, Either, State, Reader, StateMaybe, StateEither in JavaScript and in ECMAScript 6
JavaScript HTML Other
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
es6 eval0 implemented up to Plus (included) Nov 3, 2019
haskell little refurbishing in the Haskell area Oct 6, 2019
io first real io functor stuff Apr 18, 2019
js minor stuff Aug 14, 2016
parsers-node strange commit Aug 29, 2019
.editorconfig editorconfig and its beneficial effects May 3, 2018
.gitattributes Initial Commit Aug 8, 2013
.gitignore adjusting .gitignores Jun 7, 2019
LICENSE License file Sep 20, 2014
MochaGeiesmonadsES6_StateEither_Test.htm minor thingies Apr 23, 2017
MochaGeiesmonadsES6_StateMaybe_Test.htm better data on supported browsers Oct 14, 2015
MochaGeiesmonadsES6_Test.htm better data on supported browsers Oct 14, 2015 Update Dec 16, 2018
YUIGeiesmonads_TRAIN_Test.htm major refurbishment - ES6 rulez Oct 4, 2015
YUIGeiesmonads_Test.htm major refurbishment - ES6 rulez Oct 4, 2015

geiesmonads (j-s-monads)

alt image

Crisp clear chainable JavaScript/ECMAScript 6 monads.

Special Challenge: parser combinators in JavaScript!!!

File parsers.js contains an implementation of chainable parser combinators, featuring both applicative and monadic interfaces.

Test page is here.

Live examples page is here.

A JSON parser is under construction, and it is tested here.

NB - with a big credit due to Understanding Parser Combinators and to Paco.

New with RELEASE 2.2

File geiesmonads_es6_reader.js contains an implementation of a chainable reader monad.

Test page is here.

NB - with a big credit due to Don't Fear the Reader.

New with RELEASE 2.1

Maybe, Either a, State, StateMaybe and StateEither in ECMAScript 6.

Click on the above links to access the Mocha unit test page (verify whether your browser can run the code).

NB: This repo has been tested on FF 41 and Chrome 57.

Define a State monad that manages errors (in a sense like Maybe): if an error/problem occurs during the "do" computation, it is signalled and propagated by bind.

  • Step 1) The presence of a None indicates an error has occurred -> StateMaybe monad
  • Step 2) The error should propagate carrying a string which describes what occurred -> StateEither monad

See files:

New with RELEASE 2.0

  • Minor improvements to the maybe monad:
    • introduction of inner functions some() and none()
    • streamlining of the API
  • Major improvements to the state monad:
    • monad as pure JS function - see [7]
  • Implementation of monadic labeling for a binary tree and its comparison with manual labeling. See [4]
  • Usage of the state monad to emulate imperative programming - see [5]


ORIGINAL CONTRIBUTION: Implementation of a chainable state monad.

This monad is a native JS function with type s -> (s,a) enriched with a bind method. The present JS implementation of [4] is also available in Java 8 language at [6]

See file geiesmonads_0.2.js and related tests.


  • The non-chainable identity, maybe and state monad are just repetitions of implementations given in [2] and [3]

  • The chainable maybe monad is a re-elaboration of some old code of mine, written in Java and available at my blog

  • My original contribution (the chainable state monad) is a truly cool thing.

I am in debt with:



I am in DEEP debt with:

[1] (and also part 2,3,4)



A bit of self-promotion:



Every feedback is welcome.

Released under MIT License.

You can’t perform that action at this time.