Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8069029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:52:53+00:00 2026-06-05T12:52:53+00:00

This is a bit long, so bear with me! I’m having a bit of

  • 0

This is a bit long, so bear with me!

I’m having a bit of trouble working with a Haskell program, that I have to use as part of a uni project. For reference, it’s Casper.

So, you’re supposed to execute a script, which is actually a Bash script to invoke Hugs interpreter like this:

exec $HUGSBIN/hugs $HUGSARGS +p"Casper> " $FILES

Where $FILES points to a Main.lhs file.

After this, I need to invoke a function “compile” with a path to a file, in the interpreter.

I need to perform the above in a scripted manner. I need this automated because I’m writing a program that will call on Casper in the background.

So I compiled the .lhs file. Now I want to execute the “compile” function but I have no idea how this is done. I try:

./Main compile <a path>

from the command line but it returns me an error about a file “test” not found. Upon investigation, I see these lines in the Main.lhs file:

>main :: String -> IO()
>main = compile "test"

>compile :: String -> IO()
>compile s = catch (compile0 False s) handler

[...snipped]

The 2nd line solves this question. Now my question is, how do I invoke the “compile” function and pass a path to it after I have compiled main.lhs? From the interpreter, I just type “compile ” and it works, but I can’t get the same to work after compiling the main.lhs and executing from the command line? Any ideas why? Is there any way I can script Hugs if all else fails?

Thank you for any assistance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:52:55+00:00Added an answer on June 5, 2026 at 12:52 pm

    You may access the command-line arguments passed to a Haskell program via getArgs. For example, it sounds like you want a main function that does something like this:

    >main = do
    >    args <- getArgs
    >    case args of
    >        [] -> putStrLn "What file did you want me to compile?"
    >        [filename] -> compile filename
    >        _ -> putStrLn "I only compile one file at a time."
    

    Modify to taste.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a bit long so please bear with me.. I'm working on
This question is a bit of a structural/design question as I'm having trouble working
This is a bit of a long shot as I don't have access to
This question is a bit long, please bear with me. In REST, i think
I have a 64-bit long that I want to round down to the nearest
This is a bit of a long question so please bear with me guys.
I have another Javascript regex conundrum... (apologies if this is a bit long-winded -
I have a regex that is going to end up being a bit long
This is going to be a bit long and specific so please bear with
This bit of code comes with new classes that are subclasses of UITableViewController... -

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.