alexherbo2 has quit [Remote host closed the connection]
toastal has joined #ocaml
Phandal_ has quit [Quit: leaving]
bartholin has joined #ocaml
raskol has quit [Ping timeout: 246 seconds]
abbe__ has joined #ocaml
raskol has joined #ocaml
raskol has quit [Ping timeout: 252 seconds]
euphores has quit [Ping timeout: 245 seconds]
Serpent7776 has joined #ocaml
bartholin has quit [Quit: Leaving]
contificate has joined #ocaml
germ_ has quit [Ping timeout: 252 seconds]
mrtz has joined #ocaml
germ has joined #ocaml
mrtz has quit [Remote host closed the connection]
contificate has quit [Quit: Client closed]
gooby323 has joined #ocaml
gooby323 has quit [Quit: Konversation terminated!]
myrkraverk_ has quit [Quit: Leaving]
myrkraverk has joined #ocaml
alexherbo2 has joined #ocaml
gooby323 has joined #ocaml
gooby323 has quit [Client Quit]
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
chrisz has quit [Ping timeout: 252 seconds]
chrisz has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
raskol has joined #ocaml
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
rwmjones has quit [Ping timeout: 264 seconds]
rwmjones has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
oisota has quit [Quit: Ping timeout (120 seconds)]
alexherbo2 has quit [Remote host closed the connection]
dme2_ has quit [Ping timeout: 248 seconds]
dme2 has joined #ocaml
alexherbo2 has joined #ocaml
oisota has joined #ocaml
emp has quit [Ping timeout: 248 seconds]
emp has joined #ocaml
<discocaml>
<softwaresirppi> guyss
alexherbo2 has quit [Remote host closed the connection]
alexherbo2 has joined #ocaml
<discocaml>
<softwaresirppi> `type shape = Circle of int | Rectangle of (int * int)` why these kind of type definitions have this keyword `of`? in haskell you dont have it in the middle?
<discocaml>
<softwaresirppi> any reason?
<discocaml>
<softwaresirppi> wow what did you do!
<discocaml>
<contificate> be careful with that type definition, it's different from `Rectangle of int * int`
<discocaml>
<contificate> usually only do that if you're intending for their to be extra indirection
<discocaml>
<contificate> usually only do that if you're intending for there to be extra indirection
<discocaml>
<contificate> the syntax doesn't really matter, the main difference is that Haskell's `data` constructors are curried
<discocaml>
<softwaresirppi> alsu why cant i use function application functions like `5 |> Circle`
<discocaml>
<softwaresirppi> oh!
<discocaml>
<contificate> they're not functions, unlike Haskell where you can use it higher-order like that
<discocaml>
<softwaresirppi> NOT IN OCAML? 😭
<discocaml>
<contificate> there's ppx derivers to produce "make" functions for them
<discocaml>
<._null._> ^
<discocaml>
<._null._> Well I'm late
<discocaml>
<softwaresirppi> whyy whats the alternative!!
<discocaml>
<contificate> you can derive such functions using a jane street ppx
<discocaml>
<softwaresirppi> you answered even before i knew i had that question
<discocaml>
<contificate> can't lie, I don't lose sleep over this
<discocaml>
<contificate> it's a bit tedious
<discocaml>
<contificate> but hardly
<discocaml>
<softwaresirppi> THEY DOOOO
<discocaml>
<._null._> No thy don't
<discocaml>
<softwaresirppi> they take the arguments and makes a new type
<discocaml>
<._null._> No they don't
<discocaml>
<softwaresirppi> new typed thingy
<discocaml>
<softwaresirppi> why not?
<discocaml>
<contificate> the way to think about it is: `Circle 5` is "allocate an object that stores 1 thing and is tagged as Circle"
<discocaml>
<softwaresirppi> ifi see
<discocaml>
<._null._> They merely pack stuff
<discocaml>
<contificate> nullary constructors are their tag as an unboxed value
<discocaml>
<contificate> the awkwardness is that `R of int * int` is not the same as `R of (int * int)` - the former case is like `[R, int, int]`, the latter is `[R, ptr]` where `ptr` points to `[int, int]`
<discocaml>
<contificate> which can be convenient if you want to be able to match it as a real tuple and pass it somewhere without appearing to reconstruct it
<discocaml>
<softwaresirppi> that makes a lott of sense
<discocaml>
<softwaresirppi> thank you!
<discocaml>
<softwaresirppi> but still constructors not being functions are kinda leaving a bad taste in my mouth
<discocaml>
<._null._> Constructors cannot exist on their own, they need their arguments to be made sense of
<discocaml>
<contificate> the way to think of it is like
<discocaml>
<contificate> you don't call a function to do `Circle 5`
<discocaml>
<contificate> you allocate on the minor heap by bumping a register and setting a tag and stored value or whatever
<discocaml>
<contificate> if you accept that world view
<discocaml>
<contificate> the fact they're not functions is a minor inconvenience
<discocaml>
<contificate> can't do `List.map Some`
<discocaml>
<contificate> but you can do `List.map Option.some`
<discocaml>
<contificate> so who cares
<discocaml>
<softwaresirppi> hold up!!
<discocaml>
<softwaresirppi> `let f radius = Circle radius;;`
<discocaml>
<softwaresirppi> `5 |> f` works
<discocaml>
<softwaresirppi> the same with functions? you need arguments for the whole function to make sense>
<discocaml>
<._null._> `fun x y -> x + y` makes sense on its own
<discocaml>
<softwaresirppi> thats DOING something... and can be a function?
<discocaml>
<softwaresirppi> i dont understand your philosophical point
<discocaml>
<softwaresirppi> type shape = Circle int;; also makes sense right?
<discocaml>
<._null._> `fun r -> Circle r` makes sense. It is however not the same thing as `Circle` which doesn't make sense as is
<discocaml>
<softwaresirppi> (im not knitpicking im trying to understand how to deal with constructors)
<discocaml>
<softwaresirppi> `Circle radius -> Circle radius`
<discocaml>
<softwaresirppi> lol
<discocaml>
<softwaresirppi> EXACTLY
<discocaml>
<softwaresirppi> isnt it a design flaw?
<discocaml>
<softwaresirppi> as ocaml is very well designed as people say... i just dont understand their design philosophy
<discocaml>
<softwaresirppi> isnt it a design flaw? duplication of code?
<discocaml>
<._null._> This is not the constructor doing something, but the program doing something to create the value
bartholin has joined #ocaml
<discocaml>
<softwaresirppi> alright. so youre saying its not an action and a value
<discocaml>
<._null._> It's not something you can all
<discocaml>
<softwaresirppi> okay ill condition myself to think this way lol
<discocaml>
<._null._> It's not something you can call
<discocaml>
<softwaresirppi> `Circle 5` feels like calling to me
<discocaml>
<._null._> It kinda looks like calling, but that's as far as it goes
<discocaml>
<contificate> well I mean they're not curried so having them act as functions could work but it'd be limited to this one use case
<discocaml>
<contificate> I think there's a github issue where xlr says "too much sugar rots the teeth"
<discocaml>
<softwaresirppi> LMAO
<discocaml>
<softwaresirppi> i kinda agree
<discocaml>
<._null._> I'm coming from Coq, where constructors are considered as functions, and this was an error
<discocaml>
<._null._> In OCaml, `fun x -> C x` is always as general as the constructor would be, but not in Coq (with universe polymorphism). So `C` and `C x` behave fundamentally differently, which is annoying to deal with
<discocaml>
<softwaresirppi> Why C and C x would behave different? Sorry I haven't used coq
euphores has joined #ocaml
<discocaml>
<._null._> It's difficult to explain quickly, but universe arguments are irrelevant to fully applied constructors but not for partially applied constructors
<discocaml>
<softwaresirppi> Please link up articles/docs to justify this please!
<discocaml>
<softwaresirppi> cool its similar to what NULL said, passing in the behaviour along with arguments
<discocaml>
<softwaresirppi> thank you deep space john!
<discocaml>
<softwaresirppi> if you dont mind.... where is the functor here?
<discocaml>
<softwaresirppi> ive heard functor is the mapping from one category to another
<discocaml>
<deepspacejohn> yeah, both styles are similar. my example makes more sense if you're doing it often with a lot of functions
<discocaml>
<softwaresirppi> factss
<discocaml>
<deepspacejohn> line 9: module Make(M: S) = struct
<discocaml>
<deepspacejohn> functors in OCaml are basically "module functions." they're modules that take other modules as arguments to make new modules.
<discocaml>
<softwaresirppi> Ohh
<discocaml>
<softwaresirppi> It takes a module(a category) and spits out a new module (another category)
<discocaml>
<softwaresirppi> Alright makes sense
<discocaml>
<contificate> these "category" allusions are probably not useful
<discocaml>
<contificate> "functor" is overloaded in PL
<discocaml>
<contificate> the way I personally reason about functors, first class modules, etc. is as though it's a form of record specialisation at runtime
<discocaml>
<contificate> if you compile OCaml, you can actually see the indexing order in relation to the mli/order of decls in the file, like getglobal or whatever
<discocaml>
<._null._> I read "functor" as "a synonym which is not just 'function'"
<discocaml>
<contificate> I think "something that can be mapped over" but if you called it something else in OCaml, I wouldn't really have a hang-up about the terminology
<discocaml>
<contificate> C++ calls a struct with `operator()` overloaded to be a "functor", lol
<discocaml>
<softwaresirppi> interesting
jmcantrell has left #ocaml [#ocaml]
Anarchos has joined #ocaml
Anarchos has quit [Ping timeout: 272 seconds]
Anarchos has joined #ocaml
Anarchos has quit [Remote host closed the connection]
Anarchos has joined #ocaml
infinity0 has quit [Ping timeout: 245 seconds]
euphores has quit [Quit: Leaving.]
pi3ce has quit [Read error: Connection reset by peer]
pi3ce has joined #ocaml
euphores has joined #ocaml
infinity0 has joined #ocaml
szkl has quit [Quit: Connection closed for inactivity]
Anarchos has quit [Ping timeout: 244 seconds]
bartholin has quit [Quit: Leaving]
raskol has quit [Ping timeout: 255 seconds]
toastal has quit [Ping timeout: 248 seconds]
alexherbo2 has joined #ocaml
spew has joined #ocaml
Phandal has quit [Quit: leaving]
<discocaml>
<gooby_clown> Never mention those things again.
raskol has joined #ocaml
YuGiOhJCJ has joined #ocaml
f[x] has quit [Remote host closed the connection]
spew has quit [Quit: spew]
Tuplanolla has joined #ocaml
germ has quit [Ping timeout: 260 seconds]
germ has joined #ocaml
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
Haudegen has joined #ocaml
motherfsck has quit [Ping timeout: 246 seconds]
motherfsck has joined #ocaml
<discocaml>
<ada2k> Why not?
alexherbo2 has quit [Remote host closed the connection]
Haudegen has quit [Quit: Bin weg.]
<companion_cube>
Ah yes, a "let+ able"
<discocaml>
<Kali> so true
<dh`>
ocaml functors are parameterized modules
<dh`>
they have roughly the same relationship to category-theoretic functors as ocaml functions have to math functions