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

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -