Editing 1312: Haskell
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 8: | Line 8: | ||
==Explanation== | ==Explanation== | ||
− | The comic pokes fun at {{w|Haskell (programming language)|Haskell}}, a {{w|Functional programming|functional programming language}}. Functional programming languages are based on the mathematical concept of a function, that is two calls to a function always produce the same results given the same inputs. {{w|Side effect (computer science)|Side effect}}s of a function call are changes to the program state or observable interactions with the outside world, other than returning a value. As a simple example, if a <code>sum</code> function changes a global variable, or prints the sum before returning it, those are side effects. Functions in most other languages frequently have side effects, typically making them hard to analyze. Functional programming languages seek to avoid side effects when possible. ''Pure'' functional programming | + | The comic pokes fun at {{w|Haskell (programming language)|Haskell}}, a {{w|Functional programming|functional programming language}}. Functional programming languages are based on the mathematical concept of a function, that is two calls to a function always produce the same results given the same inputs. {{w|Side effect (computer science)|Side effect}}s of a function call are changes to the program state or observable interactions with the outside world, other than returning a value. As a simple example, if a <code>sum</code> function changes a global variable, or prints the sum before returning it, those are side effects. Functions in most other languages frequently have side effects, typically making them hard to analyze. Functional programming languages seek to avoid side effects when possible. ''Pure'' functional programming language like Haskell push this agenda by isolating the inevitable side-effects (input/output at least) through the type system (more specifically in {{w|monad (functional programming)|monads}} for Haskell). |
− | The first joke says that Haskell only has no side effects because no one ever uses Haskell programs. Even in a traditional procedural programming language like {{w|C (programming language)|C}}, if the program does not run | + | The first joke says that Haskell only has no side effects because no one ever uses Haskell programs. Even in a traditional procedural programming language like {{w|C (programming language)|C}}, if the program does not run it can't have side effects. |
− | In Haskell | + | In Haskell effects are first class values. This means that you can use effects just like any value, assign them to a variable, pass them around, or manipulate them to make new and different effects. Thus, there are technically no side effects, only primary effects. |
− | The title text is a joke about Haskell's {{w|lazy evaluation}}. The basic concept is that a value is not computed until it is actually used. Thus, it is possible to have a name representing the entire infinite list of {{w|Fibonacci number|Fibonacci numbers}}. However, until a particular element of the list is accessed, no work is actually done. The joke plays on "called" (referring to calling a function) vs. "called for" (requesting) | + | The title text is a joke about Haskell's {{w|lazy evaluation}}. The basic concept is that a value is not computed until it is actually used. Thus, it is possible to have a name representing the entire infinite list of {{w|Fibonacci number|Fibonacci numbers}}. However, until a particular element of the list is accessed, no work is actually done. The joke plays on "called" (referring to calling a function) vs. "called for" (requesting); thus Haskell may have value but no one has either invoked it to get that value or requested such a language. A simpler example may be: |
<nowiki>or :: Bool -> Bool -> Bool | <nowiki>or :: Bool -> Bool -> Bool |