在Learn You a Haskell中有一个示例Enum
类型:
data Day = Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday
deriving (Eq, Ord, Show, Read, Bounded, Enum)
但是当我尝试Day
使用没有空格边界值构造函数的范围语法获取 s 列表时,我收到以下错误:
ghci> [Thursday..Sunday]
<interactive>:30:2:
Failed to load interface for `Thursday'
Use -v to see a list of the files searched for.
<interactive>:30:2:
A section must be enclosed in parentheses thus: (Thursday.. Sunday)
当我使用空格时,一切正常:
ghci> [Thursday .. Sunday]
[Thursday,Friday,Saturday,Sunday]
这种行为的原因是什么(例如Int
s 的范围不需要空格)?