Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Generalize diffMU to diffFU? #1

Open
bjornbm opened this Issue · 0 comments

1 participant

@bjornbm
Owner

[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
Something went wrong with that request. Please try again.