Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

the point of functional programming is to not program functionally

Name: Anonymous 2017-11-28 10:34

closures so you can have state
monads in haskal so you write imperative-like pipelines
progns in lisp so you can evaulate for side effects instead of value

Name: Anonymous 2017-11-28 19:50

Ok.

Name: Anonymous 2017-11-29 7:20

monads in lisp

Name: Anonymous 2017-11-29 7:36

>>3
trivial to implement, although not really needed in clojure and racket as you can use threading macro for pipelines. non-pipeline usage of monads (exception handling, state encapsulation, I/O) are adequately handled in lisp-native ways

Name: Anonymous 2017-11-29 8:05

trivial to implement
Indeed, which makes me wonder why don't more people use them.

you can use threading macro
Monads are not just (f . g . h) x

handled in lisp-native ways
Which happen to be extremely shitty ways. There is no reason for the standard to define exception handling if it can be defined by the user in a saner way.

Name: Anonymous 2017-11-29 8:52

>>5
people don't use monads in lisp because it's not idiomatic. I kinda wish it was but idiom inertia is a thing. I'm actually surprised that of all the languages, it seems that Java is embracing monadic style (even though they're not doing that in a consistent way)

as for exception handling, I actually like the CL style. on the other hand, I'm not a fan of Scheme's reliance on call-cc and would rather use Maybe monad

Name: Anonymous 2017-11-29 11:11

it seems that Java is embracing monadic style
Would you mind elaborating? I tried to avoid Java just like the devil avoids the cross ever since we had it as a module in uni.

Name: Anonymous 2017-11-29 11:46

>>7
basically, Java 8 introduced several FP concepts like lambdas and higher-order functions (through @FunctionalInterface. in addition to that, some of the more popular monads were ported in an unfortunately inconsisten way: a Collection<> can be converted to Stream<> which is more or less a Free monad, allowing you to write pipelines which look like this reinterpretation of the classic HMA program:
private void hma(List<String> benis){
benis.stream() //turn into monad
.map ((s)->"HAX MY ANUS!") //map each s to output of lambda which turns them to "HAX MY ANUS!"
.filter((s)->s.startsWith("HAX")) //those filters, applied to results of map, are obvious now that you know lambda syntax
.filter((s)->s.contains("ANUS"))
.filter((s)->s.equals("HAX MY ANUS!"))
.forEach(System.out::println); //forEach is used to terminate a stream by evaluating a certain function for side-effects over the whole sequence
}

they also added Optional<> which is a lot like Maybe and Future<> which I don't think has a direct equivalent in Haskal due to its laziness.

now, the problem is that it's not consistent: e.g. while both Optional<> and Stream<> have map() and flatMap(), there's no way to write a function that would take any monad (e.g. through some kind of Monad<> interface). you must make sure it takes one of them. it's also inconvenient when you have a sequence of Optional<>s and want to use stream API on it as you must manually map()/filter() them twice (I think Java 9 will make it more consistent by allowing you to turn a Optional<> into a Stream<>, which would turn Stream<> into a general-purpose monadic type).

despite the inconsistencies, Stream API is kind of fun to use - especially when compared to standard ultra-verbose Java. I was pleasantly surprised when I had to work with a Java codebase at work because my previous experiences with the language were similar to yours.

Name: Anonymous 2017-11-29 12:17

>>8
>over the whole sequence
I mena
>over every element of the sequence

Name: Anonymous 2017-11-29 12:17

over the whole sequence
I mena
over every element of the sequence

Name: Anonymous 2017-11-29 13:23

>>9
Why don't you just edit your post, goy

Test Edited on 29/11/2017 13:51.

Name: Anonymous 2017-11-29 13:29

>>11
how to? I wrote edit:9 in email field but it just posted a new one

Name: Anonymous 2017-11-29 13:35

>>8
That's quite interesting, thanks.
I never understood the point of lambdas in Java, after all they could just make it an interface.

Name: Anonymous 2017-11-29 13:51

>>12
Probably pressed preview as well which removes it.

Name: Anonymous 2017-11-29 13:59

>>14
might be it

Name: Anonymous 2017-11-30 23:53

>>8
That's neat, but it definitely is verbose.

Name: Anonymous 2017-12-01 8:10

>>16
far less verbose than the usual java way though. mapping and flatmapping through collections turned into streams allowed me to drop thousands of LOC, and assigning lambdas to Runnables also helped (so I could create specialized objects on the fly instead of subclassing).

Don't change these.
Name: Email:
Entire Thread Thread List