Created
June 2, 2012 10:44
-
-
Save yrashk/2857762 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
iex> Monad.identity do | |
...> IO.puts 1 | |
...> {:ok, a} = {:ok, 2} | |
...> IO.puts a | |
...> end | |
1 | |
2 | |
:ok | |
iex> Monad.error do | |
...> IO.puts "reading file..." | |
...> {:ok, bin} = :file.read_file("/etc/passwd") | |
...> IO.puts bin | |
...> end | |
reading file... | |
## | |
# User Database | |
# | |
# Note that this file is consulted directly only when the system is running | |
# in single-user mode. At other times this information is provided by | |
# Open Directory. | |
# | |
# See the opendirectoryd(8) man page for additional information about | |
# Open Directory. | |
## | |
nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false | |
root:*:0:0:System Administrator:/var/root:/bin/sh | |
daemon:*:1:1:System Services:/var/root:/usr/bin/false | |
######## ... SKIPPED... ######### | |
:ok | |
iex> Monad.error do | |
...> IO.puts "reading file..." | |
...> {:ok, bin} = :file.read_file("/etc/passwd_wrong") | |
...> IO.puts bin | |
...> end | |
reading file... | |
{:error,:enoent} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment