Skip to content

behaviour won't work on a module transformed by pmod_pt #2

@tatsuya6502

Description

@tatsuya6502

Related to: rabbitmq/erlando#12 (comment)

It seems a module can't have both -behaviour(..) and -compile({parse_transform, pmod_pt}) at the same time. I think the reason is behaviour tries to validate callback functions after pmot_pt is applied(?)

state_t.erl

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

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

monad.erl

behaviour_info(callbacks) ->
    [{'>>=',  2},
     {return, 1},
     {fail,   1}];

state_t module doesn't compile:

src/state_t.erl:21: undefined callback function '>>='/2 (behaviour 'monad')
src/state_t.erl:21: undefined callback function fail/1 (behaviour 'monad')
src/state_t.erl:21: undefined callback function return/1 (behaviour 'monad')

If I remove -behaviour(monad), it compiles. Note that each function has an extra parameter (e.g. '>>='/3, not '>>='/2)

Erlang R16B (erts-5.10.1) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.1  (abort with ^G)
...
3> state_t:module_info().
[{exports,[{'>>=',3},
           {return,2},
           {fail,2},
           {get,1},
           {put,2},
           {eval,3},
           {exec,3},
           {run,3},
           {modify,2},
           {modify_and_return,2},
           {lift,2},
           {new,1},
           {instance,1},
           {module_info,0},
           {module_info,1}]},

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions