fantasyland / static-land

Specification for common algebraic structures in JavaScript based on Fantasy Land
MIT License
772 stars 41 forks source link

Do notation using generators #7

Closed rpominov closed 8 years ago

rpominov commented 8 years ago

Using https://github.com/pelotom/burrido or similar approach we could make it look something like this:

import {do, SArray} from 'static-land'

const result = do(SArray, function* () {
  const x = yield [1, 2]
  const y = yield [3, 4]
  return x * y
}) 

result // [3, 4, 6, 8]