相关疑难解决方法(0)

模棱两可的事件

我目前正在学习如何编写类型类.我似乎无法编写具有模糊发生的编译错误的Ord类型类.

module Practice where

class  (Eq a) => Ord a  where
    compare              :: a -> a -> Ordering
    (<), (<=), (>=), (>) :: a -> a -> Bool
    max, min             :: a -> a -> a

    -- Minimal complete definition:
    --      (<=) or compare
    -- Using compare can be more efficient for complex types.
    compare x y
         | x == y    =  EQ
         | x <= y    =  LT
         | otherwise =  GT

    x <= y           =  compare x y …
Run Code Online (Sandbox Code Playgroud)

haskell typeclass

11
推荐指数
2
解决办法
1万
查看次数

标签 统计

haskell ×1

typeclass ×1