Thank you for all these answers - I learned a lot (especially that the 
responses come in REALLY quickly, so the digest option is not a good choice).  

I think I need to  rephrase the problem, taking into account what I have 
learned.  

class (Functor f, Functor g) => Foo f g where
  foo :: f a -> g a

as per John Meacham's suggestion to isolate the transform.  Really, f and g are 
'containers' which I want to reshape (and there can be many different 
re-shapings of g for each f, and different f's can map to the same g, so no 
fundeps relation holds in general).  I am trying to use classes as an interface 
description, with this transformation being part of that interface, and also to 
allow me to experiment with different constraints (e.g. Monad f, Applicative f, 
etc).

Edward Kmett points out (thank you for that detailed reply!) that there is no 
canonical foo -- which is a good point, and is indeed the right model --  
"natural transformation" was likely a red herring.  What I am trying to do is 
take a container of data f, and partition it into a structure g as a 'chunking' 
of that data.  The f container is a potentially infinite stream of data 
obtained from a generator, and I want to be able to control how much data is 
extracted, so an eager 'fmap' won't be sufficient (an eager process will be 
applied to the 'chunks' defined by g).   

I am going to purse the hylomorphism model, but am interested if anyone else 
has any similar situations, and if using classes to manage the interface is the 
right strategy.  

Thanks!


Gordon J. Uszkay
uszka...@mcmaster.ca



_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to