Skip to content

Problem specialising higher-order functions #333

@mbenke

Description

@mbenke

The following example

forall abs rep . class abs:Typedef(rep) {
    function abs(x:rep) -> abs;
    function rep(x:abs) -> rep;
}

forall t.
/* default */ instance t:Typedef(t) {
    function abs(x:t) -> t { return x; }
    function rep(x:t) -> t { return x; }
}

forall abs rep res. abs:Typedef(rep) =>
function lift1ac(f:(rep) -> res, x:abs) -> res { f(Typedef.rep(x)) }


forall a. function id(x:a) -> a {x}
contract TD {
  function main() -> word { lift1ac(id, 42) }
}

fails with

Error: function lift1ac cannot be specialised because it has an ambiguous type:
   forall $v_1 rep res abs . $v_1 : invokable (rep, res), abs : Typedef (rep) => $v_1 -> abs -> res
 variables: [rep]
 do not occur in the argument/result types.

Metadata

Metadata

Assignees

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