module Solution (solution) where
solution :: Num a => a -> a -> a
solution a b = a + b
test/Spec.hs
import Test.Hspec
import Solution
main :: IO ()
main = hspec $ do
describe "solution" $ do
it "adds 1 and 2 to get 3" $
solution 1 2 `shouldBe` 3
it "adds (-1) and (-2) to get (-3)" $
solution (-1) (-2) `shouldBe` (-3)
it "fails when adding a non-numeric type" $
-- Haskell is strongly typed; attempting to add incompatible types results in a compile-time error
pendingWith "Haskell does not allow adding a String and an Int"
Launch example
Example query:
Example generation:
package.yaml
src/Solution.hs
test/Spec.hs
Example install dependencies
Example launch compilation
Example launch test
Project Structure: