Skip to content

Instantly share code, notes, and snippets.

@jmn
Created December 8, 2018 07:14
Show Gist options
  • Save jmn/a7538b7b0a1a0e724038c7a01fea9995 to your computer and use it in GitHub Desktop.
Save jmn/a7538b7b0a1a0e724038c7a01fea9995 to your computer and use it in GitHub Desktop.
replace' :: Eq b => b -> b -> [b] -> [b]
replace' a b = map (\x -> if (a == x) then b else x)
main = do
f <- readFile "1input"
let l = lines $ replace' '+' ' ' f
map (read::String->Int) l
putStrLn "hi"
@jmn
Copy link
Author

jmn commented Dec 8, 2018

1.hs:13:3: error:
    • Couldn't match type ‘[]’ with ‘IO’
      Expected type: IO Int
        Actual type: [Int]
    • In a stmt of a 'do' block: map (read :: String -> Int) l
      In the expression:
        do f <- readFile "1input"
           let l = lines $ replace' '+' ' ' f
           map (read :: String -> Int) l
           putStrLn "hi"
      In an equation for ‘main’:
          main
            = do f <- readFile "1input"
                 let l = ...
                 map (read :: String -> Int) l
                 ....
   |
13 |   map (read::String->Int) l

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment