2 Replies - 1179 Views - Last Post: 19 May 2015 - 04:34 AM

#1 abir_fragrance  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 10-March 15

build a file .hs (haskell)

Posted 19 May 2015 - 03:29 AM

Hi, i'm new in functional programing, and also in haskell , i'm having a probleme with call of functions, i'm using GHCI version 7.8.3 on windows 8, i create a file fct.hs and put it in bin ( C:\Program Files\Haskell Platform\2014.2.0.0\bin), my question is : to call the function should i just write the commande :l fct ? or do i have to somthing before that? i found this commande to build the file : ghc --make name.hs ,but in unix, and if in windows name.exe ; i dont get it; should i write ghc --make name.exe or directly name.exe, what im i doing wrong?

Is This A Good Question/Topic? 0
  • +

Replies To: build a file .hs (haskell)

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2517
  • View blog
  • Posts: 4,001
  • Joined: 21-June 11

Re: build a file .hs (haskell)

Posted 19 May 2015 - 04:05 AM

View Postabir_fragrance, on 19 May 2015 - 12:29 PM, said:

i create a file fct.hs and put it in bin ( C:\Program Files\Haskell Platform\2014.2.0.0\bin)


You shouldn't put your source files in the Haskell installation directory. It shouldn't hurt anything, but it just doesn't make any sense (especially since I imagine you need admin rights to write in that directory). Usually you'd put your source code somewhere in your home folder.

Quote

to call the function should i just write the commande :l fct ?


To call that function from ghci, you need to make sure that you're in the right directory (either by starting ghci from that directory or by using :cd inside ghci), then use :l fct and then actually call the function you want to call (by writing fact 5 for example, depending on what the name of the function is and with which argument you want to call it).

Quote

i found this commande to build the file : ghc --make name.hs ,but in unix, and if in windows name.exe ; i dont get it; should i write ghc --make name.exe or directly name.exe, what im i doing wrong?


ghc --make name.hs should work fine (though obviously you should replace "name.hs" by "fct.hs" if that's the name of your Haskell file). If that does not work, what error message do you get?
Was This Post Helpful? 1
  • +
  • -

#3 abir_fragrance  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 10-March 15

Re: build a file .hs (haskell)

Posted 19 May 2015 - 04:34 AM

Thank you sepp2k, it worked ( i didnt know how to change the directory with cd until now) you helped me a lot. thank you again
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1