problems figuring out what the type system is telling me
Chris Moline
uglydaemon@shaw.ca
Fri, 7 Jun 2002 22:29:28 -0600
hi. i am really stuck on this problem and i cant seem to figure it out and so
i am posting this in the hopes someone will help me. i realize you prolly get
this kind of question alot but the wiki and the papers i have been reading
arent helping to clarify things.
i am trying to write a little utility to make it easier to get rid of ports on
my machine. the function that is giving me trouble is getDepends. it takes the
name of a port and opens the appropriate +CONTENTS file and returns the
dependencies it finds.
here is the function and its helper.
getDepends :: String -> [String]
getDepends p = do
handle <- openFile (portsDir ++ p) ReadMode
fetchDepends handle
fetchDepends :: Handle -> [String]
fetchDepends handle = do
l <- hGetLine handle
e <- hIsEOF handle
case (not e) of -- ifs keep giving indent errors so ill just use case
True ->
case (matchRegex (mkRegex "^@pkgdep") l) of
Just [a] -> [drop 8 l] ++ (fetchDepends handle)
_ -> fetchDepends handle
False -> ""
here is ghci's error messages.
Compiling Pheobe ( Phoebe.hs, interpreted )
Phoebe.hs:19:
Couldn't match `[]' against `IO'
Expected type: [t]
Inferred type: IO Handle
In the application `openFile (portsDir ++ p) ReadMode'
In a 'do' expression pattern binding:
handle <- openFile (portsDir ++ p) ReadMode
Phoebe.hs:24:
Couldn't match `[]' against `IO'
Expected type: [t]
Inferred type: IO String
In the application `hGetLine handle'
In a 'do' expression pattern binding: l <- hGetLine handle
Failed, modules loaded: none.
could someone be so kind as to explain what the problem is?
sincerly,
chris moline