
4 Jan
2016
4 Jan
'16
9:57 a.m.
Hello all, Data.List.Ordered is just a bunch of functions operating on ordinary Lists. Fmapping a function over an ordered list has the potential of blowing the ordering. Would it be possible to define a newtype for ordered lists where the order is guaranteed to be maintained? The functor instance then may have to re-order the elements. The problem I see is that data Ordlist a = ... would certainly require an Ord constraint on a, but where would I put it? I can put it on all the functions manipulating OrdLists, but I still wouldn't know how to define a functor instance, because a Functor a does not require Ord a.