我试图弄清楚为什么它不能编译
yell :: (Floating a) => a -> [Char]
yell x
| x > 10.0 = "Yelling"
| otherwise = "No Yell"
Run Code Online (Sandbox Code Playgroud)
但是这个
yell :: (Floating a, Ord a) => a -> [Char]
yell x
| x > 10.0 = "Yelling"
| otherwise = "No Yell"
Run Code Online (Sandbox Code Playgroud)
和这个
yell :: (RealFloat a) => a -> [Char]
yell x
| x > 10.0 = "Yelling"
| otherwise = "No Yell"
Run Code Online (Sandbox Code Playgroud)
做编译。
我知道Floating和Ord是类型类,但不是Floating的每个成员也是Ord的成员吗?最后,RealFloat只是Floating和Ord的“内部联接”吗?