Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize diffMU to diffFU? #1

Open
bjornbm opened this issue May 16, 2010 · 0 comments
Open

Generalize diffMU to diffFU? #1

bjornbm opened this issue May 16, 2010 · 0 comments

Comments

@bjornbm
Copy link
Owner

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant