infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
infinity0 has quit [Remote host closed the connection]
Haudegen has joined #ocaml
infinity0 has joined #ocaml
waleee has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
waleee has quit [Ping timeout: 248 seconds]
zebrag has joined #ocaml
rwmjones has quit [Remote host closed the connection]
rwmjones has joined #ocaml
adanwan has quit [Remote host closed the connection]
adanwan has joined #ocaml
Serpent7776 has quit [Quit: WeeChat 1.9.1]
waleee has joined #ocaml
<greenbagels>
question: if i want to convert an int to char and vice-versa (basically a bijection from some set of chars to some set of ints), what would be the best way to implement this?
<greenbagels>
currently i have two pattern matching functions for the char -> int function and inverse function
<hannes>
greenbagels: if it is a small set of char, int - you could use an association list [ ('a', 1) ; ('b', 2) ] and do lookups / reverse lookups
<hannes>
or construct maps (int -> char ; char -> int) at load time.. I guess what I'd express is: depends on your use case and performance requirements
waleee has quit [Ping timeout: 264 seconds]
<greenbagels>
im just wondering if there's a way to have some kind of single interface for such a function
<greenbagels>
but i think the type system would make that hard
<greenbagels>
maybe wrapping the two functions in a function that takes a variant IntOrChar type and dispatches to the appropriate function on the raw data types...
<ski>
(also, i forgot if it was mentioned, but Rust does not have a "linear type system". iiuc, it's more about uniqueness)
wonko has joined #ocaml
<qwr>
i think it was called affine types
Everything has quit [Quit: leaving]
<ski>
that's also not the same thing
<ski>
linear types/logic forbid contraction (using a variable/assumption more than once) and weakening (not using a variable in scope). affine types/logic only forbid contraction. there's also relevant/relevance types/logic, which forbid weakening but not contraction. and there's ordered / non-commutative logic, which forbids contraction, weakening, exchange (using variables/assumptions out of order (of
<ski>
introduction))
<ski>
(and when i say "forbid" i mean "forbid, generally". it's still possible to do these things, in some particular circumstances, you've opt-in. the so-called "modalities" ("of course","why not", variations))
<ski>
anyway ..
<ski>
with linearity/affinity, you can't duplicate (not discard, for linear case) in the future. but you might already have duplicated in the past (before deciding to opt out of that capability, for the present reference, using "dereliction", converting an unrestricted reference to a linear/affine one)
<ski>
(so, you can't assume uniqueness of reference, and can't do update-in-place)
<ski>
whereas, with uniqueness, you know you haven't duplicated (and obviously not discarded either, since you have a reference) in the past, but you're still allowed to duplicate in the future (unless you have to conform to an interface which requires you to return a unique reference, say ..). so you can update-in-place (arrays and other mutable structures, as well as virtual I/O token sequencing. also reusing dead
<ski>
allocated nodes (possibly not having to copy over some fields), or else statically inserting calls to `free')
<ski>
Clean and Mercury uses uniqueness. i haven't looked in detail at what Rust does, but afaiui, it uses at least something similar/related
<ski>
(`*' means "unique". `io' is a type, and `di' and `uo' are parameter modes, short for `unique >> dead' and `free >> unique', meaning "destructive input" (consumes unique reference) and "unique output" (produces unique reference))
nikitalocalhost has joined #ocaml
bgs has quit [Remote host closed the connection]
bartholin has quit [Quit: Leaving]
<greenbagels>
ski: small world huh
<greenbagels>
i was going "why are they talking about this in the math channel"
perrierjouet has quit [Quit: WeeChat 3.7]
perrierjouet has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Serpent7776 has quit [Ping timeout: 252 seconds]
wingsorc has quit [Remote host closed the connection]
wingsorc has joined #ocaml
xd1le has joined #ocaml
Menchers has quit [Quit: Into the Void…]
Menchers has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]
amk has quit [Read error: Connection reset by peer]