현재 형식 클래스를 작성하는 방법을 배우고 있습니다. 난 모호한 발생의 컴파일 오류와 함께 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 /= GT
x < y = compare x y == LT
x >= y = compare x y /= LT
x > y = compare x y == GT
-- note that (min x y, max x y) = (x,y) or (y,x)
max x y
| x <= y = y
| otherwise = x
min x y
| x <= y = x
| otherwise = y
오류
Practice.hs:26:14:
Ambiguous occurrence `<='
It could refer to either `Practice.<=', defined at Practice.hs:5:10
or `Prelude.<=',
imported from `Prelude' at Practice.hs:1:8-15
...
등이다. 나는 그것이 Prelude 정의 버전과 충돌하고 있다고 생각한다.
의 맨 처음에 쓰기
활성화 할 수 있습니다 – user1850254