Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature:Autograding] Add Haskell image #45

Merged
merged 16 commits into from
Sep 13, 2024
Merged

Conversation

ION606
Copy link
Contributor

@ION606 ION606 commented Sep 1, 2024

Please check if the PR fulfills these requirements:

  • Tests for the changes have been added/updated (if possible)
  • Documentation has been updated/added if relevant

What is the current behavior?

none

What is the new behavior?

we can now run haskell files

Other information?

this is not a breaking change and I tested it using some simple files (I included an example below):

-- Function to compute the nth Fibonacci number
fibonacci :: Integer -> Integer
fibonacci n
  | n <= 0    = 0
  | n == 1    = 1
  | otherwise = fibonacci (n - 1) + fibonacci (n - 2)

-- Function to compute the factorial of a given number
factorial :: Integer -> Integer
factorial 0 = 1
factorial n = n * factorial (n - 1)

-- Function to check if a number is prime
isPrime :: Integer -> Bool
isPrime n
  | n <= 1    = False
  | n == 2    = True
  | otherwise = null [ x | x <- [2..isqrt n], n `mod` x == 0]
  where
    isqrt = floor . sqrt . fromIntegral

-- Main function to test the above functions
main :: IO ()
main = do
  putStrLn "Enter a number for Fibonacci calculation:"
  fibInput <- getLine
  let fibNumber = read fibInput :: Integer
  putStrLn ("Fibonacci number at position " ++ show fibNumber ++ " is " ++ show (fibonacci fibNumber))

  putStrLn "\nEnter a number for factorial calculation:"
  factInput <- getLine
  let factNumber = read factInput :: Integer
  putStrLn ("Factorial of " ++ show factNumber ++ " is " ++ show (factorial factNumber))

  putStrLn "\nEnter a number to check if it is prime:"
  primeInput <- getLine
  let primeNumber = read primeInput :: Integer
  putStrLn (show primeNumber ++ (if isPrime primeNumber then " is" else " is not") ++ " a prime number.")

dockerfiles/haskell/3.0.0.0/Dockerfile Outdated Show resolved Hide resolved
dockerfiles/haskell/3.0.0.0/Dockerfile Outdated Show resolved Hide resolved
dockerfiles/haskell/3.0.0.0/Dockerfile Outdated Show resolved Hide resolved
@cjreed121
Copy link
Member

Edit PR description

s/prolog/haskell/

@ION606
Copy link
Contributor Author

ION606 commented Sep 5, 2024

Edit PR description

s/prolog/haskell/

oops I think I fixed it now

dockerfiles/haskell/3.0.0.0/Dockerfile Outdated Show resolved Hide resolved
Copy link
Member

@cjreed121 cjreed121 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure where the tag name of 3.0.0.0 comes from. I'm guessing 8.8.4 might be more relevant since that is the ghc version.

dockerfiles/haskell/3.0.0.0/Dockerfile Outdated Show resolved Hide resolved
Copy link
Member

@cjreed121 cjreed121 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some local testing, I noticed the chosen ghc version is not compiled for aarch64. The tests should have caught this but because of an error, it was skipped. Could you pick a different ghc version where it is also compiled for aarch64.

@ION606
Copy link
Contributor Author

ION606 commented Sep 12, 2024

After some local testing, I noticed the chosen ghc version is not compiled for aarch64. The tests should have caught this but because of an error, it was skipped. Could you pick a different ghc version where it is also compiled for aarch64.

Can you please elaborate on this please? Running docker run --platform=linux/amd64 works fine for me (I put a screenshot below)
image

@cjreed121
Copy link
Member

Couple things:

  • I'm referring to building a new image not running an existing image.
  • I'm referring to aarch64 not amd64.

@ION606
Copy link
Contributor Author

ION606 commented Sep 12, 2024

Couple things:

* I'm referring to building a new image not running an existing image.

* I'm referring to aarch64 not amd64.

oops my bad, what's the error you're getting? Is it

Step 2/8 : RUN apt-get update     && apt-get install -y --no-install-recommends     curl build-essential libffi-dev libffi8 libgmp10     libgmp-dev libtinfo5 pkg-config ca-certificates     && rm -rf /var/lib/apt/lists/*
 ---> [Warning] The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64/v3) and no specific platform was requested
 ---> Running in ebd9b48099c4
exec /bin/sh: exec format error
The command '/bin/sh -c apt-get update     && apt-get install -y --no-install-recommends     curl build-essential libffi-dev libffi8 libgmp10     libgmp-dev libtinfo5 pkg-config ca-certificates     && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 1

@cjreed121
Copy link
Member

@ION606 please check Zulip and I'll follow up there

@ION606
Copy link
Contributor Author

ION606 commented Sep 12, 2024

can you check if this works on aarch64 please?

@bmcutler bmcutler merged commit fec2e49 into Submitty:main Sep 13, 2024
3 checks passed
@ION606 ION606 deleted the haskell branch September 15, 2024 20:37
@ION606 ION606 restored the haskell branch September 20, 2024 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants