Troubles with Haskell condition -
i'm beginner in haskell , have trouble in next block:
up_heap :: num => [a] -> [a] -> [a] up_heap heap (h:t) = let ppos = quot (length heap) 2 in case ((ppos > 0) && ((heap !! ppos) > h)) of true -> let (upper, (p:lower)) = splitat ppos heap in up_heap upper (h:lower) ++ (p:t) false -> heap ++ h:t next error: not deduce (ord a) arising use of `>'
how improve this?
you using > on element of heap of type num => a (the element). > part of ord typeclass , see in documentation (http://hackage.haskell.org/packages/archive/base/3.0.3.1/doc/html/ghc-num.html), type implementing num not implement ord.
class (eq a, show a) => num add constraint in type signature (num a, ord a) => ....
Comments
Post a Comment