-
-
Save danielberkompas/52216db76d764a68dfa3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Pipeline do | |
defmacro __using__(_) do | |
quote do | |
import Kernel, except: [~>>: 2] | |
import Pipeline | |
end | |
end | |
defmacro lhs ~>> rhs do | |
quote do | |
case unquote(lhs) do | |
{:ok, value} -> value |> unquote(rhs) | |
other -> other | |
end | |
end | |
end | |
end |
Yeah. It isn't really necessary, though.
https://github.com/CrowdHailer/OK
Though a bit more work is needed to make it work with named function properly
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why have you imported kernal and excepted ~>>. Is that just good form in case ~>> arrives in kernal in the future