[Haskell-beginners] Re: ghci access to .hs functions

Brent Yorgey byorgey at seas.upenn.edu
Thu Aug 12 05:50:07 EDT 2010

On Thu, Aug 12, 2010 at 01:42:58AM -0700, prad wrote:
> On Thu, 12 Aug 2010 09:01:42 +0100
> Brent Yorgey <byorgey at seas.upenn.edu> wrote:
> > Can you show
> > us the exact contents of your .hs file?
> certainly! but now i take it all back! :(
> it's working fine without the return().
> it compiles main when i :l or when i ghci the file from the command
> line.
> so now i think i'm delusional. :D :D
> anyway, here's some of the code below and i'll ask another question. in
> the function:
> -- edFil: edits a file with vim
> -- edFil :: String -> IO GHC.IO.Exception.ExitCode (not in scope error) 
> edFil kV = rawSystem "vim" ["+source ~/.vim/ftplugin/html/HTML.vim",kV]
> i got the type from ghci, but if i actually put it in i get error:
> Not in scope: type constructor or class `GHC.IO.Exception.ExitCode'

In order to be able to refer to a type you must import a module which
exports it.  However you are free to *use* a type without importing it,
as long as you do not actually refer to it in a type signature.  This
is why your code works without the type signature.  Just add

  import GHC.IO.Exception

and then you will be able to give the type signature

  edFil :: String -> ExitCode


More information about the Beginners mailing list