[Haskell-beginners] Functor instance for ordered lists

Marcin Mrotek marcin.jan.mrotek at gmail.com
Mon Jan 4 16:33:10 UTC 2016


> 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.

It's of questionable utility, as it still doesn't let you define a
Functor instance (and can no longer be a newtype), but if you want,
you can use a GADT:

data OrdList a where
   OrdList :: Ord a => a -> OrdList a

Best regards
Marcin Mrotek


More information about the Beginners mailing list