|Subject:||Re: [Haskell-cafe] Design question|
|Date:||Thu, 17 Dec 2009 12:44:12 +0100 CET|
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
To bother you with some details: i am building a model for an SVG document.
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 sub-elements 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 type-directed 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
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
|<Prev in Thread]||Current Thread||[Next in Thread>|
|Previous by Date:||Re: [Haskell-cafe] ANN: Hemkay, the 100% Haskell MOD player, Patai Gergely|
|Next by Date:||[Haskell-cafe] Re: parallel and distributed haskell?, Simon Marlow|
|Previous by Thread:||Re: [Haskell-cafe] Design question, Luke Palmer|
|Next by Thread:||Re: [Haskell-cafe] Design question, minh thu|
|Indexes:||[Date] [Thread] [Top] [All Lists]|