I was writing a program for converting all the words in the file into a array and calculate their corresponding scores and then zip both of them and make a dictionary and print it.
I want to use only dictionary to increase the performance but it is showing a error as .
[1 of 1] Compiling Main ( file.hs, file.o )
file.hs:21:1:
parse error (possibly incorrect indentation or mismatched brackets)
import Prelude hiding (lookup)
import Data.Map
import Data.Map (Map)
import qualified Data.Map as Map
getWordsFromFile :: String -> IO [String]
getWordsFromFile file = readFile file >>= return . words
main = do
wordList <- getWordsFromFile "wods.txt"
let words = wordList
let scores = score words
let list = zip words scores
let dic = fromList list
putStrLn $ show (dic)
score :: [String] -> [Int]
score (x : xs)
| map sum . map scrabble
mapper :: Eq k => [(k, v)] -> k -> v
mapper dict k = case lookup k dict of (Just v) -> v
scrabble :: Char -> Int
scrabble = mapper [ ('A', 1), ('B', 3),('C', 3), ('E', 1), ('D', 2), ('G', 2), ('F', 4), ('I', 1), ('H', 4), ('K', 5), ('J', 8), ('M', 3), ('L', 1), ('O', 1), ('N', 1), ('Q', 10), ('P', 3), ('S', 1), ('R', 1), ('U', 1), ('T', 1), ('W', 4), ('V', 4), ('Y', 4), ('X', 8), ('Z', 10)]
What are the corrections i need to do ??