News for hackers. Stuff that matters.
Re:Functional Programming Jargon by hood_syntax on Tuesday November 07, 2017 @09:59AM (#15643836)
Let's say you have a validation function that matches a string with a given regex, and you need to use that same logic in several places, using a different regex. Currying allows you to write something like this:

validate :: Regex -> String -> T

validate r s = ...

validateIpAddr :: String -> T

validateIpAddr = validate ipRegex

validateZipCode :: String -> T

validateZipCode = validate zipCodeRegex

And so on and so forth. It can reduce boilerplate, and lets you do stuff like map partially applied functions to functors.

Re:Functional Programming Jargon by jandrese on Tuesday November 07, 2017 @02:56PM (#15646928)
This doesn't really seem to save you much, since you're going from:

  validate(IpAddr, Regex)
to

  validateIpAddr(Regex)
I have to admit I'm a little fuzzy on why currying is desirable so there's probably something obvious I'm missing.
Re:Functional Programming Jargon by taejo on Wednesday November 08, 2017 @07:39AM (#15651789)
It's `validateIpAddr(String)`: the first argument is fixed. Suppose you have a list of strings, and you want to extract the ones that are IP addresses. Then you can just write

    filter (validate ipRegex) listOfStrings
instead of

    filter validateIpAddr listOfStrings
        where validateIpAddr string = validate ipRegex string
Re:Functional Programming Jargon by jandrese on Wednesday November 08, 2017 @10:22PM (#15659562)
Why not just

  map { validate(ipRegex, $) } listOfStrings