Project Inquiry

Implement Prelude.curry

Challenge
{-# LANGUAGE NoImplicitPrelude #-}

module Main where

import           Prelude hiding (curry)

main :: IO ()
main = putStrLn $ if test then "SUCCESS" else "FAILURE"

test :: Bool
test = curry helper 42 42 == 84
  where helper :: (Integer, Integer) -> Integer
        helper (fstParam, sndParam) = fstParam + sndParam

-- TODO
curry :: ((a, b) -> c) -> a -> b -> c
curry = undefined
Solution
{-# LANGUAGE NoImplicitPrelude #-}

module Main where

import           Prelude hiding (curry)

main :: IO ()
main = putStrLn $ if test then "SUCCESS" else "FAILURE"

test :: Bool
test = curry helper 42 42 == 84
  where helper :: (Integer, Integer) -> Integer
        helper (fstParam, sndParam) = fstParam + sndParam

-- DONE
curry :: ((a, b) -> c) -> a -> b -> c
curry f fstParam sndParam = f (fstParam, sndParam)