On Tue, 4 Sep 2007, Peter Verswyvelen wrote: > Henning Thielemann wrote: > > Why not just > > FancySequence.fromList [1,2,3,4] > > or > > FancySequence.fromList $ 1:2:3:4:[] > > ? > Yes of course, but the same could be said for numbers, e.g when you need > an Int, you have to type (Int.fromNumber 1), (Float.fromNumber 1), > (Double.fromNumber 1), etc... I don't like that because it makes writing > numeric type independent generic code impossibe, so luckily the Haskell > compiler automatically inserts fromInteger or fromRational calls to lift > a generic number into a specific representation. But it does not provide > the same for lists, e.g. there is no fromList function which is a member > of some List typeclass that the compiler automatically uses just like it > does for numbers. I think this is a bit of a discrepancy.
If you are happy with writing "do {1;2;3;4}" you are certainly also happy with "cv [1,2,3,4]", where cv means 'convert' and is a method of a class for converting between lists and another sequence type. class ListCompatible lc where cv :: [a] -> lc a rt :: lc a -> [a] {- restore :-) -} Better don't adapt the names, but the idea would work, wouldn't it? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe