-1

I need to import Data.Char into my .hs file, in order to run the script in GHCi. When I just add "import Data.Char" the console seems to complain and gives me parse error. How do I do that properly? I know its probably very simple, but I could not find an answer myself.

What produces the error :

import Data.Char

hashString :: [Char] -> Int -> [Char]
hashString [] a = []
hashString (x:xs) a = (intToDigit((digitToInt x) * a)):hashToString( xs (a - 1) )
foFox
  • 1,124
  • 1
  • 14
  • 24
  • 4
    This is probably something quite simple, but you'll probably need to post an example for us to be able to tell what you did wrong. My best guess is that you tried to do the import at the bottom of the file or something; it needs to be at the top. – MathematicalOrchid Dec 01 '12 at 16:56
  • That code gives me some other errors (a misspelled name, some type errors) but no parse error. – hammar Dec 01 '12 at 16:58
  • Yeah I had some code above that import, I thought since I do not use is over there, the import statement can be below. Thanks very much! – foFox Dec 01 '12 at 16:58
  • Yeah, the code is probably wrong, I need to do some haskell coding for college assignment. I don't like it so I don't use if I don't absolutely have to, hence the errors. – foFox Dec 01 '12 at 17:02

1 Answers1

1

Well you don't like it? Try to learn it first then see how it goes, give it a shot:)

Anyway, Data.Char does not have a function called hashToString, if that's your problem. You do need to import Data.Char for the intToDigit and digitToInt, though.

zw324
  • 26,764
  • 16
  • 85
  • 118