Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Do" notation #19

Closed
expede opened this issue Feb 15, 2016 · 3 comments
Closed

"Do" notation #19

expede opened this issue Feb 15, 2016 · 3 comments
Assignees

Comments

@expede
Copy link
Member

expede commented Feb 15, 2016

monad [] do
  a <- [1,2,3]
  b <- [4,5,6]
  return(a + b)
end
#=> [5, 6, 7, 6, 7, 8, 7, 8, 9]
@expede expede self-assigned this Feb 15, 2016
@expede
Copy link
Member Author

expede commented Mar 15, 2016

It's becoming increasingly clear that this would be a good feature to have

@expede
Copy link
Member Author

expede commented May 28, 2016

May want to use something like the Scala style

for {
  a <- foo
  b <- bar
  c <- baz
} yield a + b + c

@expede
Copy link
Member Author

expede commented Apr 30, 2017

https://github.com/expede/witchcraft/blob/master/lib/witchcraft/monad.ex#L19-L26

 @doc ~S"""
      monad [] do
        a <- [1,2,3]
        b <- [4,5,6]
        return(a + b)
      end
      #=> [5, 6, 7, 6, 7, 8, 7, 8, 9]
"""

# and


 @doc ~S"""
      monad do
        a <- [1,2,3]
        b <- [4,5,6]
        pure([], a + b)
      end
      #=> [5, 6, 7, 6, 7, 8, 7, 8, 9]
  """

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant