clojure-uk

A place for people in the UK, near the UK, visiting the UK, planning to visit the UK or just vaguely interested to randomly chat about things (often vi and emacs, occasionally clojure). More general the #ldnclj
dharrigan 2020-11-04T06:51:41.343200Z

Good morning!

alexlynham 2020-11-04T08:06:16.343300Z

morning

djm 2020-11-04T08:07:56.343500Z

👋

mccraigmccraig 2020-11-04T08:17:48.343700Z

måning

Alex J Henderson 2020-11-04T09:26:27.343800Z

morning, nice to get some sun, blue sky & frost for a change

👍 1
alexlynham 2020-11-04T09:45:12.344Z

y'know i was thinking about the whole 'simple made easy' thing and much as it pains me to say it but if you follow that idea to its conclusion i'm p sure you end up with monads

alexlynham 2020-11-04T09:45:41.344100Z

although concede that this may be a form of the 'everything is a monad once you start thinking about monads' fallacy

thomas 2020-11-04T10:18:34.344800Z

mogge

dominicm 2020-11-04T10:18:34.344900Z

I am not sure that's true at all. Please go on @alex.lynham

alexlynham 2020-11-04T10:19:13.345100Z

well the problem of composition gets pushed from programmer discipline onto the compiler

dominicm 2020-11-04T10:19:34.345300Z

That seems impossible.

dominicm 2020-11-04T10:20:04.345900Z

A compiler cannot prove that your program is composable.

mccraigmccraig 2020-11-04T10:21:16.346900Z

but if your program is structured as a bunch of monadic functions then they are provably composable

alexlynham 2020-11-04T10:21:26.347Z

^ this

dominicm 2020-11-04T10:21:44.347400Z

But it didn't take out discipline in that case.

dominicm 2020-11-04T10:22:05.348200Z

It also doesn't make the composition useful.

mccraigmccraig 2020-11-04T10:23:07.349Z

it automated most of the discipline, but it didn't make the programmer obsolete

alexlynham 2020-11-04T10:23:18.349100Z

😂 1
🙈 2
mccraigmccraig 2020-11-04T10:23:53.349900Z

pushing as much discipline as possible onto the compiler seems like a good thing - humans are not very good at it

dominicm 2020-11-04T10:24:22.350500Z

How is this different from programming against interfaces?

alexlynham 2020-11-04T10:24:36.350600Z

yeah this is kinda what i'm seeing from trying to a) scale out something in js/ts which is eek as always b) continually field questions about code style/how to handover

alexlynham 2020-11-04T10:25:29.351300Z

if you instead shrug and go 'the monads drive you to an opinionated pattern' then other people have to go that way and the compiler will force them to do so

alexlynham 2020-11-04T10:25:59.351500Z

& it's not incompatible with the data-first orientation of e.g. clojure a lens is kinda just a fancy get-in :D

alexlynham 2020-11-04T10:28:59.352300Z

though equally i do wonder if i'm driven in this direction by the limitations of the typescript language and whether in cljs i'd be like eh not a problem

Conor 2020-11-04T11:01:45.352500Z

I know it gives me a warm glow when the business value I provide is mathematically rigourous

😂 1
alexlynham 2020-11-04T11:14:36.352600Z

😂

dominicm 2020-11-04T11:26:28.354Z

I mean, how do monads make you simple. Let's think of the places where things get rough, like I/O.

dominicm 2020-11-04T11:28:35.356600Z

In clojure I'd consider code simple if it used a Stream or Reader/Writer, and then there were function(s) which process that. I could complect those same functions by taking a filename string and internally creating the interface. Monads seem no different?

alexlynham 2020-11-04T11:29:33.356700Z

no, but you get the type guarantee that you can just say

pipe thing1 thing2 thing3 thing4
to get your result

alexlynham 2020-11-04T11:29:39.356800Z

i have a system map and a function that takes that and interacts with the database, i make it a Reader. i make every fn like that a Reader, then i can chain a bunch of them together as one composed Reader

alexlynham 2020-11-04T11:30:18.356900Z

it's like the kinda stuff you can do with the threading macros in clj, just typesafe and with a context that may or may not represent external dependencies

mccraigmccraig 2020-11-04T11:34:36.358200Z

the monad insulates your from plumbing code, in a similar way to how transducers let you focus on the reduction rather than the transport

mccraigmccraig 2020-11-04T11:35:41.358900Z

and when you use it, you know your functions will compose nicely - it's really just another sort of interface

alexlynham 2020-11-04T11:36:43.359Z

^ a better explanation than mine haha

mccraigmccraig 2020-11-04T11:46:16.363Z

lots of the monad instance definitions are embarrassingly simple - e.g. in the sequence monad return = (fn [v] [v])and bind = mapcat, and you would use them anyway if you were composing functions over sequences, but the common interface lets you compose your functions without even thinking about it, and further even lets you compose the effects represented by particular monad types (i.e. monad transformers or compound monads), and if you have a language which supports macros, then a bind syntax makes all the plumbing just disappear into the background

alexlynham 2020-11-04T12:05:26.363900Z

right

alexlynham 2020-11-04T12:05:33.364Z

but back to simple made easy

alexlynham 2020-11-04T12:05:35.364100Z

it's simple

alexlynham 2020-11-05T09:14:17.380700Z

well... yeah

alexlynham 2020-11-05T09:14:19.380900Z

kinda

alexlynham 2020-11-05T09:14:22.381100Z

that's what i mean

alexlynham 2020-11-05T09:15:06.381300Z

i think it would be very hard to argue that spec is more simple than monads for ex

alexlynham 2020-11-05T09:15:22.381500Z

and given the selector stuff is going in the direction of lenses too 🤷

alexlynham 2020-11-05T09:15:43.381700Z

"One day I will find the right words, and they will be simple."

alexlynham 2020-11-05T09:15:47.381900Z

the quest continues

2020-11-05T09:40:47.383100Z

Well, I wonder if your feeling is essentially because a large part of mathematics essentially boils down to being a rigorous discipline for decomposing things into small pieces and composing them together. Finding the simplest formulation of an idea etc. Therefore anything sufficiently mirroring mathematical formalisms will almost by definition be simple in the sense Rich means. I think spec meets actually meets a similar theoretical standard to monads. Though monads and spec tackle different problems so it’s a bit apples and oranges, and unfair to say monads are simpler (better or more elegant) than spec, because the complexity of the initial problem is different. Still, spec is based on pretty rigorous foundations (parsing with derivatives) which describes how specs can be composed from simple predicate functions. I also think when you’re comparing monads to spec there; you’re actually comparing the trade offs in the implementations rather than the theoretic underpinnings. spec definitely makes a bunch of easy compromises by complecting certain non-theoretical things. For example being able to reuse specs for generative testing, or having a global registry of specs etc, maybe also the syntax being a bit verbose etc.

alexlynham 2020-11-05T10:30:04.383500Z

yeah that's fair

alexlynham 2020-11-05T10:30:56.383700Z

i guess i've used both and found monads + plumatic schema to be the most natural fit for what i want to do but maybe the crossover between monads + spec isn't quite as clear cut as it feels to me

alexlynham 2020-11-05T10:31:11.383900Z

they feel like they sit enough in the same space that they don't coexist well

alexlynham 2020-11-05T10:31:49.384100Z

whereas schema is hands-off enough to be a natural build on the essential power of homoiconicity for the kinda serialisation/deserialisation/run time validation i wanna do in a composable way :thinking_face:

2020-11-05T13:51:13.389900Z

I don’t think of monads and spec as being particularly related. The closest I can probably put my finger on is that in a strongly type checked language like Haskell, a monad, or essentially any pattern imposed in types, would prevent you from doing a bunch of things (they’d also imply you can do other things of course). Specs I guess are about you preventing certain shapes of data. Also both are compositional systems,… so perhaps similar in those ways; but ultimately I think very different. I’d say spec is more similar to type systems than to monads (which are in Haskell at least an abstraction expressed as types within that type system). Monads enable a specific type of composition; but I’d say the typed lambda calculus is really the thing providing the compositional similarity between monads and spec that I think you’re highlighting.

alexlynham 2020-11-05T15:03:21.390300Z

hmmm

alexlynham 2020-11-04T12:05:46.364200Z

but lots of faff to get all the types lined up

alexlynham 2020-11-04T12:05:50.364300Z

so it's not easy

alexlynham 2020-11-04T12:06:00.364400Z

hence my original shower thought

flefik 2020-11-04T12:12:20.364900Z

@mccraigmccraig where can I learn more about this? any particular book or other resource you would recommend?

mccraigmccraig 2020-11-04T12:19:37.367800Z

there isn't a single resource which really gelled the concepts for me... there are a million impenetrable articles around the web, but they mostly didn't help me. http://learnyouahaskell.com/chapters helped some, but probably most important was playing with code particulary funcool/cats and its deferred monad http://funcool.github.io/cats/latest/#manifold-deferred , perhaps because that was directly relevant to the problem i had at the time (building an async codebase)

flefik 2020-11-04T12:28:03.368200Z

thanks!

flefik 2020-11-04T12:28:08.368400Z

i’ll look at these

alexlynham 2020-11-04T12:45:02.368500Z

the haskell book is.... okay? it's still in prerelease tho

alexlynham 2020-11-04T12:45:38.368600Z

this is the one that made it make sense for me https://www.microsoft.com/en-us/research/wp-content/uploads/1993/01/imperative.pdf that and working with funcool/cats

mccraigmccraig 2020-11-04T12:50:27.369Z

oh, that's the original paper which kicked it all off isn't it @alex.lynham ?

yogidevbear 2020-11-04T12:53:21.369400Z

I've heard good things about https://haskellbook.com/ - haven't had a chance to read it though

alexlynham 2020-11-04T13:43:27.369800Z

that's the one i mean ^ it's still prerelease tho and quite dense

alexlynham 2020-11-04T13:43:43.369900Z

yes it is, surprisingly readable too

2020-11-04T13:47:53.370500Z

it’s as ready as it’ll be afaik? the authors are no longer speaking to each other

alexlynham 2020-11-05T09:13:52.380100Z

whoa

alexlynham 2020-11-05T09:13:59.380300Z

okay, won't recommend that book in future then

alexlynham 2020-11-05T09:14:02.380500Z

what an arsehole

Conor 2020-11-05T09:17:38.382300Z

To be fair, it is a good book. But Julie Moronuki has also written a book with a guy called Chris who probably isn't a knob

alexlynham 2020-11-05T09:25:54.382700Z

what is it about the haskell community, sheesh

alexlynham 2020-11-05T09:26:28.382900Z

to quote lisa simpson, "this is why we can't have nice things"

2020-11-05T10:50:08.384300Z

there are two Chrises in the story, coauthor of the Haskell Book is Chris Allen, Joy of Haskell is co-written with Chris Martin: https://joyofhaskell.com/

minimal 2020-11-04T13:49:18.371200Z

Yup ^.

alexlynham 2020-11-04T13:52:44.371300Z

oh really?

alexlynham 2020-11-04T13:52:45.371400Z

blimey

alexlynham 2020-11-04T13:54:00.371500Z

well it was worth what i paid for it i guess, although like craig i found it was other things that cemented the concepts better tbh

alexlynham 2020-11-04T14:17:27.372Z

as an aside, p sure ~43 mins into the Maybe Not talk, Rich is talking about lenses

thomas 2020-11-04T14:31:31.373300Z

off topic... but does someone know how to reach Sam Aaron, of Overtone fame? I have sent him several DM's on twitter already, but no response unfortunately.

rlj 2020-11-04T14:35:04.373800Z

Mornin

rlj 2020-11-04T14:35:23.374200Z

and Mornin @russ.anderson

2020-11-04T14:47:21.374400Z

Morning everyone!

2020-11-04T14:51:24.374500Z

in a > we've had a falling out/splitting up sense, or just a > we independently (and amicably) moved on to other projects sense?

Conor 2020-11-04T14:58:29.374800Z

IIRC I got the impression that one of the authors was a chud

Conor 2020-11-04T14:58:32.375Z

Might be wrong about that

alexlynham 2020-11-04T14:59:53.375200Z

yeah there might have been some issue around all the white supremacy stuff in haskell

alexlynham 2020-11-04T15:00:07.375400Z

iirc they took different positions on the whole lambdaconf thing

minimal 2020-11-04T15:11:34.375600Z

He is super toxic and treated her like crap. She no longer gets money from the sales of the book as they came to some kind of settlement/agreement.

dharrigan 2020-11-04T15:38:28.375900Z

How would you model this in clojure?

dharrigan 2020-11-04T15:38:30.376100Z

(input.get() & 0xFF)
                | ((input.get() & 0xFF) << 8)
                | ((input.get() & 0xFF) << 16)
                | ((input.get() & 0xFF) << 24)

dharrigan 2020-11-04T15:44:24.376300Z

I'll ask in beginners too 🙂

mccraigmccraig 2020-11-04T15:46:58.376700Z

bit-and , bit-or and bit-shift-left

2020-11-04T15:56:22.376800Z

there were lawyers involved

dharrigan 2020-11-04T16:25:46.377100Z

Found my answer in #beginners 🙂

dominicm 2020-11-04T19:17:36.377600Z

Doesn't he do training?

dominicm 2020-11-04T19:18:56.377800Z

No, perhaps not. I'd grab his email from github commits perhaps?

2020-11-04T22:14:06.378100Z

I think it’d be hard to argue that monads aren’t simple; but wouldn’t that be true of essentially any elegant mathematical concept governed by a small set of rigorously distinct axioms?