
8 Dec
2015
8 Dec
'15
7:03 p.m.
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?