symbolic evaluator for Haskell?

Is there a symbolic evaluator for Haskell that will perform all applications except on specified functions? Ie. I would love something that would take foldr (+) (6 `div` 5) [1,2,3*4] and "(+) (*)" and return 1 + (2 + (3*4 + 1)) by performing all the applications except for (+) and (*). (Something that supports ghc extensions is preferred :) Tim Newsham http://www.thenewsh.com/~newsham/

Coq (coq.inria.fr) can do that, and its language has a resemblance to
Haskell. However, by dealing with Coq, you are heavily risking your
brain, so beware.
2009/3/18 Tim Newsham
Is there a symbolic evaluator for Haskell that will perform all applications except on specified functions? Ie. I would love something that would take
foldr (+) (6 `div` 5) [1,2,3*4]
and "(+) (*)" and return
1 + (2 + (3*4 + 1))
by performing all the applications except for (+) and (*). (Something that supports ghc extensions is preferred :)
Tim Newsham http://www.thenewsh.com/~newsham/ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Eugene Kirpichov Web IR developer, market.yandex.ru

Tim Newsham wrote:
Is there a symbolic evaluator for Haskell that will perform all applications except on specified functions? Ie. I would love something that would take
foldr (+) (6 `div` 5) [1,2,3*4]
and "(+) (*)" and return
1 + (2 + (3*4 + 1))
by performing all the applications except for (+) and (*). (Something that supports ghc extensions is preferred :)
Lambdabot (on #haskell) has something similar using a type, Expr, to overload certain names, e.g. koninkje > foldr f z [1..5] lambdabot f 1 (f 2 (f 3 (f 4 (f 5 z)))) It's a complete hack and isn't as sophisticated as what you're after, but it could serve as a basis for implementation ideas. -- Live well, ~wren

On Mar 18, 2009, at 1:40 AM, wren ng thornton wrote:
Lambdabot (on #haskell) has something similar using a type, Expr, to overload certain names, e.g.
koninkje > foldr f z [1..5] lambdabot f 1 (f 2 (f 3 (f 4 (f 5 z))))
It's a complete hack and isn't as sophisticated as what you're after, but it could serve as a basis for implementation ideas.
This is, I believe, essentially the simple-reflect package on Hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/simple- reflect At least two of lennart's libraries provide related functionality: Traced: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/ traced and Data.Number.Symbolic in numbers: http://hackage.haskell.org/cgi- bin/hackage-scripts/package/numbers Cheers, S.

Lambdabot (on #haskell) has something similar using a type, Expr, to overload certain names, e.g.
koninkje > foldr f z [1..5] lambdabot f 1 (f 2 (f 3 (f 4 (f 5 z))))
It's a complete hack and isn't as sophisticated as what you're after, but it could serve as a basis for implementation ideas.
I'm aware of the Expr stuff in lambdabot and elsewhere. This is not quite what I need, perhaps I should have picked an example that doesn't almost-work with Expr. I need something that will symbolically evaluate a complex non-numeric expression that makes use of GADTs. I'm thinking it might not be too hard to implement using TH, but haven't tried yet... (though not sure if TH supports GADTs).
Live well, ~wren
Tim Newsham http://www.thenewsh.com/~newsham/
participants (4)
-
Eugene Kirpichov
-
Sterling Clover
-
Tim Newsham
-
wren ng thornton