Skip to content

Instantly share code, notes, and snippets.

@expede
Last active September 3, 2016 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save expede/778e16658cd63c1ba0d4512b4e63edca to your computer and use it in GitHub Desktop.
Save expede/778e16658cd63c1ba0d4512b4e63edca to your computer and use it in GitHub Desktop.
OtherFile.read("./existing_file.txt")
~> fn text ->
text
|> String.length
|> fn x -> x / 2 end.()
end.()
|> to_tagged_status
#=> {:ok, 500}
# `ok` alias for tagged_status
OtherFile.read("./missing.file")
~> fn text ->
text
|> String.length
|> fn x -> x / 2 end.()
end.()
|> ok
#=> {:error, "File not found at ./missing.file"}
# Operator
~~~OtherFile.read("./missing.file")
#=> {:error, "File not found at ./missing.file"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment