Haskell

What the fuck is this

Attached: fucking_monads.png (237x125, 964)

Other urls found in this thread:

learnyouahaskell.com/syntax-in-functions
youtube.com/watch?v=b0EF0VTs9Dc
twitter.com/SFWRedditImages

Disgusting.

(>>=) :: Monad m => m a -> (a -> m b) -> m b

A really sad face.

it's programming for solution spaces and not solutions
it's thinking about what you want to do before you do it instead of blindly typing line after line of spaghetti code without sleep

Attached: ConEmu_2018-12-14_21-38-27.png (301x37, 2K)

kys windowsfag

Attached: 1457118967529-0.png (250x250, 38K)

I can't tell you what it is but I can tell you what it's called. It's the bind operator.

Just [1,2,3] >>= \x -> return $ x >>= \y -> return $ y + 1
Just [2,3,4]

So it's basically just ∘?

No, that's (.) :: (b -> c) -> (a -> b) -> a -> c.

It's the bind operator

Attached: 1427411607620.jpg (1024x734, 147K)

[Just 1, Nothing, Just 3] >>= \x -> return $ x >>= \y -> return $ y + 1
[Just 2,Nothing,Just 4]

Dear god that’s ugly.

Just [1,2,3] >>= \x -> return [y *2 | y

It’s really not. It takes a monad A, and a function which takes an A and returns a monad B, it then evaluates the first argument and passes it to second, and returns the monad B.
Just don’t ask me what a monad is tho, I still haven’t figured it out.

No it's beautiful. Everything about it.

>it then evaluates the first argument
It actually doesn't. It enforces the order of monad operations, but it doesn't force evaluation of values inside the monad unless they are needed.
pure undefined >>= (const $ pure 1)

it can be thought as an algebra which define the operations
(>>=) :: m a -> (a -> m b) -> m b
(>>) :: m a -> m b -> m b
return :: a -> m a

which have the properties:
return a >>= k = k a
m >>= return = m
m >>= (\x -> k x >>= h) = (m >>= k) >>= h

Just think of it as a monoid in the category of endofunctors :^)

I like how you can tell what OS he is using just from the font rendering

Or a composition of adjoint functors :^)

What’s a functor?

what's an algebra?

monads are like, they're, monads... man

>What the fuck is this

A very sad face

Sitting in front of a computer making the elon musk face for ten minutes before I type a single character.

My favorite meme

Attached: A3A3F21A-E3E3-467E-9453-D5A6457BDD41.png (1000x1500, 494K)

Why is haskill using a common operator across all languages for something different?

Is this language for autists?

Attached: 1542448966689.jpg (1533x1015, 198K)

Try:
(.:) :: (c -> d) -> (a -> b -> c) -> a -> b -> d
(.:) = (.).(.)

Because bitwise operations have no business being operators in a modern high level language.
Also because it triggers the C fags.

banned on 4channel

>bitwise operations have no business being operators in a modern high level language.
yeah it sure sucks being able to check 64 flags in one operation what of language would need something like that

kek

A burrito.

That’s what a pattern match is for friendo.

what the fuck is a pattern match and how is it better than a bitwise operation

If your language requires this for efficiency checking 64 flags, then your language is old.

Could someone explain to me the benis operator? what's its type signature?
8===D

>literally just map(lambda x: x*2, range(1,11))
wowie haskell is so cool

>If your language requires this
it's a basic operation of your processor
why would you layer an abstraction ontop of a simple math operation? is binary too hard for you?

(8===D) :: Benis -> Vagene -> Fugg :DDD

Its the ability to match the form and contents of data based on whatever criteria you want.
learnyouahaskell.com/syntax-in-functions

so is that just a switch case or am i missing something

>just replace flags/bitops with pattern matching!
Are you under 18 by any chance

Its not hard, its just pointless. If your work requires bitwise operations, then Haskell would be an awful choice regardless for many reasons. So why bother?

>its just pointless
the point is you can check 64 bools in one operation
thats useful nearly anywhere

Switch only works on integers. Pattern matching works on anything and allows equalities on the form of data in addition to its contents.

>Switch only works on integers
which ancient language are you thinking of?
leave it to Haskell to rename a basic programming construct and act like its a new invention

the point is that it allows you to remove structure and then recreate it easily.. like

Then what language do you want to talk about. I assumed the C switch statement because you seem to be in love with binary operators.
If your language actually does support pattern matching in the switch statement, then you are a fool for still using binary comparisons.

I didn't even know there were languages that only supported int switches
Nobody is a fool for using binary operators when you can do what would normally take 64 operations in 1
You'd be a fool not to include them in a language

>If your language actually does support pattern matching in the switch statement, then you are a fool for still using binary comparisons.
Depends. Embedded I/O absolutely requires bit ops to be performant
t. embedded dev

>I didn't even know there were languages that only supported int switches
Yes, obscure languages like C, C++, Java, C#. Although the latter three have been implementing pattern matching features in the last few years because it is silly not to.

>monads

Attached: screams internally.gif (384x288, 433K)

Agreed. But you would also never write anything embedded in Haskell because its lazy and garbage collected.
My point is the domain of Haskell has no common need for binary operations.

well in the obscure shitty languages i use I can use any form of expression and they didn't need to give it a pretentious new name like 'pattern matching'

In dis he explains how to do the bind operator in javascript:

youtube.com/watch?v=b0EF0VTs9Dc

Attached: 1443284860036.png (540x354, 179K)

>I didn't even know there were languages that only supported int switches
Not only does C require `case` labels to be integer constants, it requires their values to be known at compile-time

digraphs > trigraphs

You can tell because the name of the screenshot is ConEmu

The symbol of an unemployable PhD student who studied a useless area of computer science and cannot get a real job working with real programming languages because all they know is a language with lazy evaluation, a inefficient memory model, and no strings.

>no strings
C doesn't have strings either, so it's in good company.