Skip to content

Instantly share code, notes, and snippets.

defmodule Counter do
use GenServer
def increment() do
GenServer.cast(__MODULE__, :increment)
end
def decrement() do
GenServer.cast(__MODULE__, :decrement)
end
defmodule ShuffleCards do
def suits() do
[:hearts, :spades, :clubs, :diamonds]
end
def cards do
[:ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, :jack, :queen, :king]
end
def shuffle() do
@zkessin
zkessin / loop.erl
Last active February 14, 2019 15:06
Charlie on the MTA in Elixir
-module(loop).
% If you are not from greater Boston watch this video of the Song "Charlie on the MTA" by the Kingston Trio
% And this will make more sense https://www.youtube.com/watch?v=MbtkL5_f6-4
-export([charlie/1, init/0, run/0]).
-type line() :: 'red'|'green_e'|'blue'|'orange'.
-type station() :: 'kendal'|'charles/mgh'|'park_st'|'government_center'|'heath'.
defmodule ReconTest do
use ExUnit.Case, async: true
test "FAKE" do
ReconTrace.calls(
{module, function, 3},
10,
[
{:io_server, self()},
{:formatter,

Test and Type Driven Development In Elm

Zachary Kessin

Length: about 30 minutes

If you are coming to Elm from JavaScript or other weekly types languages you are probably used to doing Test Driven Development but Elm is a strongly typed language with a rich type system. In Elm it is often possible to use the compiler to do Type Driven Development where our invariants are created by creatively using

w
506 es_address_book -> !!
make eqcshell
===> Verifying dependencies...
===> Skipping es_types (from {git,"git@gitlab.eco.kobil.com:ecoservers/es_types.git",
{branch,"master"}}) as an app of the same name has already been fetched
===> Skipping jsx (from {git,"git@gitlab.eco.kobil.com:ecoservers/erl_jsx.git",
{tag,"ecoservers"}}) as an app of the same name has already been fetched
===> Skipping lager (from {git,"git@gitlab.eco.kobil.com:ecoservers/erl_lager.git",
{tag,"ecoservers-v2"}}) as an app of the same name has already been fetched
{[{model,es_abs_flow_eqc},{init,{state,[]}}],
[[{set,{var,1},
{call,es_abs_flow_eqc,create_user,
[#{<<"ecoId">> => <<"fe72b199-d1b4-40db-b1b7-53f2c3812ae7">>,
<<"userId">> => <<"872659c7-f0b2-4c9c-b1d0-af0a89354def">>},
#{<<"userType">> => <<"person">>}]}},
{set,{var,2},
{call,es_abs_flow_eqc,get_user,
[#{<<"ecoId">> => <<"362e2c55-e597-4b76-bdbc-19284ee2761f">>,
<<"userId">> =>
-module(wm_elm).
-compile(export_all).
%-compile({parse_transform, ct_expand}).
%-pt_pp_src(false).
-include_lib("webmachine/include/webmachine.hrl").
-include("squaretarget.hrl").
-spec(routes() ->[webmachine_dispatcher:route()]).
-type rd() :: wrq:reqdata().
lt() ->
error_logger:tty(false),
lager:error("~n********************************************************************************~n~n~n~n",[]),
ok = lager:set_loglevel(lager_console_backend, error),
eqc:check(barrel_rpc_events_eqc:prop_barrel_rpc_events_eqc(), eqc:counterexample()),
ok = lager:set_loglevel(lager_console_backend, info),
ok.
-module(fake).
non_duplicate_random(Gen,Len) ->
?SHUFFLE(non_duplicate(Gen,Len)).
non_duplicate(Gen, Len) ->
?LET(A,