<< Back to previous view

[ALGOG-2] dispatch for fmap multimethod shouldn't be on type of second argument Created: 22/May/13  Updated: 05/Feb/14  Resolved: 05/Feb/14

Status: Closed
Project: algo.generic
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Minor
Reporter: ben wolfson Assignee: Konrad Hinsen
Resolution: Completed Votes: 0
Labels: None


AFAICT having fmap dispatch on the type of the second argument makes it practically impossible to define fmap for arbitrary functions, since the type is different for each function:

user> (type type)
user> (type fn?)
user> (type not=)

However, there's a perfectly reasonable definition of fmap for functions (fmap = comp).

To my mind the simplest/best thing to do is just have a Functor protocol and have fmap call a function in it, with the order of arguments reversed so that dispatch will happen correctly.

Comment by Konrad Hinsen [ 05/Feb/14 10:16 AM ]

I added an fmap implementation for the IFn interface, which covers all functions:

Changing fmap to a protocol-based implementation would break all existing code that adds fmap implementations.

Generated at Fri Oct 09 07:17:50 CDT 2015 using JIRA 4.4#649-r158309.