mattbierner / atum

Javascript Interpreter in Functional-Style Javascript
MIT License
19 stars 2 forks source link

Formalize Different Monads Used #129

Closed mattbierner closed 11 years ago

mattbierner commented 11 years ago

3 (or 4) monads are used in Atum (excluding base types that are transformed). The use and interfaces of these monads is rather ad hoc. Formalizing the interfaces between these using general operations would be beneficial as it would reduce logic duplication and allow working at a higher level of abstraction.

The lack of a type system means any solution will not be as elegant as Haskell, or even have any sound mathematical support, and direct emulation should not be the goal.

The types are:

A minimum of three operations must be defined for each:

Standard monadic lifting operations will also be defined, either as general operations or one specific to a given pair.

Further specialization could breakdown the monads into their components, such as using lifted State/Cont operations, although a good Javascript style interface would be required for this as without Haskell's type system and type inference this could be messy.

mattbierner commented 11 years ago

Started and statement monad added.

Currently there are cases where non lifted versions are mixed together. That must be eliminated.

Also, it is not clear how bind should work for statement. Does it only call f if c results in a normal completion or anything except an error completion or with any result. Currently it does the last, but the first seems more correct if an additional method that intercepts abrupt completions is handled.

A set of general combinators for monads, like the between operation which only depends on just and bind of a type class, should also be added so that this logic can be reused.