/fpt/ - Functional Programming Thread

Next-level programming thread.
Let the New Year bring you pure and immutable joy and happiness! May anger, despair and sorrow never be evaluated!
Happy New 2017 year!
Last one: Resources:
>Erlang
learnyousomeerlang.com/content
>>Elixir
chimera.labs.oreilly.com/books/1234000001642/index.html
elixir-lang.org/learning.html
>F#
fsharp.org/learn
>Haskell
en.wikibooks.org/wiki/Haskell
0x0.st/pbp.pdf
>Lisps
>>Common Lisp
gigamonkeys.com/book
cs.cmu.edu/~dst/LispBook/book.pdf
Common Lisp Recipes
Land of Lisp
An Introduction to Functional Programming Through Lambda Calculus
>>Clojure
braveclojure.com/foreword/
The joy of Clojure
>>Scheme
SICP
Essentials of Programming Languages
How to Design Programs:
ccs.neu.edu/home/matthias/HtDP2e/
Art of the Propagator
Little Schemer
The Seasoned Schemer
The Scheme Programming Language by Kent Dybvig
Realm of Racket
Lisp in Small Pieces
>OCaml
realworldocaml.org/
ocaml.org/learn/tutorials/
>Scala
Functional Programming in Scala (Chiusano and Bjarnason)
Atomic Scala (Eckel and Marsh)
Programming Scala (Wampler and Payne)
Programming in Scala (Odersky, Spoon and Venners)
>Web languages
>>Elm
guide.elm-lang.org/
>>PureScript
purescript.org/learn/

Other urls found in this thread:

github.com/purcell/emacs.d.
blunt.herokuapp.com/#input=\xs -> map (\x -> isDigit x) xs
clhs.lisp.se/Body/m_loop.htm#loop
unintelligible.org/onlisp/onlisp.html
twitter.com/SFWRedditImages

can you stop making this fuckign thread? theres already a retarded functional general thread with 60 posts

I keep telling him to change stuff in the OP to see how many times he'll remake it.

Probably not any more after reading this.

I said it is the last time, it will be the last time.

Also:
>The OP seems to imply that it's a good way to learn Scheme.
"Resources:" is written in the OP, not "Resouces to learn language X"
EoPL uses Scheme, so it will be Scheme resource.
I will thinkj about that by next bumplimit.

>HaskLEL is useless and, pure functional and stateless languages are a meme
>Lisp is only used for third class text editors
>SICP is not a good book and this is why it's given away for free
>Anime is shit
>Maki a slut
>C++ is much better than C
>Java is the language of the future
>JS is a good choice for server side
>The best software engineers are indians

I don't dislike this thread but thank you for using an anime image

Talking again about logic programming.
Some user around said that modern logic programmers use Haskell for logic programming.
Does it mean Haskell supports backtracking?
If so, how?

>EoPL uses Scheme, so it will be Scheme resource.
EoPL uses Scheme incidentally, it doesn't teach it. See also: SICP.

Please make a list what should be redone in OP.

1. Delete OP.
2. Try again.
3. Goto 1.

Your opinion is taken into consideration, thanks.

You're welcome. Now please delete the thread and try again.

Not possible.

You have failed utterly, OP.

I've forgotten to check this.
>You can add, "Slime - The Superior Lisp Interaction Mode for Emacs" it's epic.

>Also easymod "emacs.d" configs for webdev and bunch of the functional languages github.com/purcell/emacs.d.

I don't get about point-free notation.
If I don't give arguments with function, does it mean I must specify a signature for the function?

wat? no that doesn't change anything. If you needed a type annotation with point-free style you need it in a pointful style too. It's exploiting a beta-equivalence of terms. If it confuses you don't bother doing it, it's more a style thing anyway.

s

Are there some functions where you can't use point-free notation?

man i'm not even sure I understand that question. here, this is what you gotta know if `f x ≡ g x` then `f ≡ g`, this is axiomatic.

I just don't understand how functions are evaluated if point-free notation is used.
How would abs(x) function look in point-free notation?

it's an equational thing, user. here's a different example map isDigit ≡ \xs -> map (\x -> isDigit x) xs In both cases we get a function which wants a list of Char's, and along the way we make use of another function that needs a single Char, but since, in both cases, the argument appears all the way on the right, we can drop the lambda completely.

here's a thing that probably won't help you understand anything:
blunt.herokuapp.com/#input=\xs -> map (\x -> isDigit x) xs

Well, example with map gives more clearance, but I'm not proficient Haskell, so I can't understand what -> mean.
Moreover, how guards are set if indentation is ommited?

up

Is little schemer good to read before HtDP? Will I just be wasting time learning shit I will learn anyways? My goal is to be able to at least fuck around and read real scheme programs pretty fast, so I stay interested, but go deeper in my learning with HtDP.

HtDP uses Scheme as a language to show principles, but Little Schemer is more about Scheme itself, so, if you want to practice Scheme, Little Schemer is a good choice.

Is it permissible to use LOOP in CLisp?

I'm the organizer of a functional programming meetup in my city. What should I do with it?

Bring beer

What the fuck are you doing?
/fpt/ is in here

/fpt/ is here

Reminder that OP made this thread well into the real thread because he was mad that he didn't make it this time

Reminder that thread is not real, because:
>no FP-related OP
>link to /dpt/ is given (no need since /dpt/ iterates faster)
>no Next-level programming thread
>no new resources added though there were marked ones
>Opinions listed in resources

>linking /dpt/ (despite always linking /fpt/ in /dpt/) is not allowed
>i didn't get the lisp reference so it's not fp related, even if it is programming related
>it didn't copy my OP posts word for word so it's wrong
>it didn't add resources, OP made a mistake so lets ignore the entire thread rather than simply adding resources as a post
>"Scala is shit" is an opinion

Wow, suddenly it all makes sense why you ignored 80 fucking posts and 30 different posters and decided to thread split two hours after the thread was made.
It's totally not like you wanted to be OP or anything.

>linking /dpt/ (despite always linking /fpt/ in /dpt/) is not allowed
/dpt/ OP doesn't link /fpt/
/fpt/ OP doesn't link /dpt/
New /dpt/ is created every 8-12 hours
New /fpt/ takes a half of week
How come you need to link /dpt/ since it's faster?
>i didn't get the lisp reference so it's not fp related, even if it is programming related
>himegoto
>lisp
Tell me more
>inb4 but muh brackets
>didn't copy my OP posts word for word so it's wrong
See above and below.
>it didn't add resources, OP made a mistake so lets ignore the entire thread rather than simply adding resources as a post
>given "Scala is shit"
If it were mistake, there would be no opinions
>"Scala is shit" is an opinion
>implying it's not
>you ignored 80 fucking posts
At the time it wasn't 80.
>It's totally not like you wanted to be OP or anything.
what

please respond

bump

Anyone got any links to open source project so using functional languages?

I'm ok with using FP for small Project Euler type stuff but for real world usage I can't see how FP is Moreno intuitive to use than non-FP styles.

How about xmonad?

Is there hentai of her?

Can we talk about functional programming language implementation?

How do you build a virtual machine for one? How do you optimize?

Haskell fags, this is actually retarded.
I know you have a raging hard-on for guards (and that's fine!), but that doesn't mean you have to write if statements like this.

Why can't picrelated just be like it is in all other sane languages:
pts :: Int -> Int
pts x =
if x == 1
then 10
else if x == 2
then 6
else if x == 3
then 4
else if x == 4
then 3
else if x == 5
then 2
else if x == 6
then 1
else 0

Or you can put "then N" on the same line as "else if". Anything but picrelated.
The Haskell wikibook is great and all, but this shit is ruining the whole experience.

I have no idea why they decided to do this.
You could also use the MultiWayIf extension

if | x == 1 -> a
| x == 2 -> b
| x == 3 -> c
| otherwise -> d

Tbh learning Haskell at the moment and think this is retarded as fuck. I like guards though

That's a teaching example for if expressions, you derps. Barring just using a Map, this is how you'd actually do it:

pts 1 = 10
pts 2 = 6
pts 3 = 4
pts 4 = 3
pts 5 = 2
pts 6 = 1
pts _ = 0

As I said, I don't care if you're supposed to use guards or pattern matching or whatever is best in that case. All I'm asking is why the fuck are ifs indented like that?

I see you've added the phrase 'pattern matching' to your argument.

Try this:

test x =
if x == 10
then 12
else if x == 12
then 10
else if x == 13
then 13
else 0

That's what he was arguing from the beginning

user, no.
Look at my original post. My code snippet works and looks like it's supposed to (with one level of indentation, not six). I'm wondering why does the code snippet from Haskell wikibook on that pic have six levels of indentation when only one is actually needed.

Never mentioned pattern matching.

This is a non-discussion; it essentially runs like so:
"Hey guys, I know I'm not supposed to do this, but why is it so ugly?"
"It's so ugly because you're not supposed to do it."

You've misunderstood him yet again

Yes, is ugly, but in the pic in it's a lot uglier, with insane indentation.

All of the examples in these two posts (there are three if you count the image) are ugly because you're not supposed to do it this way:

Just because it's not the best solution doesn't mean that we have to indent if statements in an absolutely insane way.
At least to me it seems insane. I'm very new to functional languages, so I was hoping somebody would explain that crazy indentation and maybe then it wouldn't look insane to me.

>"It's so ugly because you're not supposed to do it."
No, it's ugly because somebody indented it that way. Compiler accepts my version from the original post, yet the wikibook has insane indentation for some reason (which I'm trying to find out).

You're still missing his point, which is why are they indenting the if's that way?

>ugly because you're not supposed to do it this way
You've got it the wrong way round.
You're not supposed to do it that way because it's ugly.
And even then, that's because someone saw that it was uglier than it needed to be and added it in.

LOOP is a standard CL macro, therefore it should be implemented in CLisp.
clhs.lisp.se/Body/m_loop.htm#loop

>with insane indentation.
Can't you just put it in braces?

All of the syntax resulting from chaining a daft number of if expressions is ugly.

This is because you're not supposed to chain a daft number of if expressions.

You're supposed to go for cases, pattern matching, Map lookup, or similar: something that abstracts out the branching.

Are you just ignoring the discussion at this point?
I assume you know what we're actually talking about.

In functional languages there are opportunities to abstract out branching constructs like if expressions.

You should use them.

It seems like you're trying to avoid my question.

>All of the syntax resulting from chaining a daft number of if expressions is ugly.
Sure, I can agree with that. So we have to write them in the most ugly way that doesn't make any sense and wouldn't work in languages where indentation matters?

Ah, so that's a yes then.

You don't have to write them at all. You could just:

ifThenElse True x _ = x
ifThenElse False _ y = y

This is lambda calculus, you chumps. There's no need to run straight for the syntax involved in an 8-way if expression chain.

>Yes yes yes yes I am ABSOLUTELY avoiding the discussion!
so eager

i just want to fucking know why i constantly see haskell code where people are pressing their tab button way more times than necessary

don't (you) me if you don't know the answer to this particular question

You haven't posted anything relevant to the discussion in your last two posts.

Functional languages are a sequence of expressions, not statements. Graham discusses this difference in structure in 'On Lisp':
unintelligible.org/onlisp/onlisp.html

If you haven't noticed, there are no more '(You)'s, so I'm happy to oblige.

>You haven't posted anything relevant to the discussion in your last two posts.
you haven't posted anything relevant to the discusison since it started

I don't the question at all.
Is there the problem of having multilayered if-branches?
Should I use them?
Shouldn't I use them?
Can't I have multiple IFs not placed one in each other?
me confused

Is lisp worth learning? What is good about it?

For reference I've only got any experience in python, c, and visual basic

i'll go email a smart person. this fourchan thing isn't working out.

exactly.

>memeprogramming has its own stable thread

Here are your .d.o.t.s.

It has two threads. This one split from

You're still not actually contributing anything here. Don't you have a point to make?

>I don't the question at all.
Clearly.

If if expression syntax is completely redundant: as demonstrated, you don't need it in a lazy lambda language: you get branching for free. The only reason the syntax exists is to stop newcomers going 'where are my branching constructs?'

You *shouldn't* use extensively chained if expressions because there are much more elegant (pretty and simple) abstractions of branching that are far better suited for the job. Like: case, pattern matching, lookup.
The reason that the if syntax is ugly is because it *shouldn't be used in excess*.

And if you must, use multi-way if. But you're probably better off just using C instead.

Have fun.

>multi-way if
i.e. multiple IFs on one level?

I think the answer after all this is "there is no real reason"

MultiWayIf is a language extension that lets you chain if-elses with case syntax

i.e.

if | cond1
| cond2
| cond3

aka

if cond1 then
else if cond2 then
else if cond3 then

becomes

case () of
() | cond1 ->
() | cond2 ->
() | cond3 ->

See It's ugly as fuck.

>I think the answer after all this is "there is no real reason"
Because if that's the case, I'm going to go on a wiki edit spree and change every single one of those ugly ass snippets into something that makes sense.

>sarcasm

I wouldn't, it's entirely possible there's some archaic reason like "back in Haskell '98 this was necessary"

And I'm pretty sure that's a part of the reason (some minor googling led me to that conclusion). I just wanted to know why it was necessary back then.

How does it differ from guards then?

If you do that just make sure you get rid of all the redundant 'if' bollocks. It teaches newbies bad habits.

And makes them very confused, as we've discovered.

Very little. That's one of the reasons it's so ugly: it's very much non-orthogonal.

>How do you build a virtual machine for one
There was a talk given by Xavier Leroy (OCaml dad) about the implementation of functional languages, you could start with this.

it doesn't

>And makes them very confused, as we've discovered.
THE ONLY ONE CONFUSED IN THIS ENTIRE THREAD WAS YOU.
You still are, after all this. It's quite baffling. At this point I have nothing else left but to assume malice.

help
Moreover, are there any situations where you can't use point-free notation?

\x -> e
is a lambda
x is the parameter, e is the result

there are many cases where pointfree is inconvenient

>there are many cases where pointfree is inconvenient
Such as?

You seem to have decided to repeat "you're not engaging in the discussion" so much that you've been too confused to actually engage in the discussion, which I think is hilariously ironic.

...

Can you explain to me why the person that was writing code in that pic pressed tab six times instead of one?

Which one of them is the most suited for AI?

I've heard Lisp is pretty good for that (something about it being simple to write programs that write themselves in Lisp). But that was decades ago, I'm not sure it's still used in the industry to this day.

That's good indentation style for if-expressions.

It looks daft for six 'if's in a row because six 'if's in a row is a daft thing to do.

Haskell is a functional language. Functional languages are built from expressions, whose arguments determine indentation level. The 'if' syntax in Haskell is just syntactic sugar for a function of three arguments.
This is in contrast to imperative languages, whose block-like structure is reflective of their construction from series of statements.
Once again, Graham discusses this in On Lisp: I've posted a link above.

It's really not that confusing:
functional languages =
look like $ this $
for example

they are structured =
from functions $
whose arguments
determine indentation level


imperative languages;
are a series;
of statements;
broken (into) {
blocks like this;
which reflects;
their construction;
}

>The 'if' syntax in Haskell is just syntactic sugar for a function of three arguments.
At this point I don't even care if this isn't true (I couldn't get a concrete answer from REPL with :info if, so I'll just trust you). This explanation makes vague sense to me as a beginner, so I'll accept it as truth.
Thanks.

:info
only works on in-scope variables, not keywords
there's a request on GHC's trac to add a :binfo (:beginnerinfo)

It is.
It's also used a lot for computational linguistics (along with prolog), and a lot of that is how easy it is to make grammatical tree structures for evaluation.

I remember a woman making a massive neural net for translating proverbs. It was pretty cool, and it was made in Common Lisp.

Well, if in Haskell can be a function because of lazy evaluation.
You could have a weird as fuck imperative language doing that too. It would not be a good language, but it would be possible.

That's because 'if' is *syntax*, not a function per se. Try playing around with this:

myIf True y _ = y
myIf False _ z = z

It's a branching construct (like if-then-else), but defined as an actual function (rather than just syntax). It will work exactly like if-then-else syntax, bar the fact that you need to parenthesize the arguments (since with the syntactic version, the keywords separate out the arguments).

myIf (0 == 1) "TRUE!" "FALSE!"
if 0 == 1 then "TRUE!" "FALSE!"

This demonstrates the redundancy of the keyword version. As I said earlier, I'm pretty sure it was just put in in order to stop newbies asking "where's 'if'?".

Furthermore, now that you see it's basically just an ugly function, you understand why it's good style to indent the arguments: because that's what you do to functions.

See >you don't need it in a lazy lambda language: you get branching for free
I think we're making the same point here.