ekmett / ad

Automatic Differentiation
http://hackage.haskell.org/package/ad
BSD 3-Clause "New" or "Revised" License
368 stars 73 forks source link

weird stuff with partial function application to lists? #66

Closed donovancrichton closed 7 years ago

donovancrichton commented 7 years ago

Hi, I'm new to Haskell, but I've asked around on some of the freenode communities and nobody there can help me. This may not be a bug, but simply my inexperience.

f :: [a] -> a f = [u, v] -> (v - (u u u))

grad f [1, 1] works just fine in GHCI

map (\x -> grad x) [f] gives the following error: Couldn't match type ‘Integer’ with ‘Numeric.AD.Internal.Reverse.Reverse s a’ Expected type: [Numeric.AD.Internal.Reverse.Reverse s a] -> Numeric.AD.Internal.Reverse.Reverse s a Actual type: [Integer] -> Integer • In the first argument of ‘grad’, namely ‘f’ In the expression: grad f In the first argument of ‘map’, namely ‘(\ f -> grad f)’ • Relevant bindings include it :: [[a] -> [a]] (bound at :6:1)

I've tried many different ways of partially applying grad to a list of functions but cannot get it to typecheck.

donovancrichton commented 7 years ago

I'm an idiot.