lambda-calculus

What does eta reduce mean in the context of HLint

巧了我就是萌 提交于 2019-11-27 03:21:09
问题 I'm looking at the tutorial http://haskell.org/haskellwiki/How_to_write_a_Haskell_program import System.Environment main :: IO () main = getArgs >>= print . haqify . head haqify s = "Haq! " ++ s When running this program under HLint it gives the following error; ./Haq.hs:11:1: Warning: Eta reduce Found: haqify s = "Haq! " ++ s Why not: haqify = ("Haq! " ++ ) Can someone shed some light on what exactly "Eta Reduce" means in this context? 回答1: Eta reduction is turning \x -> f x into f as long

“What part of Hindley-Milner do you not understand?”

冷暖自知 提交于 2019-11-27 02:19:42
I swear there used to be a T-shirt for sale featuring the immortal words: What part of do you not understand? In my case, the answer would be... all of it! In particular, I often see notation like this in Haskell papers, but I have no clue what any of it means. I have no idea what branch of mathematics it's supposed to be. I recognise the letters of the Greek alphabet of course, and symbols such as "∉" (which usually means that something is not an element of a set). On the other hand, I've never seen "⊢" before ( Wikipedia claims it might mean "partition" ). I'm also unfamiliar with the use of

How to correctly curry a function in JavaScript?

不羁的心 提交于 2019-11-27 01:21:48
I wrote a simple curry function in JavaScript which works correctly for most cases: const add = curry((a, b, c) => a + b + c); const add2 = add(2); const add5 = add2(3); console.log(add5(5)); <script> const curried = Symbol("curried"); Object.defineProperty(curry, curried, { value: true }); function curry(functor, ...initArgs) { if (arguments.length === 0) return curry; if (typeof functor !== "function") { const value = JSON.stringify(functor); throw new TypeError(`${value} is not a function`); } if (functor[curried] || initArgs.length >= functor.length) return functor(...initArgs); const

non recursive lambda calculus factorial function

六眼飞鱼酱① 提交于 2019-11-26 22:09:06
问题 How to write a factorial function without use of recursion using lambda calculus? Meaning just the math notation not implementation in any particular programming language. 回答1: If by "without the use of recursion" you mean without general recursion and hence without fixpoints (or self applications), we can simply observe that the factorial function is primitive recursive (that is, iterative, in essence), and there is a very general and simple encoding of primitive recursion by means of

How to correctly curry a function in JavaScript?

半腔热情 提交于 2019-11-26 09:38:00
问题 I wrote a simple curry function in JavaScript which works correctly for most cases: const add = curry((a, b, c) => a + b + c); const add2 = add(2); const add5 = add2(3); console.log(add5(5)); <script> const curried = Symbol(\"curried\"); Object.defineProperty(curry, curried, { value: true }); function curry(functor, ...initArgs) { if (arguments.length === 0) return curry; if (typeof functor !== \"function\") { const value = JSON.stringify(functor); throw new TypeError(`${value} is not a

“What part of Hindley-Milner do you not understand?”

耗尽温柔 提交于 2019-11-26 08:38:49
问题 I swear there used to be a T-shirt for sale featuring the immortal words: What part of do you not understand? In my case, the answer would be... all of it! In particular, I often see notation like this in Haskell papers, but I have no clue what any of it means. I have no idea what branch of mathematics it\'s supposed to be. I recognise the letters of the Greek alphabet of course, and symbols such as \"∉\" (which usually means that something is not an element of a set). On the other hand, I\