My complaint with FP: Sometimes I just want to do something silly, like adding a log somewhere. If I choose to add said side effect, now all my functions are marked with an io signature (so there might be _other_, nastier side effects hiding there as well - mainly an issue if you have multiple people contributing to the same project). If I don't add the side effect, and choose to refactor multiple layers of code, I w…
> Sometimes I just want to do something silly, like adding a log somewhere. In Haskell, you can use Debug.Trace for just that purpose, when you don't want to change the type of your function.
15-150: Principles of Functional Programming
61–70 of 146 posts
Re: 15-150: Principles of Functional Programming
#62Earlier quoted context omitted.
There's a few things which go into this (hi, I'm the instructor!). One such reason is historical. Standard ML is a research language, and a significant amount of work on it was done by professors at Carnegie Mellon, who developed the curriculum for this course. Even setting that aside though, I fully agree with the choice to teach it in SML. For transparency, I work professionally in OCaml, so I am not unfamiliar wit…
As a professional who uses F# every day, I appreciate this answer, even though it concerns me. Separating concepts from practical details is worthwhile, but can be taken too far. I think the FP community probably focuses a bit too much on theory. I would encourage you to consider teaching a more practical language, like F#, in the future.
Re: 15-150: Principles of Functional Programming
#63Does this include exercises? I didn't see any and I always find that the most useful part of learning.
For instance, here's the SML code for it:
``` datatype exp =
Num of int
| Plus of exp * exp
| Minus of exp * exp
| Times of exp * exp
| Div of exp * exp
```Implement the function `eval : exp -> int`, which evaluates the expression as best as it can. Assume no division by zero.
Extra credit: Can you implement `eval' : exp -> int option`, that returns `SOME n` if the expression evaluates, and `NONE` if it divides by zero?
Re: 15-150: Principles of Functional Programming
#64Re: 15-150: Principles of Functional Programming
#65Great resource! Forgive my ignorance but why do so many modern functional programming courses use Standard ML instead of a Lisp dialect? Is it because of its built-in type-checking, or is it just how it's always been taught?
Re: 15-150: Principles of Functional Programming
#66Re: 15-150: Principles of Functional Programming
#67It seems that the fundamental problem with the functional paradigm (in its pure form) is that the real world - including the architecture of the computer that is used to run the programs on - is full of side effects, i.e. is essentially "imperative," and with this impedance between them the idea creates more problems than it solves.
Re: 15-150: Principles of Functional Programming
#68Great resource! Forgive my ignorance but why do so many modern functional programming courses use Standard ML instead of a Lisp dialect? Is it because of its built-in type-checking, or is it just how it's always been taught?
The value of purely functional programming languages, as opposed to functional programming languages like lisps, is that you get referential transparency, which means that when you define `a = b`, you know that you can always replace any instance of `a` with `b` and get the same answer. This is a very natural property in mathematics (algebraic rewritings are basically just this property writ large) and so it helps to…
Re: 15-150: Principles of Functional Programming
#69Hey Brandon, thanks for posting this. Off-topic but maybe consider serving up thumbnails on that page instead of the full-size pngs https://brandonspark.github.io/prologue/lecture01.png