0
votes

I've been getting used to Haskell development without the helping hand of ghci, namely using cabal and ghc together.

I'm trying to get a very simple haskell file to compile however I'm getting a strange error that makes no sense, at least not on the surface.

type Date = (String, String)
type Temperature = (String, Int)

data TemperatureInfo = Temp Date Temperature
                       deriving (Show)

myTemp = Temp ("date:","2015-02-28T20:16:12+00:00") ("Temperature", 0)


main :: IO ()
main = print myTemp

With the error:

Bradley$ ghc --make test.hs
         [1 of 1] Compiling Main             ( test.hs, test.o )
         .: createDirectory: invalid argument (Invalid argument)

I'm not sure if this is helpful, but if I remove the parameter from the print function the error goes away and gives the error below (as expected). Not sure if this is indicative at all.

[1 of 1] Compiling Main             ( test.hs, test.o )

test.hs:12:8:
    Couldn't match expected type ‘IO ()’ with actual type ‘a0 -> IO ()’
    Probable cause: ‘print’ is applied to too few arguments
    In the expression: print
    In an equation for ‘main’: main = print

Interestingly, because I store this file on a usb stick and cd to the directory and compile the file there, as I was writing this question, I moved it to my desktop and tried to compile again and it works!

Bradley$ runhaskell test.hs
         Temp ("date:","2015-02-28T20:16:12+00:00") ("Temperature",0)

I feel like I spend 95% of my time trying to get my haskell development environment working and 5% actually coding, does anyone know or have had any experiences as to why I'm having these type of problems? There seems to be lots of documentation for beginners and experts, but very little in terms of setting up the haskell platform/cabal/ghc correctly.

1
You didn't have write permissions on the USB. It's not Haskell's fault, it's a layer 8 problem. - Mihai Maruseac
Interesting! I'll reconsider storing my files on usb - Bradley
Just don't compile from it, unless you are sure you also have write permissions. - Mihai Maruseac

1 Answers

1
votes

Skip the --make flag. Run just ghc test.hs.