Skip to content

Commit

Permalink
Make use of pmod_pt parse_transform
Browse files Browse the repository at this point in the history
In order to use it, the monad transformers have new behaviour:
monad_t. That's beause the transform alters the arity of exported
functions and they are no longer the same as those of monad.
  • Loading branch information
BartAdv committed Jun 15, 2014
1 parent e3f115b commit ebd1de6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions rebar.config
@@ -1,3 +1,4 @@
%% -*- erlang -*-
{erl_opts, [debug_info, warnings_as_errors]}.
{cover_enabled, true}.
{deps, [{pmod_transform, ".*", {git, "git://github.com/erlang/pmod_transform.git", "master"}}]}.
3 changes: 2 additions & 1 deletion src/error_t.erl
Expand Up @@ -14,10 +14,11 @@
%% Copyright (c) 2011-2013 VMware, Inc. All rights reserved.
%%

-compile({parse_transform, pmod_pt}).
-module(error_t, [InnerMonad]).
-compile({parse_transform, do}).

-behaviour(monad).
-behaviour(monad_t).
-export(['>>='/2, return/1, fail/1, run/1, lift/1]).

-ifdef(use_specs).
Expand Down
10 changes: 10 additions & 0 deletions src/monad_t.erl
@@ -0,0 +1,10 @@
-module(monad_t).

-export([behaviour_info/1]).

behaviour_info(callbacks) ->
[{'>>=', 3},
{return, 2},
{fail, 2}];
behaviour_info(_Other) ->
undefined.
3 changes: 2 additions & 1 deletion src/state_t.erl
Expand Up @@ -14,10 +14,11 @@
%% Copyright (c) 2011-2013 VMware, Inc. All rights reserved.
%%

-compile({parse_transform, pmod_pt}).
-module(state_t, [InnerMonad]).
-compile({parse_transform, do}).

-behaviour(monad).
-behaviour(monad_t).
-export(['>>='/2, return/1, fail/1]).
-export([get/0, put/1, eval/2, exec/2, run/2,
modify/1, modify_and_return/1, lift/1]).
Expand Down

0 comments on commit ebd1de6

Please sign in to comment.