winghci

Haskell : can only load one file at a time via :load

a 夏天 提交于 2021-02-04 13:19:04
问题 suppose I have two modules NecessaryModule1 & NecessaryModule2 (as outlined in the post Haskell : loading ALL files in current directory path. Then I have noticed in both WinGHCi and GHCi that if I do : > :load NecessaryModule1 [1 of 1] Compiling NecessaryModule1 ( NecessaryModule1.hs, interpreted ) Ok, modules loaded: NecessaryModule1. > addNumber1 2 3 5 > :load NecessaryModule2 [1 of 1] Compiling NecessaryModule2 ( NecessaryModule2.hs, interpreted ) Ok, modules loaded: NecessaryModule2. >

How can I compare and return data using a list of data

会有一股神秘感。 提交于 2020-05-15 07:48:23
问题 I'm a newbie to Haskell and I'm struggling to find a way to use class member variables to return the member variable I am looking for. I have this data: data Place = Place {name :: String, north :: Float, east :: Float, rainfall :: [Int] } deriving (Eq, Ord, Show) testData :: [Place] testData = [ Place "London" 51.5 (-0.1) [0, 0, 5, 8, 8, 0, 0], Place "Norwich" 52.6 (1.3) [0, 6, 5, 0, 0, 0, 3], Place "Birmingham" 52.5 (-1.9) [0, 2, 10, 7, 8, 2, 2], Place "Hull" 53.8 (-0.3) [0, 6, 5, 0, 0, 0,

Haskell function that takes out last occurrence of input character

一世执手 提交于 2019-12-23 21:07:23
问题 I'm having trouble writing this function that takes a character and a list of characters, then eliminates the last occurrence of that input character in the list. I was able to take out the first occurrence of the input character with my function below: fun :: Char -> String -> String fun c (s:ss) | s == c = ss | otherwise = s : fun c ss fun _ [] = [] What I need help on is how I should modify this function to take out the last occurrence of the input character, instead of the first. The

Compiling Haskell code in Cygwin, and some other bugs in Haskell Platform on Windows

五迷三道 提交于 2019-12-19 19:53:29
问题 I am trying to compile a simple hello world program in Haskell, with Haskell Platform 2011.2.0.1. If I load the code in WinGHCi, and use the GUI to compile, the .exe is created. Then I can run the .exe from Cygwin. But if I try to compile the code in Cygwin (using ghc --make ), linker fails. But again, if I compile from the Windows cmd prompt, then the compile+linker works fine. Are there any other environment variables I need to import into Cygwin, to make the compile+linker work in it? I

Convert a list of digits to a number HASKELL

吃可爱长大的小学妹 提交于 2019-12-13 03:45:41
问题 I want to make a function in haskell that given a list of single digits, i make the full number. I was thinking in using intensive lists and patrons, as the code it follows: funcion5 (x:xs) = [y*(10^w) | y <- (x:xs) w] The idea is, to go over the list and multiplie each digit to 10 pow to the position of the number. Finally i only have to sum all digits and I have the number as this: sum (funcion5 (x:xs)) Can anyone help me, please? Thanks 回答1: This may simply be done by folding with foldl1 :

Compiling Haskell code in Cygwin, and some other bugs in Haskell Platform on Windows

流过昼夜 提交于 2019-12-01 18:15:46
I am trying to compile a simple hello world program in Haskell, with Haskell Platform 2011.2.0.1. If I load the code in WinGHCi, and use the GUI to compile, the .exe is created. Then I can run the .exe from Cygwin. But if I try to compile the code in Cygwin (using ghc --make ), linker fails. But again, if I compile from the Windows cmd prompt, then the compile+linker works fine. Are there any other environment variables I need to import into Cygwin, to make the compile+linker work in it? I have put the following dirs in my Cygwin PATH: 2011.2.0.1/lib/extralibs/bin , 2011.2.0.1/bin (these are

Haskell : display/get list of all user defined functions

£可爱£侵袭症+ 提交于 2019-11-30 11:47:11
Is there a command in Haskell which displays (or get as a list of) all the user defined functions which have been loaded/defined in the GHCi? Thanks To see bindings you've made at the ghci prompt (e.g. with let or <- ), try :show bindings . If you've loaded some modules, you can use :show modules to get the names of loaded modules and then :browse ModuleName to list everything in scope from that module. When in ghci, use :browse or just :bro after loading the file. You may also browse unloaded modules via :browse Foo.Bar.Baz . 来源: https://stackoverflow.com/questions/10272094/haskell-display

Haskell : display/get list of all user defined functions

独自空忆成欢 提交于 2019-11-29 17:14:14
问题 Is there a command in Haskell which displays (or get as a list of) all the user defined functions which have been loaded/defined in the GHCi? Thanks 回答1: To see bindings you've made at the ghci prompt (e.g. with let or <- ), try :show bindings . If you've loaded some modules, you can use :show modules to get the names of loaded modules and then :browse ModuleName to list everything in scope from that module. 回答2: When in ghci, use :browse or just :bro after loading the file. You may also

Haskell : loading ALL files in current directory path

萝らか妹 提交于 2019-11-28 08:16:03
问题 The command (in GHCi) :load abc Loads the functions in the file abc (which must exist in the current directory path). How would I load all the files in the current directory path? Thanks ---------------------------------------------------------------------------------- [RESPONSE TO POST BELOW] Hi Rotskoff, thanks I tried your suggestion but I could not get it to work, so I think I must have misunderstood something. I created 3 files test.hs, test1.hs, and test2.hs as follows : -> --test.hs