I'm learning Haskell from a popular book .
It includes the following ghci command :
ghci> Just ord <*> Nothing
Nothing
When I run this in ghci I get:
<interactive>:1:6: error:
• Variable not in scope: ord :: a0 -> b
• Perhaps you meant one of these:
‘or’ (imported from Prelude), ‘odd’ (imported from Prelude)
I think there is a typo, either due to an author mistake or the version of Haskell changing the syntax.
My question is: Why do I get variable not in scope
for Just ord <*> Nothing
?
A quick search for "ord" on Hoogle reveals that it lives in the Data.Char
module . (I have no idea whether it was always there, or whether it only recently got moved there.) So you just need to import Data.Char
into your ghci
session.
ghci> import Data.Char
ghci> Just ord <*> Nothing
Nothing
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.