<Drup>
MercurialAlchemi: could you make a lense example with a not deeply nested structure
<Drup>
(like, a normaly nested one :p)
<MercurialAlchemi>
the reason I made a deeply nested one is because it demonstrates best (IMHO) the interest of having lenses
<MercurialAlchemi>
with a one-level-deep structure, the syntaxic overhead is not very interesting
<Drup>
it seems you don't have a lense to return multiple results
^elyse^ has quit [Quit: Leaving]
<MercurialAlchemi>
indeed
<MercurialAlchemi>
if you have a use case, I could add that
<Drup>
anytime you have two things of different type you want to get in one swoop ?
<MercurialAlchemi>
so you have a key1=1,key2="a" table
<MercurialAlchemi>
and you want key1 and key2 at the same time?
<MercurialAlchemi>
this doesn't strike me as something you'd typically do
nuuit has quit [Ping timeout: 246 seconds]
ncthom91 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
govg has quit [Ping timeout: 272 seconds]
<gasche>
I'm not so familiar with lenses, is it common to make them partial?
<gasche>
having lenses from the same type to int/string/bool/float feels a bit wrong to me
govg has joined #ocaml
<gasche>
(or are they also playing the roles of first-class pattern somewhat, with an operator to say "try this lens or that other if the first fails"?)
<gasche>
I would rather have a function that takes a value and returns either an int lens, or a bool lens, etc.
^elyse^ has joined #ocaml
mcint has quit [Quit: mcint]
ncthom91 has joined #ocaml
<octachron>
gasche, it feels quite logical to me to have partial functions when transitioning from toml dynamic type system to ocaml static type system. Or I am missing something?
manizzle has joined #ocaml
ncthom91 has quit [Ping timeout: 250 seconds]
<MercurialAlchemi>
gasche: in this case, you want partial lenses, because the typical use case is accessing nested hashes
<MercurialAlchemi>
so you 1) don't have a guarantee that a given key is actually there and 2) that the value has the type you think it has
<MercurialAlchemi>
it's not so much an issue of casting, really
<MercurialAlchemi>
in this case I don't think it matters very much, I don't see "accessing your config file in a hot loop" as something that needs optimization
<companion_cube>
I meant in general, yeah
esad has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ldopa has left #ocaml [#ocaml]
<MercurialAlchemi>
but yeah, I'm curious too
esad has joined #ocaml
<gasche>
octachron: I'd rather have pattern-matching, where control flow ensures that you always take the type-correct branch, than a product of partial getters
<gasche>
but MercurialAlchemi's point about nested access and type errors are interesting
ollehar1 has joined #ocaml
govg has joined #ocaml
<def`>
gasche: I didn't look at neovim in details, but it seems to be ideal for this usecase
<MercurialAlchemi>
gasche: as a non-native English speaker, I'd say "on Windows" is definitely more common
<MercurialAlchemi>
"under Windows" sounds very much like Englishified "sous Windows"
<gasche>
go comment then
<MercurialAlchemi>
done
<MercurialAlchemi>
about lenses vs pattern-matching: you can't pattern-match maps
<MercurialAlchemi>
but the big thing is that it lets you *update*
<gasche>
I think there are different use-cases
<gasche>
pattern matching is better if you ask: what is this?
<MercurialAlchemi>
updating a deeply nested structure without tools like this is painful
<gasche>
your API is designed to say: I claim it is X, please do what I say or just barf if you can't
<MercurialAlchemi>
(I'll point out that you can use plain pattern-matching as well - apart from the issue with maps)
<gasche>
you could also define a concrete path type
<gasche>
with a checking function making sure that it is not inconsistent with the document at hand
<gasche>
and path-generic get/set functions
<MercurialAlchemi>
get table (Path "this/is/nested") -> TomlTypes.value option ?
<gasche>
let path = [Array "this"; Idx 0; Field "is"; Field "nested"]
<companion_cube>
maybe with a GADT?
<gasche>
let slot : int slot option = check Int path
<gasche>
companion_cube: overkill
<companion_cube>
hmm
<ggole>
gasche: Either is acceptable. "Under" is a touch more formal, perhaps.
<gasche>
companion_cube: I think one should not use GADTs unless not using them is horrible
<gasche>
it always pays to look for a reasonable non-GADT solution
<companion_cube>
it's reasonable
malc_ has quit [Quit: leaving]
<gasche>
(you just reminded me of one place where I need to go add GADTs)
<MercurialAlchemi>
gasche: doesn't sound much shorter than the lens solution (assuming I add a shortcut lens that combines the 'key' and 'table' lenses)
Simn has quit [Ping timeout: 240 seconds]
<gasche>
MercurialAlchemi: the two approaches should be exactly equivalent
<MercurialAlchemi>
with the difference that lenses let you update, too
<gasche>
the lenses you build are paths, only they are specialized in advance to the operation you want to express
<gasche>
MercurialAlchemi: type 'a slot = { get : unit -> 'a; set : 'a -> unit }
<gasche>
in your lens type you hardcode the operations you plan to do, and then define lens composition on them
<gasche>
my approach is an initial encoding, the composition is the data, and then the operations are defined over it
<gasche>
I think in general it makes things simpler (and often also faster but that's not important here), but with enough care you can make the two approaches look exactly the same
<gasche>
(the user may not even see the difference)
<MercurialAlchemi>
I have a hard time grasping the difference. I mean, you can compose your lenses outside of your operation, that's not an issue
<companion_cube>
oh, interesting, using a constant lens for data
<MercurialAlchemi>
I agree that the path solution may be a bit faster, but for accessing a typically small config file at startup, well... this won't keep me up at night
<gasche>
list people say that code is data
<gasche>
but, in practice, the less code the better
<companion_cube>
lisp*
_whitelogger_ has joined #ocaml
<ggole>
() is an atom ;)
^elyse^ has quit [Quit: Leaving]
thesnowdog1 has joined #ocaml
Major_Bi1 has joined #ocaml
tane has quit [Killed (rajaniemi.freenode.net (Nickname regained by services))]
tani is now known as tane
oldmanistan_ has joined #ocaml
NhanH has joined #ocaml
pootler__ has joined #ocaml
mariusae_ has joined #ocaml
andreypopp_ has joined #ocaml
sbrouf_ has joined #ocaml
stux|RC has joined #ocaml
mariusae has quit [Ping timeout: 240 seconds]
lpaste has quit [Ping timeout: 240 seconds]
_whitelogger has quit [Ping timeout: 240 seconds]
dexterph has quit [Ping timeout: 240 seconds]
pootler_ has quit [Ping timeout: 240 seconds]
Leonidas has quit [Ping timeout: 240 seconds]
fraggle__ has quit [Ping timeout: 240 seconds]
ollehar1 has quit [Remote host closed the connection]
yegods has quit [Ping timeout: 240 seconds]
andreypopp has quit [Ping timeout: 240 seconds]
stux|RC-only has quit [Ping timeout: 240 seconds]
baum_ has quit [Ping timeout: 240 seconds]
sbrouf has quit [Ping timeout: 240 seconds]
Major_Biscuit has quit [Ping timeout: 240 seconds]
octachron has quit [Ping timeout: 240 seconds]
thesnowdog has quit [Ping timeout: 240 seconds]
sz0 has quit [Ping timeout: 240 seconds]
yegods has joined #ocaml
mariusae_ is now known as mariusae
mcint has joined #ocaml
octachron_ has joined #ocaml
pootler__ is now known as pootler_
lpaste_ has joined #ocaml
xyh has joined #ocaml
BitPuffin|osx has quit [Ping timeout: 256 seconds]
andreypopp_ is now known as andreypopp
<Drup>
MercurialAlchemi: I'm unconvinced by your array type
<Drup>
I feel you would be equally fine with array = value list
<MercurialAlchemi>
I haven't changed the existing data structure, but I'm open to changes
<MercurialAlchemi>
hmm
ncthom91 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<MercurialAlchemi>
yeah, I guess we could do that now
xyh has left #ocaml [#ocaml]
yegods has quit [Ping timeout: 240 seconds]
baum has joined #ocaml
<MercurialAlchemi>
I think the original issue with that approach was that the old version didn't support array of tables
<Drup>
also, if the goal is to parse and update config files, I wonder if it would be beneficial to keep an annotated version of the parsetree, with locations, so that, in case of error, the lense would be able to return the location that was wrong
fraggle__ has joined #ocaml
dexterph has joined #ocaml
govg has quit [Ping timeout: 256 seconds]
<MercurialAlchemi>
the lens doesn't have context
<Drup>
It doesn't need to
python476 has joined #ocaml
python476 has quit [Changing host]
python476 has joined #ocaml
<MercurialAlchemi>
well, say you have your deeply nested data structure, [a.b.c.d]foo="1"
<Drup>
but it means you need to enrich your datatype
<Drup>
(with positions)
<MercurialAlchemi>
this sounds annoying considering you need to offer a way of building the tree from code as well
<flux>
if you do it the way drup suggests, it also becomes simple to support preserving comments.. ;)
<Drup>
that's a non issue, just provide constructors for the various things with a dummy position by default
Leonidas has joined #ocaml
<Drup>
(you could even use the lenses as constructors)
<MercurialAlchemi>
it makes pattern-matching quite more cumbersome
python476 is now known as 43UAACB05
baum has quit [Ping timeout: 240 seconds]
baum has joined #ocaml
<Drup>
yes it does, my propositions works if we assume the main usage is to fix the configuration file we want in a program (by defining a big lens) and that dynamic things are rare.
<MercurialAlchemi>
of course, the "gasche solution" could operate on a "toml document" which would contain both the data structures as they are now and some position information
<MercurialAlchemi>
because there is no code composition with loss of context
43UAACB05 has left #ocaml [#ocaml]
<Drup>
you could make either way work, I'm just proposing that, as it would improve what I think is the typical use case significantly
<MercurialAlchemi>
I'll consider that
<MercurialAlchemi>
the datatype simplification is definitely a good one
<Drup>
the good benchmark is "given a typical algebric datatype (so, record of sums of things), how much code do I need to make a lens filling it
<Drup>
(or, put in another way "I have a configuration datatype, how much code I need to make it read toml")
<Drup>
(read and emit)
yegods has joined #ocaml
govg has joined #ocaml
<MercurialAlchemi>
yeah
<MercurialAlchemi>
I also like "how many util functions did I build into the test suite and what does it say about the API"
groovy2shoes has joined #ocaml
mcint is now known as mcint_asdf
mcint_asdf is now known as mcint
badon_ has joined #ocaml
badon has quit [Disconnected by services]
badon_ is now known as badon
nullcatxxx_ has joined #ocaml
rand has joined #ocaml
Haudegen has quit [Ping timeout: 250 seconds]
groovy2shoes has quit [Quit: Leaving]
meiji11 has joined #ocaml
Haudegen has joined #ocaml
rbocquet has quit [*.net *.split]
w1gz has quit [*.net *.split]
k1000 has quit [*.net *.split]
adrien has quit [*.net *.split]
vodkaInferno has quit [*.net *.split]
stomp has quit [*.net *.split]
schoppenhauer has quit [*.net *.split]
TheAuGingembre has quit [*.net *.split]
mrvn has quit [*.net *.split]
kandu has quit [*.net *.split]
nzyuzin has quit [*.net *.split]
tokik has quit [*.net *.split]
__rlp has quit [*.net *.split]
fold3 has quit [*.net *.split]
Lasher` has quit [*.net *.split]
drmem has quit [*.net *.split]
cow-orker has quit [*.net *.split]
ski has quit [*.net *.split]
low-profile has quit [*.net *.split]
Mike57 has quit [*.net *.split]
Enjolras has quit [*.net *.split]
micro_ has quit [*.net *.split]
maufred_ has quit [*.net *.split]
asmanur has quit [*.net *.split]
gasche has quit [*.net *.split]
lukky513 has quit [*.net *.split]
adrien_z- has quit [*.net *.split]
vbmithr has quit [*.net *.split]
_2can_ has quit [*.net *.split]
mehdi___ has quit [*.net *.split]
Fleurety has quit [*.net *.split]
ahf has quit [*.net *.split]
orbitz has quit [*.net *.split]
chris2 has quit [*.net *.split]
so has quit [*.net *.split]
charpi has quit [*.net *.split]
neferty has quit [*.net *.split]
jrslepak has quit [*.net *.split]
xiaolin has quit [*.net *.split]
vishesh has quit [*.net *.split]
bitemyapp has quit [*.net *.split]
tokenrove has quit [*.net *.split]
SHODAN has quit [*.net *.split]
Johann has quit [*.net *.split]
eikke has quit [*.net *.split]
rwmjones has quit [*.net *.split]
thizanne has quit [*.net *.split]
lukky513 has joined #ocaml
rbocquet has joined #ocaml
w1gz has joined #ocaml
adrien_z- has joined #ocaml
ahf has joined #ocaml
Fleurety has joined #ocaml
_2can_ has joined #ocaml
k1000 has joined #ocaml
so has joined #ocaml
mehdi___ has joined #ocaml
asmanur has joined #ocaml
vbmithr has joined #ocaml
charpi has joined #ocaml
maufred_ has joined #ocaml
chris2 has joined #ocaml
gasche has joined #ocaml
orbitz has joined #ocaml
micro_ has joined #ocaml
Enjolras has joined #ocaml
Mike57 has joined #ocaml
low-profile has joined #ocaml
ski has joined #ocaml
cow-orker has joined #ocaml
drmem has joined #ocaml
Lasher` has joined #ocaml
fold3 has joined #ocaml
__rlp has joined #ocaml
tokik has joined #ocaml
nzyuzin has joined #ocaml
kandu has joined #ocaml
mrvn has joined #ocaml
TheAuGingembre has joined #ocaml
schoppenhauer has joined #ocaml
stomp has joined #ocaml
vodkaInferno has joined #ocaml
adrien has joined #ocaml
neferty has joined #ocaml
xiaolin has joined #ocaml
vishesh has joined #ocaml
bitemyapp has joined #ocaml
jrslepak has joined #ocaml
tokenrove has joined #ocaml
SHODAN has joined #ocaml
Johann has joined #ocaml
eikke has joined #ocaml
rwmjones has joined #ocaml
thizanne has joined #ocaml
mort___ has joined #ocaml
tokik has quit [Max SendQ exceeded]
tokik has joined #ocaml
_2can_ has quit [Ping timeout: 245 seconds]
so has quit [Ping timeout: 245 seconds]
ggole has quit []
nuuit has joined #ocaml
_2can has joined #ocaml
BitPuffin|osx has joined #ocaml
octachron_ has quit [Quit: Leaving]
Kakadu has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
larhat1 has joined #ocaml
mort___ has quit [Quit: Leaving.]
so has joined #ocaml
darkf has quit [Quit: Leaving]
tristero has quit [Quit: tristero]
^elyse^ has joined #ocaml
Anarchos has joined #ocaml
esad has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
esad has joined #ocaml
esad has quit [Read error: Connection reset by peer]
esad_ has joined #ocaml
nullcatxxx_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
f[x] has joined #ocaml
badon_ has joined #ocaml
badon has quit [Disconnected by services]
badon_ is now known as badon
Algebr has joined #ocaml
Algebr is now known as Guest92673
xaimus has quit [Ping timeout: 272 seconds]
<Guest92673>
Some kind of abtraction available in Lwt to say connect to this socket and keep listening to it as a client, some kind of forever function?
xaimus has joined #ocaml
<Guest92673>
or just a plain while%lwt will do
xaimus has quit [Ping timeout: 256 seconds]
seangrove has joined #ocaml
<seangrove>
Hey all, I'm having a hard time compiling some example lwt code. The let%lwt seems to be a problem - is there some flag I should pass to be able to use the syntax?
<def`>
Guest92673: let rec ...
<def`>
and you can use Lwt.async to let the thread live its own life
<def`>
seangrove: please show us the error messagz