[Haskell-cafe] Safe forward-mode AD in Haskell?
David Roundy
droundy at darcs.net
Tue May 8 20:59:48 EDT 2007
On Tue, May 08, 2007 at 06:06:56PM -0400, Björn Buckwalter wrote:
> We provide a type signature for 'd' where we existentially quantify
> the phantom type 's' to prevent mixing of bundles from different
> 'd' operators.
>
> >d :: Num a => (forall s. Bundle s a -> Bundle s a) -> a -> a
> >d f x = let (Bundle y y') = f (Bundle x 1) in y'
Couldn't you do the same without branding if you simply made your function
polymorphic:
data Bundle a = Bundle a a
d :: Num a => (forall b. Num b => b -> b) -> a -> a
d f x = let (Bundle y y') = f (Bundle x 1) in y'
and defined
lift x = Bundle x 0
?
You obviously need an existential type, but I don't see that you need any
branding.
--
David Roundy
Department of Physics
Oregon State University
More information about the Haskell-Cafe
mailing list