#dev-general

1 messages ยท Page 481 of 1

prisma wave
#

lmao

old wyvern
#

Maybe we can replace that with another symbol?

#

@?

prisma wave
#

yeah

#

hmmm

#

add : Add a @ a -> a -> a

old wyvern
#

hmm

prisma wave
#

@ could also be used for pattern matching if we're copying taking influence from haskell

arctic juniper
old wyvern
#

how do you mean?

#

yes vr

prisma wave
old wyvern
#

๐Ÿ˜ฎ

#

yea thats lit

arctic juniper
#

stuff isn't in path

#

no it's pretty not lit

old wyvern
#

You'll need to add it to your path yourself

#

Theres instructions on the arch wiki

prisma wave
#

yeah ~/.ghcup/env needs to be added

old wyvern
prisma wave
#

i think it offers to do that for you if you install it with the shell script, but not if you used the aur package

old wyvern
#

ah

arctic juniper
#

also ghc isn't in path

prisma wave
#

that will be in /env too

arctic juniper
#

and what do I put there

prisma wave
#

i presume you know how to add a directory to your path

old wyvern
#

export PATH="$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH"

arctic juniper
#

.ghcup/env doesn't exist

arctic juniper
#

ah, thanks

prisma wave
#

oh wait yeah

old wyvern
#

if you have stack as well
export PATH="$HOME/.local/bin:$PATH"

arctic juniper
#

I have neither yet

old wyvern
#

download both

prisma wave
#

my bad, it's env on my machine but it did weirdness

arctic juniper
#

well hold on

old wyvern
#

ghcup has cabal

#

stack is on a separate package

#

stack-static

prisma wave
#

i usually use the shell script to isntall

#

which is slightly different it seems

arctic juniper
#

it just told me to upgrade ghc, jesus christ

old wyvern
#

lol

arctic juniper
#

time to download another 200mb

#

cya in a bit

prisma wave
#

๐Ÿฅฒ

#

what version are you on atm?

arctic juniper
#

was at 8.10.4

#

updating to 9.0.1

prisma wave
#

hmm

#

does vsc work with 9.0.1 yugi?

#

kali was having some issues with it the other day

#

although that was on windows

old wyvern
#

It gives a warning in the main file tho

#

but that should be fine

prisma wave
#

ah okay

#

cool

arctic juniper
#

downloaded, installing

prisma wave
#

excellent

arctic juniper
#
[ Warn  ] This is an old-style command for installing GHC. Use 'ghcup install ghc' instead.
[ Error ] Unable to find a download for the requested version/distro.```
prisma wave
#

stack-static is an aur package

arctic juniper
#

ah

#

why am I installing it through aur?

prisma wave
#

idk the exact reason but i think it's because it's kind of 3rd party

arctic juniper
#

okay got them installed

prisma wave
#

awesome

arctic juniper
#

lemme just add to path

prisma wave
#

might have done that for you if it's on the aur

arctic juniper
#

okay I think I setup the language server

#

how do I start a project?

prisma wave
#

you using VSC?

arctic juniper
#

nvim

old wyvern
#

stack new <Project_name>

prisma wave
#

ah nice

#

uh

arctic juniper
#

it made a bunch of stuff

prisma wave
#

yeah tbh, you might want to steer clear of the build tools for the absolute basics

old wyvern
#

now run stack setup

#

yea true

prisma wave
#

kinda overkill if you just want a hello world

old wyvern
#

maybe just use ghci

prisma wave
#

yeah

arctic juniper
#

200mb fuuuuuu-

old wyvern
#

No

#

just run ghci

#

you have it with ghc

prisma wave
#

ghci is the jshell to java

old wyvern
#

lol

arctic juniper
#

after stack new or?

old wyvern
#

leave that project for now ig

prisma wave
#

or delete it, whatever. you can just use a single file for now

arctic juniper
#

do I install ghci

#

hold on, ghc isn't in path

prisma wave
#

it's part of ghc

#

ah

old wyvern
prisma wave
#

okay so anyway, in FP you often program at a REPL as it's usually more convenient for hacking together stuff

#

the official repl is ghci

arctic juniper
#

ah I see why it isn't in path

#

there's no ghci or ghc bin, there are bins with a version

#

ghci-9.0.1 is a command

prisma wave
#

ah that's an issue i was having a while ago

old wyvern
#

There should be a alias

#

oh wait

arctic juniper
#

there should be or I should alias?

old wyvern
#

I know whats wrong

#

You didnt set the version

arctic juniper
#

yep probably it

prisma wave
#

can you do ghcup tui and make sure you've set the versions you have installed

arctic juniper
#

okay ran ghcup set 9.0.1

prisma wave
#

that should make the aliases

#

nice

old wyvern
#

alright, now it should work

arctic juniper
#

does

prisma wave
#

awesome

old wyvern
#

lit

prisma wave
#

okay so uh

arctic juniper
#

I have a shell thing now

prisma wave
#

what now

#

yeah that's the repl

arctic juniper
#

oh my god 9 + 9 works

prisma wave
#

incredible

arctic juniper
#

says 18

#

amazing

prisma wave
#

try putStrLn "hello world"

#

i bet you can't guess what that does!

old wyvern
#

sum [1..9]

arctic juniper
#

where are the parentheses

prisma wave
#

you don't write them

old wyvern
#

^

arctic juniper
#

is this ruby?

#

who stole them

old wyvern
#

Its used in multiple languages

#

lol

arctic juniper
#

sum [1..10000000] is slow

old wyvern
#

try sum [1,3..11]

prisma wave
#

in haskell (and other ML style languages) parentheses are to denote precedence, not for function application

old wyvern
arctic juniper
prisma wave
#

lmao

#

rip

arctic juniper
#

okay it works now

forest pecan
#

prolly cause memory limits

#

idk

#

lmao

#

that is 10 million

prisma wave
#

you can probably identify all the parts in that, [1..n] is a list between 1 and n, and sum is a function that... sums a list

arctic juniper
prisma wave
#

simple

arctic juniper
#

yeah I see

forest pecan
#

(10million * (10 million + 1) )/2

arctic juniper
#

does .. only work in the [] thingies?

prisma wave
#

yeah

old wyvern
#

those are lists

forest pecan
#

or 5,000,000 * 10,000,001

#

lmao

old wyvern
#

sum takes a list as input

arctic juniper
#

gauss shit

prisma wave
#

they're list literals, you can also do stuff like [1, 2, 4, 8]

arctic juniper
#

does .. have a step?

old wyvern
#
sum :: Num a => [a] -> a

is the type

prisma wave
#

or maybe it does do that

forest pecan
#

F

old wyvern
prisma wave
#

idk

forest pecan
#

so it doesnt use a formula?

#

lmao

prisma wave
#

probably not

arctic juniper
forest pecan
#

L

#

it should

prisma wave
#

dw about that

old wyvern
#

oh oops

#

fixed

#

sum :: Num a => [a] -> a

arctic juniper
#

is that a named return value?

old wyvern
#

no

prisma wave
#

in java terms that's <A extends Num> A sum (List<A>)

old wyvern
#

Thats a constraint

prisma wave
#

but dw too much about that for now

arctic juniper
#

ah

prisma wave
#

let's keep it simple

arctic juniper
#

so a is a type

prisma wave
#

okay so

#

yes, a generic type

arctic juniper
#

well not a type

#

Num is the type

#

a is of type Num

old wyvern
#

No

arctic juniper
#

no?

old wyvern
#

a is the type

#

Num is a constraint

prisma wave
#

num is a type constraint, kinda like an interface except more powerful

arctic juniper
#

right

prisma wave
#

in other words "a can be any type that implements the Num type"

#

anyway

#

so

#

we know how to use functions

#

time to make a function

#

double x = x * 2

#

try this

#

or that

old wyvern
#

^

prisma wave
#

lol

arctic juniper
#

weird syntax

#

makes sense

prisma wave
#

you get used to it

arctic juniper
#

works

prisma wave
#

and then naturally you can do double 3 etc

arctic juniper
#

yay

prisma wave
#

awesome

arctic juniper
#

uh so

old wyvern
#

now define another function

arctic juniper
#

double 3 + 5 does what

prisma wave
#

that won't compile i don't think

old wyvern
prisma wave
#

or maybe it will

#

ah yeah

arctic juniper
#

it compiles

#

and now you turned this into lisp

prisma wave
#

yeah function calling has the highest precedence

old wyvern
#

You will sometimes end up with lisp like syntax

#

lol

prisma wave
#

although not often

arctic juniper
#

5 + double 3

#

tada

prisma wave
#

nice

#

easy

forest pecan
#

are you guys converting someone to haskell?

#

๐Ÿ˜ฎ

prisma wave
#

yep

arctic juniper
#

converting?

forest pecan
#

how dare u

old wyvern
#

๐Ÿ˜Œ

old wyvern
arctic juniper
#

excuse me, I'm a catholic

prisma wave
#

also, cool bonus feature - when you're in ghci you can do :t x to find out the type of x

#

try :t double

arctic juniper
#

I am learning about your culture, not converting

forest pecan
#

lol

prisma wave
#

we'll see about that

old wyvern
#

You will convert soon dw

#

Once you have a bit, you cant have enough

arctic juniper
#

floats are fractionals?

old wyvern
#

Theres a distiction in haskell actually

prisma wave
#

yeah...

old wyvern
#

haskell has both fractional numbers and floating point numbers

prisma wave
#

decimal stuff is kinda messy sometimes

arctic juniper
#

pi is floating

arctic juniper
#

my 6.9 is fractional

obtuse gale
#

how does that work

#

like

#

yeah okay I get it nvm

arctic juniper
#

is fractional so you don't lose precision?

prisma wave
#

if it's rational it will be Fractional*

#

yeah

old wyvern
#

Depends on the type you operate on and the functions you use fefo

prisma wave
#

it's a bit confusing

#

anyway, you'll probably know this from rust and kotlin but in haskell, functions are values

arctic juniper
#

what's next

prisma wave
#

meaning they're no different to any other "variable"

#

you can pass functions to functions, functions can return functions, etc

arctic juniper
#

right

old wyvern
#

Fractional is just anything dividable generally I think

arctic juniper
#

is pi not divisible

old wyvern
#

It can be

prisma wave
#

confusing stuff

#

okay what next

#

Strings

#

they're pretty similar

#

exactly the same even

#

and of course you have Chars too

#

exactly the same syntax as any other language for those

arctic juniper
#

'E' :: Char

#

mmyes

prisma wave
#

in other words "'E' is of type Char"

obtuse gale
#

right?

obtuse gale
#

well numbers idk what you can do in haskell but hopefully you get what I'm trying to say

prisma wave
#

lol

arctic juniper
#

so what do I use when I want to deal with decimals?

prisma wave
#

generally i think you'd just let the compiler figure it out

arctic juniper
#

Rational?

prisma wave
#

i guess Floating is the "traditional" way, but im not sure what's conventional tbh

obtuse gale
old wyvern
arctic juniper
#

so how would I make a multiline function?

old wyvern
#

do blocks

prisma wave
#

good question

old wyvern
#

But

prisma wave
#

this is where ghci gets a bit annoying

old wyvern
#

Warning

prisma wave
#

you can't do multiple line stuff very well

old wyvern
#

those are syntax sugar, anything not part of the final result either as a value or as a bind will NOT be evaluated

prisma wave
#

lol

#

okay you might wanna switch over to an actual editor now, and make a new file

#

we'll have a look at do blocks

eternal flare
#

Minecraft on java 1.16 ๐Ÿ˜ถ

ocean quartz
#

Yasss

arctic juniper
#

initializing languageserver.haskell

prisma wave
#

๐Ÿ‘€

prisma wave
#

๐Ÿฅฒ

old wyvern
#

Ok mockito is just trolling now

#

Why does it say cglib is not on the classpath when its right damn there

#

๐Ÿฅฒ

prisma wave
#

classic

arctic juniper
#

Cannot find any haskell-language-server exe, looked for: haskell-language-server-9.0.1, haskell-language-server-9.0, haskell-language-server

#

f

prisma wave
#

f

#

wait

arctic juniper
#

I don't have it installed for 9.0.1

prisma wave
#

did you do ghcup set hls?

old wyvern
#

its

#

right

#

there

ocean quartz
#

๐Ÿฅฒ

old wyvern
#

ok screw this

prisma wave
#

ima keep typing while you try and figure it out - i could never get vim working but i also suck at vim so that might be why

arctic juniper
prisma wave
#

ah

old wyvern
#

is there any other framework that can mock with proxies?

ocean quartz
arctic juniper
#

I guess I'll just go back to 8.10.4

prisma wave
#

that's similar to the problem kaliber was having a while ago

old wyvern
prisma wave
#

yeah that's probably best

#

you're not gonna be missing much

#

okay so, in haskell every function is a single expression. there are no "blocks", just expressions.
however as you might expect this can get a bit annoying, so there's a syntax sugar called "do blocks" that replicate an imperative {} block

arctic juniper
#

okay it loaded in like a second

prisma wave
#

great

#

all working now?

arctic juniper
#

waited for 2 minutes straight before

#

coc didn't tell me anything was wrong

prisma wave
#

good enough

ocean quartz
arctic juniper
#

okay yep works

prisma wave
#

okay so let's start with the main function actually, you've already seen putStrLn "hello world", but that only evaluated in the repl

arctic juniper
#

yes

prisma wave
#

like most languages we have a main function

arctic juniper
#
main =
    putStrLn "hello"```
#

dis?

prisma wave
#

yup

arctic juniper
#

yay I guessed it

prisma wave
#

conventionally you'd put that on the same line

#

but sure

arctic juniper
#

what if I want more lines?

old wyvern
prisma wave
#

that's when do blocks come into play

arctic juniper
#

how do I close a do?

prisma wave
#

try this: ```hs
main = do
putStrLn "hello"
putStrLn "world"

ocean quartz
old wyvern
#

welp

arctic juniper
#

okay it compiles

#

but what's the point of do if I don't close it?

obtuse gale
prisma wave
arctic juniper
#

ah

old wyvern
#

๐Ÿฅฒ

ocean quartz
prisma wave
#

you can technically use braces if you want, it's just not generally done

#
main = do {
  putStrLn "hello";
  putStrLn "world";
}
#

this is also valid

arctic juniper
#
  { haCharBuffer :: IORef (...something...)
  , haBuffers :: IORef (...something...)
  , haBufferMode :: BufferMode
  }```commas before the line??
prisma wave
#

o_O

#

yes generally

arctic juniper
#

w- what

old wyvern
#

Except thats not the convention ๐Ÿฅฒ
Prepare to be horrified

#
main = do 
  { putStrLn "hello"
  ; putStrLn "world"
  ; }
prisma wave
#

the conventions for spacing and things are definitely a little different

old wyvern
#

yea

prisma wave
#

yes ๐Ÿฅฒ

arctic juniper
prisma wave
#

but im not sure it can be considered a convention if nobody actually writes it like that

ocean quartz
#

Who created that convention? i need to have a talk with them

old wyvern
#

They do use that I think

prisma wave
#

i mean usually you're not using braces or semicolons

#

but anyway

arctic juniper
#

thank fuck

prisma wave
#

@arctic juniper try putStrLn 3

#

in a repl if you want

old wyvern
#

ah

arctic juniper
#

not working

prisma wave
#

yup

old wyvern
#

Because Int is not a ...

#

String!

prisma wave
#

indeed

old wyvern
#

Anything the derives Show provides a show function

obtuse gale
#

OH MY GOD

old wyvern
#

Which can "Stringify" it

obtuse gale
#

gradle 7 for fabric mods UJFDSUOJSDNBJLOS

arctic juniper
prisma wave
#

putStrLn :: String -> IO () this is the signature of putStrLn - it takes a String, and returns an IO () (which we'll get to in a minute)

old wyvern
#

xD

#

putStrLn (show 3)

#

try that ^

arctic juniper
#

what the

prisma wave
#

show is roughly analogous to toString

old wyvern
#

we'll remove the paren soon

#

dw

arctic juniper
#

works

old wyvern
#

ok

#

now

arctic juniper
#

I removed the parentheses, it doesn't work

old wyvern
#

to save yourself from parenthesis hell

#

We have custom operators

#

Haskell has one defined in the base class to apply an argument

prisma wave
old wyvern
#

This is for a single argument and so can only be used for the last argument

prisma wave
#

whereas what we want is putStrLn(show(3))

old wyvern
#

its the $ operator

#

so you have
putStrLn $ show 1

#

try that

arctic juniper
#

shows a warning

old wyvern
#

It simply takes whats on its right, and applys its to the function on the left

arctic juniper
#

tells me to use print 1

prisma wave
#

indeed

old wyvern
#

Yea, thats a function that prints with show

#

This was an example to use $

prisma wave
#

that's kinda verbose so there's print which is a combination of putStrLn and show

old wyvern
#

brb

arctic juniper
#

how do multiple args work?

prisma wave
#

just spaces

#
add x y = x + y

add 3 4
arctic juniper
#
add $ add 1 2 $ add 3 4```
#

would this do what I think it would?

prisma wave
#

i dont think so, this is where it can get a bit confusing

#

actually maybe

#

try it

#

i don't think it will

arctic juniper
#
add(add(1, 2), add(3, 4))```
prisma wave
#

add (add 1 2) (add 3 4) this will work

#

we can't use commas

#

they are for tuples

arctic juniper
#

add x y doesn't compile

prisma wave
#

you need the body

arctic juniper
#

I have it

prisma wave
#

oh?

#

what have you got rn

arctic juniper
#

oh do I put the add outside of main?

#

yeah the thing doesn't compile

#

lemme try parentheses

prisma wave
#

yeah outside of main

#

you can nest functions, but that has a slightly different syntax

arctic juniper
#
    print $ add (add 1 2) (add 3 4)
prisma wave
#

that should work

arctic juniper
#

it does

prisma wave
#

awesome

obtuse gale
#

what kind of chain rule is that lol

arctic juniper
#

weird and confusing

prisma wave
#

heh

#

okay

#

now for the real mind-blow

#

go into ghci, define add again and then check the type of add

arctic juniper
#

fuck

#

a -> a -> a

prisma wave
#

it should be something like (Num a) -> a -> a -> a rigth?

#

okay

arctic juniper
#
add :: Num a => a -> a -> a
obtuse gale
#

loll

prisma wave
#

that looks a little intimidating

#

but

arctic juniper
#

looks very intimidating

prisma wave
#

it's actually quite simple

arctic juniper
#

I want to kill it

prisma wave
#

in haskell functions only have 1 parameter

arctic juniper
#

they what

prisma wave
#

if you have functions with multiple, that's just a function that returns a function

#

and so on

arctic juniper
#

oh makes sense

#

hold on

#

so

#
add(1)(2)```
#

in a normal language

prisma wave
#

precisely

#

are you familiar with the concept of "currying"?

arctic juniper
#

I know what curry is

prisma wave
#

also known as "partial application"

#

๐Ÿฅฒ

arctic juniper
#

currying is the process of applying curry to food?

prisma wave
#

close enough

#

anyway, what this funky parameter stuff means is that we don't need to provide all of the parameters to a function

#

so for example, we can do add 3

arctic juniper
#

oh

prisma wave
#

which in turn returns another function

arctic juniper
#

so that returns a function we can use later

prisma wave
#

exactly!

arctic juniper
#

similar to julia

prisma wave
#

oh does julia do that too?

arctic juniper
#

yeah some functions return a function if you don't supply all params

prisma wave
#

ah cool

#

yeah, super common pattern in FP

#

i was gonna explain where it might be useful but im guessing you already know

arctic juniper
#
julia> ==("69", "69")
true

julia> ==("69")
(::Base.Fix2{typeof(==), String}) (generic function with 1 method)
#

I have no clue where that could be useful

prisma wave
#

ah yeah exactly the same thing

#

okay

#

well

#

you're familiar with map and filter right?

arctic juniper
#

yes

#

ohh

#

yep

prisma wave
#

hehe

arctic juniper
#

I see

prisma wave
#

yup

arctic juniper
#

filter(==("69"), arr)

prisma wave
#

exactly

arctic juniper
#

in julia

prisma wave
#

in haskell that would be filter (== "69") arr

arctic juniper
#

is equivalent to filter(x -> x == "69", arr)

prisma wave
#

so almost exactly the same

arctic juniper
#

nice

#

well anyway

#

thanks for the help

prisma wave
#

lol no problem

arctic juniper
#

it's getting late and I haven't showered in 3 days

prisma wave
#

๐Ÿฅถ

#

fair enough

#

if you decide to carry this on feel free to ping me if you have any questions

arctic juniper
#

actually gonna go a bit later

prisma wave
#

this is just the tip of the iceberg of all the fancy stuff haskell has

#

๐Ÿ‘€

arctic juniper
#

so you told me all about functions and all that fancy stuff

prisma wave
#

yup

arctic juniper
#

but what about if statements

prisma wave
#

no statements, only expressions

arctic juniper
#

right

prisma wave
#

the difference being that an if requires an else

arctic juniper
#

it what

prisma wave
#

so it can evaluate to some value

arctic juniper
#

right

#

why does it evaluate to a value

prisma wave
#

because everything in haskell is an expression

#

and the definition of an expression is something that evaluates to a value

arctic juniper
#

does haskell have no void type?

prisma wave
#

it does

arctic juniper
#

do functions with 0 params exist?

prisma wave
#

kind of

#

values are functions with 0 params

arctic juniper
#

eh?

prisma wave
#

because haskell does lazy evaluation

arctic juniper
#

ah

prisma wave
#

so you can do blah = print 3 and that won't actually print anything until you try and get the value of blah

arctic juniper
#

wait

#

yeah that's weird

prisma wave
#

it is a bit weird

arctic juniper
#

and it evaluates how many times?

#

how do I define a var?

prisma wave
#

that is an interesting question

#

technically it just evaluates once

prisma wave
arctic juniper
#

in main

prisma wave
#

ah

#

let name = value

arctic juniper
#
    let test = print 69
```this doesn't work until I access test
prisma wave
#

yeah

#

that line alone won't print anything

#

because it doesn't evaluate until it's forced to

arctic juniper
#
    let test = print 69
    test
    test```this prints twice
prisma wave
#

ah yes

#

there is a reason for that

#

it's just kinda hard to explain

arctic juniper
#

it's like a weird ass macro

prisma wave
#

basically, to keep functions pure, stuff like print don't actually print anything, they just return a value that describes some IO.
so it's returning the same value every time, but the do block is executing the IO twice

#

print doesn't actually print anything, it returns a value that's sort of like a list of instructions on what IO to do in order to print that value

arctic juniper
#

why is it executing the value?

prisma wave
#

because the do block assumes you want to execute it

arctic juniper
#

oh is test like a 0 param function now?

prisma wave
#

kind of

#

this is quite a tricky concept

#

but it will make sense

#

it's probably best not to worry about that for now

#

for all intents and purposes, it's a 0 param function

arctic juniper
#

no no

#

it's nothing for now

prisma wave
#

lol

#

ยฏ_(ใƒ„)_/ยฏ

#

basically, haskell wants every function to be pure, so it doesn't actually do any IO, it just describes the IO to do, and then the compiler bundles that up and does evil wizardry to perform that IO

#

the language stays pure, but it can still do IO

cinder flare
#

might as well rename this channel to #intro-to-haskell

prisma wave
#

yes

#

do it

arctic juniper
#

Tomorrow at 00:00

cinder flare
#

im kinda diggin it though

#

just following along after

#

makes actually a bit of sense

#

hey do you know how to do infinite lists BM

prisma wave
#

yes

cinder flare
#

what's up with those

prisma wave
#

wdym

cinder flare
#

what are they used for

prisma wave
#

hmm

#

they are somewhat niche

cinder flare
#

but super cool!

prisma wave
#

but usually number generating stuff

arctic juniper
#

how do you get all odd numbers

cinder flare
#

oh I see like a number generator is just an infinite list of all possible numbers generated?

prisma wave
#

yeah

#

if you wanted to generate a list of all primes, a naive but functional implementation would be filter isPrime [1..n]

cinder flare
prisma wave
cinder flare
#

lol

arctic juniper
#

OH

#

I just realized

#

.. continues the whole thing, not just the last element

prisma wave
#

yup

arctic juniper
#

damn

#

what if I...

#

[1, 1, 2, 3, 5, 8..]

prisma wave
#

sadly it's not that sophisticated

#

it can do arithmetic progressions

#

not much more than that

arctic juniper
#

ah

#

sad

cinder flare
#

{2n โˆ’ 1 | n โˆˆ N}

#

now that's set theory baby

arctic juniper
#

is that valid haskell

cinder flare
#

no

#

that's set theory

prisma wave
#

probably valid julia lol

arctic juniper
#

well โˆˆ is a thing in julia

#

and 2n is a thing in julia

cinder flare
#

โˆˆ means is an element of in set theory

prisma wave
#

you could do an infinite list of all fibonnacci numbers with some recursion magic

cinder flare
#

2n is just multiplying n by two lol

arctic juniper
#

but | is just binary or

cinder flare
#

| means such that

prisma wave
#

shame

cinder flare
#

you read that statement as: 2n -1 such that n is an element of all natural numbers

#

so basically every odd number

arctic juniper
#

main :: IO somethingwat

prisma wave
#

Ah you've discovered the IO monad

cinder flare
#

haha monads go brrr

prisma wave
#

Now we're cooking with gas

arctic juniper
#

I haven't discovered shit, I just googled how print works

cinder flare
#

gas

prisma wave
#

Lol

arctic juniper
#

btw, what's haskell used for?

prisma wave
#

Quite a lot

#

It's definitely traditionally used for academia

#

But Facebook uses it for spam detection, GitHub uses it for language parsing

cinder flare
#

yeah as I said it's really good at expressing set theory and category theory lol

#

type theory too

prisma wave
#

It's gaining more adoption

#

But yes the original use case was definitely just for nerdy professors to experiment with complicated mathematical ideas

#

Which sounds pretty fun tbh

arctic juniper
#

it's gaining more adoption? isn't it half a century old?

cinder flare
#

hey im a nerdy normal person, not a professor

cinder flare
prisma wave
#

Or around that time

#

93 maybe

cinder flare
#

yea a lot of langs came out early 90's

arctic juniper
#

ah it is 1990

#

thought it was older

prisma wave
#

Ah close enough

#

FP is definitely older

cinder flare
#

ML go brrrr

prisma wave
#

I mean lisp was like 1958 or something

arctic juniper
#

ml is what

prisma wave
#

Maybe 61

cinder flare
#

ML is the precursor to Haskell

arctic juniper
#

what does ml stand for

cinder flare
#

1973 phew

#

Meta Language

#

technically OCaml, Standard ML, and F# are all ML bois

prisma wave
#

There were quite a few functional languages in the 70s and 80s, until they realised that there were too many languages to learn so they all sat down and made Haskell

#

That's not a joke

#

Pretty much what happened

cinder flare
#

ooh ML influenced Kotlin and Rust!

#

and C++

#

and Coq, nice

prisma wave
#

ML was pretty influential afaik

#

That and Lisp were like

#

The big 2

#

Back in the day

arctic juniper
cinder flare
#

awe man what a time to be alive

prisma wave
#

Not that I'd know

cinder flare
arctic juniper
#

hmm

obtuse gale
#

u horny ass

cinder flare
#

oy

obtuse gale
#

lmao

cinder flare
#

is it cause I mentioned C++

arctic juniper
#

blyat

cinder flare
#

it summoned you out of your cave

arctic juniper
#

tf2 guy

#

you alive?

obtuse gale
#

lol not because of that, no

prisma wave
#

Ofc

cinder flare
#

tf2 guy

#

my hero

obtuse gale
prisma wave
#

lmao

#

That's not even an exaggeration

arctic juniper
#

so we stopped at the io thing

#

what's next

prisma wave
#

Ah yeah

#

Uh

arctic juniper
#

monads?

cinder flare
#

woah have you guys heard of Cyclone

#

it's like C but they made it harder to fuck yourself

prisma wave
prisma wave
cinder flare
#

yeah

arctic juniper
#

I don't like when they make it hard to fuck yourself

cinder flare
#

bro go back to writing ASM then

arctic juniper
#

if I want to fuck myself I will do it and nobody will stop me

prisma wave
#

Damn right

arctic juniper
cinder flare
#

oooh that's cool

#

x86 I presume?

arctic juniper
#

nasm

cinder flare
#

nice

prisma wave
#

Okay I am gonna go to bed pretty shortly but I will try and briefly explain the IO monad (or at least the idea behind it)

arctic juniper
#

network assembly I think is what it stands for

cinder flare
#

Netwide Assembler apparently

arctic juniper
#

close enough

cinder flare
#

so this is... portable ASM?

#

that's kinda weird

old wyvern
#

back

arctic juniper
#

but anyways, I tried making a simple tcp server

#

then it decided to not work

old wyvern
#

how far did you get vr?

cinder flare
#

in ASM? holy cow

arctic juniper
#

the literal equivalent in c did work

#

so I was left confused

#

it didn't error, it just returned

#

weird stuff

#

well not returned, ran the whole thing

#

without error

#

also debugging assembly is a pain in the ass

#

especially without libc

old wyvern
prisma wave
#

this is what I was talking about earlier where we have an abstraction that describes some IO to do. The main function says "this is a list of the IO I would like to do", and the compiler turns that into evil unsafe code.
This is expressed through the type IO a which basically represents some IO operation that returns an a

So print and putStrLn are IO () because they're an IO operation that returns no meaningful value (() is the void type, known as "unit")

old wyvern
cinder flare
#

yugi really going back through the message history and commenting

prisma wave
#

similarly we have other IO functions like getLine (gets a line from standard input), this returns an IO String

old wyvern
#

Yea

cinder flare
#

also Wikipedia does not list Elm as an ML boi

old wyvern
#

Elm is afaik

cinder flare
#

it was influenced by

#

but it's not a dialect

old wyvern
arctic juniper
#

hmm well it is kind of confusing

cinder flare
#

yeah influenced

old wyvern
#

Even haskell was "influenced by"

cinder flare
#

not part of

#

ofc haskell was influenced by

#

ML was the baby version of haskell

old wyvern
#

Its literally the same syntax as haskell

arctic juniper
#

can you print inside another function?

old wyvern
#

It only lacks custom monads

prisma wave
#

Yes, but that function has to return an IO value

old wyvern
#

Elm is actually pure

arctic juniper
#

oh

cinder flare
#

yeah ML isn't 100% pure

arctic juniper
#

what if I want to return another value?

cinder flare
#

it allows unsafe stuff

old wyvern
#

Ofc, Elm isnt a complete ML ripoff

#

I just meant it shares the same elements haskell does from ML

prisma wave
old wyvern
#

or atleast most of it

arctic juniper
#

if I have a function that prints 69 and returns 420

cinder flare
#

nice

prisma wave
#

So something like ```hs
funny = do
print 69
return 420

arctic juniper
#

yes

#

that works

prisma wave
#

This would have to return an IO Int

arctic juniper
#

IO Int?

cinder flare
#

combo types!!!!

prisma wave
#

Because it's an IO operation that eventually returns an Int (420)

old wyvern
#

IO is also a constraint

#

imagine it similar to how a Future works

cinder flare
#

what if I don't know how a Future works either ๐Ÿฅฒ

arctic juniper
#

wait can I run any function that doesn't return IO in main?

old wyvern
#

Haskell itself does not read or write anything, so it needs to compose IO Actions to create the sideeffects

prisma wave
#

Yes

arctic juniper
#

I can't run add

old wyvern
#

IO functions can only eb called in IO functions

#

Except a few cases wher eyou can lift em with transformers

#

but the general rule stands

prisma wave
old wyvern
#

You need an instance of MonadIO

#

^

prisma wave
#

yugi you might be overcomplicating this a little

old wyvern
old wyvern
prisma wave
#

Yeah you have to bind it with a let binding, or not call it at all

arctic juniper
#

doesn't binding just not run it at all?

cinder flare
#

oh snap he's got a point

prisma wave
#

It will run it if you force it to evaluate

cinder flare
#

lazy evaluation biting oyu

old wyvern
#

Wait

#

What exactly were you running vr?

prisma wave
#
main = do
   let res = add 3 4
   print res
#

This works as you might expect

arctic juniper
#

so say I got this

#
add x y = x + y

main = do
    let poo = add 69 420

    print "ha"```
#

this works fine

#

but add will never actually be called

old wyvern
#

Mhm

prisma wave
#

right

cinder flare
#

print poo

old wyvern
#

Everything is evaluted only when it needs to be

arctic juniper
#

and I can't just put poo on the next line, it won't work unless I print it

prisma wave
#

the thing is, because add is pure you won't actually know that it doesn't get called

#

there's no noticeable difference

arctic juniper
#

well yes, but I will know

prisma wave
#

Indeed

obtuse gale
#

sounds like a functor to me ๐ŸŒš

arctic juniper
#

a what now

prisma wave
old wyvern
#

lol

#

functor is just fancy for function

#

dw

arctic juniper
#

do you call a functor or is there a fancier word?

obtuse gale
#

an object that can be treated as a function

#

or smth

prisma wave
#

is it really

cinder flare
#

this is why we stay in haskell land

old wyvern
cinder flare
#

no weird C++ shit

old wyvern
#

But

#

Assuming you are sane

#

And havent started circlejerking

#

lets just go with function

prisma wave
old wyvern
#

๐Ÿฅฒ

prisma wave
#

anyway, Vr the reason you can't just do poo is because of what do blocks compile to

arctic juniper
#

what do do blocks compile to?

prisma wave
#
main = do
    print 3
    print 4

This gets translated to ```hs
main = print 3 >> print 4

arctic juniper
#

?

prisma wave
#

Yeah

arctic juniper
#

well yeah

#

what is >>

prisma wave
#

It basically takes 2 IO actions and turns them into 1

cinder flare
prisma wave
#

it's like .thenRun with a CompletableFuture or something

arctic juniper
#

what happens to bindings?

prisma wave
#

they get inlined I believe

#

So your poo example becomes ```hs
main = print (add 69 420)

arctic juniper
#

wouldn't that call the function multiple times?

prisma wave
#

potentially

#

Potentially not

#

It's up to the compiler

arctic juniper
#

what now

obtuse gale
#

and no I don't know haskell lol

cinder flare
#

ah nice

prisma wave
#

We generally don't worry about it, because the compiler can determine whether it's worth caching or not

#

this kinda what yugi was saying earlier, how you don't need to think about performance much

#

because the compiler is able to do a lot of the optimisations for you

arctic juniper
#

so can I think of bindings as kind of #define?

prisma wave
#

they usually act in a similar way yeah

#

But they might not, as far as I know that's an implementation detail

arctic juniper
#

ya know

#

I thought the g in ghc was gnu

prisma wave
#

lol

#

it uses bsd I think

arctic juniper
#

so, what's a monad?

gusty glen
prisma wave
#

๐Ÿ˜ฑ

arctic juniper
#

uh

prisma wave
#

It is getting pretty late so I don't think I can explain that now

arctic juniper
#

you mean early

prisma wave
#

But an oversimplified explanation would be "an abstraction over a value"

prisma wave
#

11:35 pm for me

arctic juniper
#

ah

#

I'm an hour ahead

prisma wave
#

Ah nice

#

Okay I should probably be heading off

obtuse gale
prisma wave
#

Adios

obtuse gale
#

chao

arctic juniper
#

cya

#

you free tomorrow?

gusty glen
#

I just call monad a thing that has flatmap, which is just lazy operations over the wrapped object, plus flattening the object later (if I'm not mistaken here)

prisma wave
#

The only thing stopping me from talking about Haskell 24/7 is school and "sleep"

#

Quite unfair imo

arctic juniper
#

okay I just realised I forgot to do something I should've done 3 hours ago

prisma wave
#

uh oh

arctic juniper
#

no, not 3, 5 hours ago

prisma wave
#

๐Ÿฅถ

arctic juniper
#

meh fuck it I'll do it tomorrow

#

well today

distant sun
prisma wave
#

WHAT

arctic juniper
#

why do I have to bring papers physically

#

I have a phone with a camera

#

I want to die

#

cya

#

gn

obtuse gale
ocean quartz
#

Oh boy

steel heart
#

arguably newer versions are more optimized. then we have better switch expressions, records, sealed classes, the java std lib gets better and better also for every version

forest pecan
#

new gc

obtuse gale
#

List.of() ๐Ÿ™‚

forest pecan
#

lol

distant sun
#

Basically everything

obtuse gale
ocean quartz
#

Enjoy

#

TIL Java 13 added text block ๐Ÿ˜ฎ

obtuse gale
#

yeah lol

distant sun
#

sealed thing looks interesting

#

Does kotlin have that?

ocean quartz
#

Yup, it had for some time, 1.5 added sealed interfaces though
Actually just used it for the first time today

obtuse gale
#

Private Methods in Interfaces
I genuinely don't see the point in this though

ocean quartz
#

me neither

distant sun
#

Who cares about you two ๐Ÿคท

obtuse gale
#

I do

#

to some extent

#

it's not like I'm loving my life to the fullest

cinder flare
#

wait holy shit I just realized how awesome Java 16 will be for plugins

#

this solves my oldest woe of everyone using JDK 8

distant sun
#

so you dont specify which classes can extend that but define them inside the sealed class itself? @ocean quartz

ocean quartz
#

You know what would be awesome

ocean quartz
#

Valhalla ๐Ÿฅบ

old wyvern
cinder flare
#

i hate how everyone uses old java versions

#

and this fixes it

distant sun
#

tldr for valhalla?

old wyvern
#

Probably not

obtuse gale
ocean quartz
cinder flare
distant sun
#

Ah nice

old wyvern
#

ah ok

cinder flare
#

i am usually very sad that we don't get to use anything cool

#

but now we get like switch expressions and record classes or whatever

old wyvern
#

Yea happens when you dont use haskell

cinder flare
#

i gotta read up on new features babyyy

ocean quartz
obtuse gale
#

I came just by reading List<int>

old wyvern
#

c# being ahead of its time ๐Ÿ˜Œ

ocean quartz
#

For Kotlin it means full support for value classes and a few other features I don't remember much

distant sun
#

Ic

cinder flare
old wyvern
#

maybe

#

maybe not

#

Just

#

Nothing

#

IO

#

error

cinder flare
#

nullpointerexception

old wyvern
#

ew

obtuse gale
cinder flare
#

yeah I skimmed it once but it just made me sad cause I thought I would never use them

obtuse gale
#

now read it joyfully fingerguns

old wyvern
#

Why not?

cinder flare
#

because this is the only reason people will upgrade java versions

#

have you seen the graph

#

70% or something of people are still on java 8

old wyvern
#

I assume you plan to make stuff outside of the minecraft community as well

cinder flare
#

not with java probably

old wyvern
#

ah I c

cinder flare
#

that's what Rust is for ๐Ÿ˜‰

old wyvern
#

eh

#

personally Ill probably main java, atleast for a while

cinder flare
#

there's really not too much you can do with Java

obtuse gale
cinder flare
#

i don't see many projects besides Minecraft stuff written in java

old wyvern
obtuse gale
#

And one of them could be you

cinder flare
old wyvern
#

There are lots of applications written in java

obtuse gale
#

lmaoo

cinder flare
#

such as?

old wyvern
#

Google it up my guy

cinder flare
#

wow great point proving

ocean quartz
#

The amount of web servers using Java is insane

cinder flare
#

moral of the story, I don't see a lot of stuff I'd like to work in written in java

old wyvern
#

A lot of people using spring

quiet depot
#

google uses java

#

my government uses java