I'm a Haskell newbie, trying to accomplish a Caesar cipher exercise.
In a .hs
file, I defined the following function:
let2int :: Char -> Int
let2int c = ord c - ord 'a'
Then I attempt to load this into GHCi by typing :l caeser.hs
and I get the following error message:
[1 of 1] Compiling Main ( caeser.hs, interpreted )
caeser.hs:2:12: Not in scope: `ord'
caeser.hs:2:20: Not in scope: `ord'
From the book I was using, I had the impression that ord
and chr
were standard functions for converting between characters and integers, but it seems evident that I need to "import" them or something. How is this done?
:m Data.Char
- metatron