I am having the problem that readFile returns an IO String but parse expects a regular String (or in the example below a ByteString). I though I simply use liftM but the example below still fails. What is the problem?
import Data.Aeson
import Data.Attoparsec
import Data.ByteString (ByteString, pack)
import Data.Maybe
import Network.HTTP
import Network.URI
import qualified Data.ByteString.Char8 as C
import Control.Monad
main = do
myres <- liftM parse json (C.readFile "dummy.json")
print myres
ERROR:
Couldn't match expected type `t0 -> Parser a0'
with actual type `Parser Value'
In the second argument of `liftM', namely `json'
In a stmt of a 'do' block:
myres <- liftM parse json (C.readFile "dummy.json")
In the expression:
do { myres <- liftM parse json (C.readFile "dummy.json");
print myres }
You miss parentheses around
(parse json), soliftMis applied toparse