I think what Martin is aiming at is heterogeneous collections.  http://www.haskell.org/haskellwiki/Heterogenous_collections

As you can see from the article, you can do "the same thing" to a bunch of objects of different types, but you've still got to "pack" them explicitly first.  So in this particular case the answer is that it's not worth the effort.  This may seem ridiculous, but it turns out that Haskell's approach gives you a lot of power in other areas.

Julian


On 17 August 2014 13:57, Francesco Ariis <fa-ml@ariis.it> wrote:
On Sun, Aug 17, 2014 at 12:08:57PM +0100, Karolis Velicka wrote:
> In that case, can you elaborate please? I don't see how this is different
> to making the record itself an instance if Show.

If by "no difference" you mean "equivalent output", I guess we can ditch
Haskell and write programs in Basic.

What Martin is asking for is how you could implement such a feature if
something like |deriving (Show)| weren't there.

On 17 Aug 2014 10:44, "martin" <martin.drautzburg@web.de> wrote:
> Right, but this is merely a coincidence.
>
> What I wanted is a way to show a value of a record, where all fields are
> instances of Show.
>
> Haskell itself is able to do this (and it even figures out the accessors,
> which I am not even asking for).

Martin, as far as I know this is not possible in standard ^Haskell 2010^ [1].
To perform this kind of magic people use ^Template Haskell^ [2], which is,
in so many words, a meta programming extension for GHC; with it you can
handle and go-back-and-forth between Concrete Syntax and the Abstract Syntax
Tree.
Template Haskell isn't type safe and that goes "against the grain" of
Haskell-the-language itself, I suppose (for sure it goes against mine);
it is used in some popular libraries (e.g. lens, yesod).


[1] http://www.haskell.org/onlinereport/haskell2010/
[2] http://www.haskell.org/haskellwiki/Template_Haskell

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners