Nice catch! Indeed it errors out ...
> take 10 [P, P..]
<interactive>:6:16: parse error on input ‘]’
... but this does not
> take 10 [P, P ..] -- one more space
[P,P,P,P,P,P,P,P,P,P]
Why the whitespace is significant? Because otherwise the syntax overlaps with module-prefixed names, which have the form Module.name
. Here's how the operator .
from Prelude
is accessed, for instance.
> :t (Prelude..)
(Prelude..) :: (b -> c) -> (a -> b) -> a -> c
> :t succ Prelude.. succ -- infix use!
succ Prelude.. succ :: Enum c => c -> c
Hence, P..
is .
from module P
, while P ..
works fine in a list enumeration.
(Yes, this is an unfortunate quirk of the syntax ...)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…