#12: implement functors
-------------------------+--------------------------------------------------
Reporter: erickt | Owner:
Type: enhancement | Status: new
Priority: major | Milestone:
Component: type system | Version:
Keywords: |
-------------------------+--------------------------------------------------
We've got a keyword for functors, but we don't actually support them yet.
One way to do it without needing the "functor" keyword would be to
implement functors as arguments to a module, like this:
{{{
module Foo (x:module_interface) {
typedef t = x.t;
...
}
}}}
from skaller:
Good idea. What's an interface? Hmm .. how about a typeclass?
{{{
module Foo[t with Eq[t]] { f(x:t) .... }
}}}
Implementation ..
{{{
f[t with Eq[t]] (x:t) ..
}}}
Oh wait .. that should work right now! Or close to it.
Hmm.. or:
{{{
module Foo (X) { typedef t = X::t; }
}}}
Something I've been thinking of is 'typesafe' macros aka templates.
They're just C++ templates, that is, they bind to the
context of use.
We do sort of have this with 'reduce .. ' but only
for expressions. There's no 'reduce' for statements.
--
Ticket URL: <http://code.felix-lang.org/ticket/12>
felix <http://code.felix-lang.org>
The advanced scripting language