I have a first Application file, Myapp.hs
I have created a module for parsing csv file , called Csvparser which is defined in a file Csvparser.hs.
Both files are in the same directory.
I don't understand how to import in Myapp.hs the Csvparser module
Prelude Data.Maybe Data.List Data.Time Data.Either> :load C:\Test\Haskell\MyApp.hs
[1 of 1] Compiling Main ( C:\Test\Haskell\MyApp.hs, interpreted )
C:\Test\Haskell\MyApp.hs:5:1: error:
Could not find module `Csvparser'
Use -v to see a list of the files searched for.
|
5 | import Csvparser
| ^^^^^^^^^^^^^^^^
Failed, no modules loaded.
Prelude Data.Maybe Data.List Data.Time Data.Either>
The module can be loaded in standalone and works
Prelude Data.Maybe Data.List Data.Time Data.Either> :load C:\Test\Haskell\Csvparser.hs
[1 of 1] Compiling Csvparser ( C:\Test\Haskell\Csvparser.hs, interpreted )
Ok, one module loaded.
*Csvparser Data.Maybe Data.List Data.Time Data.Either> import Csvparser
*Csvparser Data.Maybe Data.List Data.Time Data.Either Csvparser> :t Csvparser.parseCSV
Csvparser.parseCSV :: String -> Either ParseError [[String]]
*Csvparser Data.Maybe Data.List Data.Time Data.Either Csvparser>
Here is the failing syntax at line 5 of MyApp.hs
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE ScopedTypeVariables #-}
import Csvparser
import Database.HDBC
import Database.HDBC.ODBC
What can I do for making ghci/haskell understand that Csvparser module is to be found in the same directory of MyApp.hs ?
Csvparser.hs
ghci
from the folder that contains both files the import should work, but maybe you have a reason not to run it from there:cd C:\Test\Haskell
to change GHCi's directory to the one with your code. Note that this will also run your code in such directory (e.g. if your code creates a file, it will be created there).