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
defmodule BaseApp do | |
def new_conn do | |
%{} | |
|> put_status(:ok) | |
end | |
def render(%{status: status} = conn) do | |
IO.puts "Status: #{status}" | |
conn | |
end |
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
defmodule BaseApp do | |
def new_conn do | |
%{status: 200} | |
end | |
def render(%{status: status} = conn) do | |
IO.puts "Status: #{status}" | |
conn | |
end |
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
@statuses [ | |
ok: 200, | |
bad_request: 400, | |
not_found: 404 | |
] | |
def put_status(conn, status) when is_atom(status) do | |
put_status(conn, @statuses[status]) | |
end |
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
@statuses [ | |
ok: 200, | |
bad_request: 400, | |
not_found: 404 | |
] | |
def put_status(conn, status) when is_atom(status) and not is_nil(status) do | |
put_status(conn, @statuses[status]) | |
end |
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
def put_status(conn, :ok) do | |
put_status(conn, 200) | |
end | |
def put_status(conn, :bad_request) do | |
put_status(conn, 400) | |
end | |
def put_status(conn, :not_found) do | |
put_status(conn, 404) |
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
statuses = [ | |
ok: 200, | |
bad_request: 400, | |
not_found: 404 | |
] | |
for {status, status_code} <- statuses do | |
def put_status(conn, unquote(status)) do | |
put_status(conn, unquote(status_code)) | |
end |
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
name = "andrew" | |
last_name = "krasnobaev" | |
long_full_name = "#{name} #{last_name}" |
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
hello | |
world |
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
var fp = require("./fp") | |
var foldl = fp.foldl | |
var keys = fp.keys | |
var curry = fp.curry | |
var pipe = fp.pipe | |
var log = fp.log | |
var join = fp.join | |
var map = fp.map |
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
f a b = | |
let | |
c = 10 | |
in | |
a + b + c |