Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
How can I effectively work with the leksah haskell IDE?
For a start, I am very thankful for all the work that the leksah people put in. It's great!
However, I have trouble working effectively in leksah.
mymain :: IO ()
mymain = do
myData <- getMyData
...
...
How can I show the type of some variable in a do-expression, like myData? When I right click on it and then go to type, the error message gets <interactive>:1:1: Not in scope: 'myData'. Also after I do something with ghci in leksah, build (CtrlB) no longer compiles my project but suddenly does something else.
How can I effectively use leksah in general and especially concerning ghci in leksah (like display a type of something that is not toplevel but nested)? What are the top 5 things you would suggest?
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I can't fit the definition of Wikipedia with Haskell code:
main = return ()
or
main = undefined
Above all, "A computer program is a collection of instructions1" where instructions are defined like that.
Taking those two definition, is main = return () a computer program? Is the definition quoting to machine code?
If it is... Why?
If it's not, what is considered a program in Haskell?
Nothing about the definition of a program requires it to have explicit I/O. For example, consider /bin/sleep. It does literally nothing besides doing nothing for a fixed period of time. Ultimately, it does kind of have input/output, in that it "causes" (in a weak sense of the term) a change in the time.
Another example might be a Python program like:
while True:
pass
All it does is create heat, literally, but there's no reason to think it's not a program.
An unoptimized build of your program might actually contain the machine instructions to load an immediate value 5 into some register, followed by program termination. However, an optimizing compiler like Haskell's would deduce that the value is never used, and will gladly cull it entirely (and it's more than free to do so, since it won't have any observable effect. The machine instructions for program termination would still exist, though.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
The intuition of an optional type like Maybe Int is that either there is no Int (thus, there's Nothing there) or that there is some Int; there is something there.
It makes sense to me that we call the type constructor for the "negative" case Nothing, since it means exactly that -- that there's no Int there. But why use the word Just in the case where the emphasis is on something actually being there?
To me, the word "Just" carries the connotation that the thing it's describing is less than the alternative; the opposite of something actually being there; for example,
A: Are you doing anything tonight?
B: No; I'm just gonna stay in and watch TV.
A: Did you investigate the creepy ghost sounds around your house?
B: yeah, turns out it was actually just an owl.
Clearly I'm lacking whatever intuition this naming choice was based on. What is it? Because to me, the word Just means the opposite of how it's used in the Maybe type.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am studying the example in section 3 on this page:
https://wiki.haskell.org/State_Monad
Basically, I would like to play with this example but I do not know how to make the code do anything. I take it that this is a "module", and that some modules are "programs" in Haskell, but I don't understand why this module has a function called "main" (I thought it would also have to be called "Main" to be a program, but I tried changing it and it failed to compile). If it is not a program, then what I am supposed to do with a module sitting all by itself? Am I supposed to import it into ghci and then type > main? If so, I tried but I can't make it happen.
The code in the sections titled "complete and concrete example" are complete and concrete examples. You can put the code in these into files with the same name as the module name (i.e. the StateGame module should go into a file called StateGame.hs).
You can then compile that with ghc ghc StateGame.hs -main-is StateGame. Alternatively you can rename that module to Main, then you don't need the -main-is part.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am not fully satisfied with the format of GHC error messages. How can I make a custom print function?
You want to modify GHC? well, it's open-source so you can change it however you wish and recompile but that would probably be a gigantic overkill.
If I really really wanted to, I'd make a program that calls GHC with the arguments it receives, read back the output, process it, then print it.
You can do it with System.Process.readProcessWithExitCode, specifically.
You might be tempted to use readProcess for its easier API, but it will only read from stdout and you're almost certainly want stderr too.
Plus the exit-code in the former function could be very helpful too: you could know if compilation succeeded or not without even parsing, but by just seeing if the exit code = 0.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
So lets say I have this global variable foo, which while my server is running I can access it. What I want to be possible is if my server crashes it will first initially try to recover foo, then continue to do server stuff. I want to know the best way possible to do such a thing. Here are the ways I can think of doing this.
1, Whenever foo is updated, (which not frequently), I will write to a file a marshalized foo, and when my server crashes it will eval the content's of the file to be foo.
2, Use a light database such as sqlite to store foo,
Come to think about it both these ideas are really closely related, but is there a referred solution given that foo is at any point going to be 10kBytes.
I would store the var in redis. This allows what you want and provides scalability.
Node redis module: https://github.com/mranney/node_redis
Hands on: http://howtonode.org/node-redis-fun