Reputation: 35732
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
?
Upvotes: 2
Views: 608
Reputation: 44634
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
Upvotes: 6