function - Multiple actions upon a case statement in Haskell -


One final question for the evening, I am creating the main input function of my Haskell program and I have to check for it

then I use

  args  

Is there a wise way to install other methods, or is it in my best interest to write such a function that the second case is thrown into the main is?

Or there is not a better solution to the issue of affairs. I just have to take a name.

Argument processing should be separated into a separate function. Apart from this it is difficult to generalize because there are many different ways of handling arguments. Here are some types of signatures that deserve to be considered:

exitIfNonempty :: [Arg] - & gt; IO [Arg] - empty procedures options until return processes :: [Arg] - & gt; (Option Recurring, [ARG]) - Convert to Records Option - Balance Elixed Process OpticsBase Effect :: [ARG] - & gt; State [ARG] - Update the state to the alternative, remaining remaining ARGS callFirstArgas cum: [(name, [ARG] -> Io ()) -> [ARG] - & gt; IO ()

and some sketches of the implementation (none of this code has anywhere near the compiler):

  exitIfNonempty [] = putStrLen Exit "exit" to exit exit effnonempty args = return args callfirstArgAsCommand commands [] = "missing command name" callFirstArgAsCommand command (f: as) = ​​Case lookup in bus command -f; & Gt; Nothing as f - & gt; Unsuccessful (f ++ "no command is named")  

I will leave others in my imagination.

Is it the best interest for me to write a function, which is the second case thrown into the main?

Yes. In addition, you should create a library of combonators that you can easily process command line arguments for different types of programs. Such libraries are undoubtedly present already, but it is one of those cases where it can be easy to roll your own (and it will definitely be more fun) than learning someone else's API.


Comments