Natalie funeral fuming
@Ulfra_Wolfe wow...
@what that makes a lot of sense...
@claire *offers hugs and gentle re-raveling*
@LottieVixen *cuddles and smooches*
@Fenreliania *cuddles*
@what oh?
@turbodragon goodnight addison!!!! sleep well!!
@bug never! /s
I'm a silly, don't listen to me~
@what I get so sick of this idea... you can't put yourself in a computer, you can only ever put a copy of yourself in a computer...
I'd still do it, but! it's not immortality for you!
@popefucker@cybre.space sorry, I should have given you the type! It's kinda complex, so let me show you compose first:
(.) :: (b -> c) -> (a -> b) -> (a -> c)
this says "the compose function takes 2 arguments, a function from b to c and a function from a to b, and then returns a function from a to c"
>>= (which is called "bind") is:
(>>=) :: IO a -> (a -> b) -> IO b
which says "the bind function takes 2 arguments, something of type IO a and a function from a to b, then returns something of type IO b"
@popefucker@cybre.space ...but now we can't compose it!
if we have:
reverse :: String -> String
we can't write
reverse (askAndResponse "what's your name?")
because askAndResponse doesn't return a String. It returns an IO String, which is something else
without monads, we'd be stuck - we can't use our results easily.
But if we make sure IO follows the monad laws, we can use the function >>= to compose:
askAndResponse "name?" >>= reverse
which makes writing code w/ effects easier
@popefucker@cybre.space for functions with no side effects (those that just take something and return something) it doesn't matter what order we do them in.
but functions that ask the user questions and wait for responses? the order matters!
so we have to wrap up whatever our function does in a higher order type:
askAndResponse :: String -> IO (String)
let's say this function displays whatever string we pass to it to the user, then waits for user response...
hi I'm avery, a cute lizardsquid with 3 hearts full of love!
nonbinary ░ they/she ░ australia ░ 29yo
I post: silly lizardy nonsense, world building, conlangs, doctor who
polyam, demi, open. I love affection!
hugs and cuddles and such are ok, but everything else please ask first
languages: English • Welsh (very basic)
I have a private account, ask for access!
(some old accounts:
@gwyfyndraig
@liquid_lizsquid
)