Subject:  Re: [Haskellcafe] Design question 

From:  "" 
Date:  Thu, 17 Dec 2009 12:44:12 +0100 CET 
Hi all, thanks for your ideas so far. > I think you might be looking for too much sugar. I don't know much > about your problem, but I would use approximately your approach and be > straightforward: To bother you with some details: i am building a model for an SVG document. http://chlor.svn.sourceforge.net/viewvc/chlor/trunk/haskell/Chlor/FileFormat/Svg/SvgDocument.hs There are many SVG elements, of which only a few are valid as the content of each other SVG elements. SvgDocumentElement defines the allowed subset for the SVG document. I want to generate a "DList Char" for all those subelements and finally collapse them to one "DList Char" representing the whole SVG document. So it's a bit more complicated than your "Either" example I need to manually efine such subset data structures for most SVG elements which does not feel most elegant already. Additionally instantiating a class for the subset structures, in order to being able to iterate over them, feels even more clumsy. So i wonder whether i am missing a more clean approach to the problem "easily combining data structures but also easy iteration over them". > > type SubSet = Either A C > > > and use it in Foo: > > > > data Foo = Foo [SubSet] > > > > No i want to perform a polymorphic operation on the contents of A,B,C, e.g. > > > > doSomething :: Foo > [Double] > > doSomething (Foo s) = map doSomethingElse s > > doSomething (Foo s) = map (doSomethingWithA  doSomethingWithC) s > > ( is from Control.Arrow) > > If that gets too complicated, you can build the "doSomething" > functions in a typedirected way using typeclasses: > > class DoSomething a where > doSomething :: a > Double > > instance DoSomething A where ... > instance DoSomething B where ... > instance DoSomething C where ... > > instance (DoSomething a, DoSomething b) => DoSomething (Either a b) where > doSomething = doSomething  doSomething > > Luke _______________________________________________ HaskellCafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskellcafe 
<Prev in Thread]  Current Thread  [Next in Thread> 


Previous by Date:  Re: [Haskellcafe] ANN: Hemkay, the 100% Haskell MOD player, Patai Gergely 

Next by Date:  [Haskellcafe] Re: parallel and distributed haskell?, Simon Marlow 
Previous by Thread:  Re: [Haskellcafe] Design question, Luke Palmer 
Next by Thread:  Re: [Haskellcafe] Design question, minh thu 
Indexes:  [Date] [Thread] [Top] [All Lists] 