Haskell Curry (and Uncurry)

  1. the function takes two parameters of type a and b and returns a type c. [i.e. (a → b) → c ]
  2. Or, the function takes a parameter of type a and returns a function of type b → c . [i.e. a → (b → c) ]
add :: Int -> Int -> Int
add x y = x+y
ghci> let add2 = add 3
ghci> add2 4
7
ghci> add 3 4
7
curry :: ((a, b) -> c) -> a -> b -> c
uncurry :: (a -> b -> c) -> ((a, b) -> c)
cur1 :: (Num a) => a -> a -> a                                                           cur1 x y = x+yghci>add1 = uncurry cur1
ghci> add1 (1,2)
3
ghci> add1 1
**ERROR**
uncur1 :: (Num a) => (a,a) -> a
uncur1 x = fst x + snd x
ghci> add1 = curry uncur1
ghci> add1 1 2
3
ghci> let add2 = add1 1
ghci> add2 2
3

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Install Homebrew on Mac

Realtime JavaScript Face Tracking and Face Recognition using face-api.js’ MTCNN Face Detector

AWS NoSQL Workbench & DynamoDB Local

Tutorial Fuzzy Logic Mamdani for Arduino

Tutorial Fuzzy Logic Mamdani for Arduino

Python 101: Ultimate Python Guide or Introduction to Modern Python

Zomato Features development using Agile Methodology

Guild master — Is that a real job title?

How to write a Synthetix Improvement Proposal (SIP) for dummies

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Priyanka Mondal

Priyanka Mondal

More from Medium

CRODO: It’s benefits over other IDO’s. A MUST KNOW!!

Ghosties’ Roundup — three

Interactive Map Reveals Which Indigenous Lands You’re Living On

3.22.2022