
Am 12/09/2015 um 01:03 AM schrieb Francesco Ariis:
On Tue, Dec 08, 2015 at 11:29:22PM +0100, martin wrote:
Hello all,
with this code
[...]
The commented line -- < -- does not work, though I am just replacing equals with equals. I get
No instance for (Ord b0) arising from a use of ‘compare’
Try to erase the `build` function and see what happens; You will get the same error. GHC complains that there is no good `Ord` instance and this can be solved by adding an appropriate type signature:
tcmp :: (Ord a) => Tree a -> Tree a -> Ordering
Now, with the `build` function present (the one with `let xs = sortBy tcmp t`), GHC will infer `tcmp` signature, as t is an Int
λ> :t tcmp tcmp :: Tree Int -> Tree Int -> Ordering
as since Int is an instance of Ord everything is fine. Does that help?
Oh, I see. I was assuming the message referred to the build function (because I made chages there) and not to tcmp. Didn't check the line number. But really tcmp has lost its roots by not being used in build anymore.