Generalize diffMU to diffFU? #1

bjornbm opened this Issue May 16, 2010 · 0 comments


None yet
1 participant

bjornbm commented May 16, 2010

[From email 2008-02-28]

But, consider changing the interface of e.g. 'diffMU' to:

diffMU :: Num a => (forall tag. [Dual tag a] -> Dual tag b) -> [(a, a)] -> b
diffMU f = tangent . f . map pair2dual

I.e. instead of taking two lists take a single list of pairs (which
has the added benefit that it becomes impossible to pass lists of
different length by mistake). Now, the above trivially generalizes to:

diffFU :: (Num a, Functor f) => (forall tag. f (Dual tag a) ->
Dual tag b) -> f (a, a) -> b
diffFU f = tangent . f . fmap pair2dual

The others variations should be equally straight forward. If you want
to still provide the original interface for 'diffMU' the definition
would be:

diffMU f xs x's = diffFU f (zip xs x's)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment