On 29 September 2011 07:56, Roman Leshchinskiy <[email protected]> wrote: > On 25/09/2011, at 18:20, Chris Smith wrote: > >> class Ord a => Range a where >> rangeFromTo :: a -> a -> [a] -- subsumes Ix.range / Enum.enumFromTo >> rangeFromThenTo :: a -> a -> a -> [a] >> inRange :: (a, a) -> a -> Bool >> -- Does have instances for Float/Double. List ranges desugar to this. >> -- Also has instances for tuples >> >> class Range a => InfiniteRange a where -- [1] >> rangeFrom :: a -> [a] >> rangeFromThen :: a -> a -> [a] >> -- Has instances for Float/Double >> -- No instances for tuples > > I realise I'm slightly late to the discussion but IMO, the rangeFrom* (or > enumFrom*) functions shouldn't be methods. Rather, a redesign of Enum should > ensure that they can be defined generically for all types. The rationale is > that other data structures (like arrays) want to provide similar functions > without having to go through lists.
Wouldn't this require something like the ListLike class? -- Ivan Lazar Miljenovic [email protected] IvanMiljenovic.wordpress.com _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
