Re: [Haskell] Type Lambdas in Gofer

2007-07-31 Thread Stefan O'Rear
On Wed, Aug 01, 2007 at 07:57:48AM +0200, Wolfgang Lux wrote: > Jim Apple wrote: > >> data Rec f = In (f (Rec f)) >> type P f a = f (Rec f, a) >> >> mapP :: Functor f => (a -> b) -> P f a -> P f b >> mapP g = fmap (\(x,a) -> (x, g a)) >> >> instance Functor f => Functor (P f) where >> fmap = ma

Re: [Haskell] Type Lambdas in Gofer

2007-07-31 Thread Wolfgang Lux
Jim Apple wrote: data Rec f = In (f (Rec f)) type P f a = f (Rec f, a) mapP :: Functor f => (a -> b) -> P f a -> P f b mapP g = fmap (\(x,a) -> (x, g a)) instance Functor f => Functor (P f) where fmap = mapP Why did Gofer have this power while Haskell does not? Haskell does have the sam

[Haskell] Type Lambdas in Gofer

2007-07-31 Thread Jim Apple
The code in "Bananas in Space: Extending Fold and Unfold to Exponential Types" http://citeseer.ist.psu.edu/293490.html mirror: http://www.cs.nott.ac.uk/~gmh/bananas.pdf uses Gofer, and has examples such as data Rec f = In (f (Rec f)) type P f a = f (Rec f, a) mapP :: Functor f => (a -> b) -> P

Re: [Haskell] Re: type class instance selection & search

2007-07-31 Thread jeff p
Hello, > > My understanding is that this sort of instance collection doesn't work > together because instance selection is based only on the matching the head > of an instance declaration (part after the "=>"). I'm wondering why not use > the preconditions as well, via a Prolog-like, backward-cha

Re: [Haskell] Re: type class instance selection & search

2007-07-31 Thread Conal Elliott
Thanks for these pointers, Ken. And belated thanks to Oleg for his reply in June. Impressive tricks! Perhaps I'm not the only person who'd prefer a more straightforward formulation of backtracking search? Cheers, - Conal On 7/31/07, Chung-chieh Shan <[EMAIL PROTECTED]> wrote: > > Conal Elli

[Haskell] Re: type class instance selection & search

2007-07-31 Thread Conal Elliott
Here are some other instances that could work with backward chaining: \begin{code} instance Monad m => Applicative m where pure = return (<*>) = ap instance (Applicative f, Monoid a) => Monoid (f a) where mempty = pure mempty mappend = liftA2 mappend instance (Applicative f, Num a)

[Haskell] Re: type class instance selection & search

2007-07-31 Thread Chung-chieh Shan
Conal Elliott <[EMAIL PROTECTED]> wrote in article <[EMAIL PROTECTED]> in gmane.comp.lang.haskell.general: > I keep running into situations in which I want more powerful search in > selecting type class instances. I agree that it's quite useful for instance search to backtrack, if not desirable i

[Haskell] type class instance selection & search

2007-07-31 Thread Conal Elliott
I keep running into situations in which I want more powerful search in selecting type class instances. One example I raised in June, in which all of the following instances are useful. > instance (Functor g, Functor f) => Functor (O g f) where > fmap h (O gf) = O (fmap (fmap h) gf) > instance

[Haskell] 3-yr post for language person

2007-07-31 Thread Simon Peyton-Jones
Tim Griffin is advertising a 3-year research associate position at the Cambridge Computer Lab, working on a project that seeks to design and implement a meta-language for the specification and implementation of correct Internet routing protocols. He says "A PL person would be perfect". Details