Home > Software engineering >  Comparison without deriving Ord
Comparison without deriving Ord

Time:09-30

My prof asked us to implement bubble sort in Haskell. The problem should be easy, however, he specified the function signature like this

bsort :: (a -> a -> Bool) -> [a] -> [a]
bsort = undefined

The problem is that a is not deriving Ord, so I have no idea how to compare as. So I wonder if this is doable or he forgot to add (Ord a) =>?

CodePudding user response:

Yes, it is doable, no he did not forget. Here's a hint:

bsort (<=) = undefined
  • Related