
On Sat, Jan 20, 2018 at 09:20:33PM +0100, Patrik Iselind wrote:
It's the very last exercise on the page concerning constructing a Convex Hull. I have no problem implementing a Graham Scan in non-functional languages as i have far more experience with those. But the book hasn't yet covered how i make my own data belong to for example the Data.Ord class. The question then for me is how am i supposed to sort my coordinates?
Type classes are not covered for another three chapters in the book. Given this it seems to me that i should be able to solve this without using Data.Ord, i just cannot see how. Any pointers would be highly appreciated.
Hello Patrik, as you suggested, implementing an instance of Data.Ord would be ok; if you don't want that, just write a myTypeCompare :: SomeData -> SomeData -> Ordering function to use with `sortBy` from `Data.List`. Does that make sense? -F