Reaganomicon has quit [Remote host closed the connection]
Eataix has quit []
dsheets has quit [Ping timeout: 260 seconds]
dsheets has joined #ocaml
lopex has quit []
vram0 has joined #ocaml
<vram0>
I'm having some trouble figuring out how to do something. I'd like to construct a type which has some value T1 of 'a | T2 of ('a * ('a -> 'b) * ('a -> 'c)) ; is there a way to do something like this?
<vram0>
I haven't been able to figure out how write the type statement given that the T1 side only takes 1 arbitrary parameter
<zorun>
you have to declare the type as "type ('a, 'b) foo = ..."
<zorun>
because the type depends on 'a and 'b
<zorun>
you can then construct more specific types (eg. "type bar = (int, string) foo")
<zorun>
or just use your general type, but OCaml will probably specialize it itself then
<vram0>
zorun: Thanks! I wasn't sure about the syntax specification. That works!
<zorun>
np ;)
Eataix has joined #ocaml
<zorun>
oooh, I love utop! <3
<zorun>
it's incredible to have such a nice interface after having been stuck with the crappy toplevel for years!
<zorun>
(ok, with rlwrap the toplevel was less crappy, but anyway)
jamii has joined #ocaml
sebz has joined #ocaml
Eataix has quit []
jamii has quit [Ping timeout: 258 seconds]
jamii has joined #ocaml
dnolen has joined #ocaml
dnolen has quit [Client Quit]
mdelaney has quit [Ping timeout: 264 seconds]
mdelaney has joined #ocaml
mdelaney has quit [Quit: mdelaney]
joewilliams is now known as joewilliams_away
jamii has quit [Ping timeout: 252 seconds]
metasyntax|work has quit [Ping timeout: 246 seconds]
joewilliams_away is now known as joewilliams
jamii has joined #ocaml
jamii has quit [Ping timeout: 240 seconds]
jamii has joined #ocaml
jamii has quit [Remote host closed the connection]
ulfdoz has joined #ocaml
sebz has quit [Quit: Computer has gone to sleep.]
thelema has quit [Remote host closed the connection]
thelema has joined #ocaml
bobry has quit [Ping timeout: 240 seconds]
arubin has quit [Quit: arubin]
bobry has joined #ocaml
joewilliams is now known as joewilliams_away
ulfdoz has quit [Ping timeout: 252 seconds]
metasyntax|work has joined #ocaml
ttamttam has joined #ocaml
mdelaney has joined #ocaml
mdelaney has quit [Client Quit]
bobry1 has joined #ocaml
<f[x]>
ouch, thelema, that is not the latest patch on mantis, caml_c_call annotation is wrong and I couldn't get it right so it should be removed
ttamttam has quit [Quit: Leaving.]
Reaganomicon has joined #ocaml
betta_y_omega has quit [Ping timeout: 245 seconds]
The_third_man has quit []
betta_y_omega has joined #ocaml
<f[x]>
thelema, I've updated the patch
ttamttam has joined #ocaml
Snark has joined #ocaml
Associat0r has joined #ocaml
<_habnabit>
okay, so, I've been doing a lot of thinking about architecture and so on, and I've mostly got it. just one last issue.
<_habnabit>
is there _any way_ to do this? or do I have to make do_repetitive_work a part of a functorial interface or something
<_habnabit>
because okay, I might end up having to just make everything a functorial interface.
<_habnabit>
but not having to do that would be nice too.
ikaros has joined #ocaml
<flux>
I haven't used first class modules, BUT. Maybe you can try something like let do_repetitive_work (type a) m (x : a) = let module C = (val m: N with type t = a) in .. ?
* _habnabit
tries that.
<_habnabit>
on line 37 (same line 37):
<_habnabit>
Error: This expression has type (module N) but an expression was expected of type (module N with type t = 'a)
larhat has joined #ocaml
<_habnabit>
... !!!
<flux>
_habnabit, hmm
<_habnabit>
changed it to do_repetitive_work (module C: N with type t = C.t) x;
<_habnabit>
and it compiles
<flux>
_habnabit, why do you have (module C : N) and not just (module C)?
<flux>
or is that part of the syntax somehow
<_habnabit>
pretty sure it's invalid syntax without the : N
<flux>
try it?
<_habnabit>
yeah, it is.
<flux>
hmm
<_habnabit>
but what you said got me halfway there.
<_habnabit>
and I got the rest.
<flux>
great! I'm well prepared then for my first first-class-modules-program then :-)
<_habnabit>
the more I think about it, the more the functorial interface makes more sense anyway
<_habnabit>
but it's good to understand this is possible.
<flux>
seems still pretty repetitive.. maybe you can put (module C: N with blahblah) into a variable and use that?
<_habnabit>
yeah, I can.
<flux>
yeah, maybe functorial interface is nicer
<flux>
less trickery
<_habnabit>
since (module ...) packs a module into a value.
<_habnabit>
the (type t) syntax has always puzzled me, though.
<_habnabit>
is that new in 3.12?
<flux>
yes
<flux>
I understand it's pretty useful with those first class modules
edwin has joined #ocaml
<_habnabit>
oh, there's its description in the grammar.
<flux>
it enables the use of Map.Make for polymorphic parameters
<flux>
hm, so infact you don't even need first class modules for that to be useful
<_habnabit>
is there an example of 'constraint' somewhere? the only place I've seen it used is the generated signatures when you have a class type as a field in a struct type.
<flux>
well, you could use it for example for: type 'a foo = int constraint 'a = [ `A | `B ]
<flux>
maybe you could take a look at some big libraries, they might have found use for it
<flux>
(that example would be suitable for phantom types)
<_habnabit>
what's that code do, though? I don't think I've ever used polymorphic variants.
<flux>
at least it should be easy to find, find -name \*mli | xargs grep constraint :)
<flux>
actually it would typically be like type 'access handle = int constraint 'access = [< `Read | `Write ]
<flux>
then you might have function like: let open_for_read file = (open `Read file : [< `Read] handle)
<flux>
and then you might have functions like: val get_line : [`Read] handle -> string
<flux>
but still have function like: val close : 'a handle -> unit
<_habnabit>
ah.
<flux>
but I'm sure there are non-phantom-type examples as well
<flux>
and in fact the constraint is not required in that example either. it rather serves as self-enforcing documentation.
<flux>
(you would be able to limit the available types with the signatures of your functions)
<_habnabit>
maybe I should learn more about polymorphic variants.
<_habnabit>
hmmmm. they might actually be really useful in some of the FSM-based parsers I've written
<flux>
polymorphic variants can lead to worse error messages
<flux>
but I still use them if I just need a local variant for a functino..
oriba has joined #ocaml
<flux>
oh, hadn't noticed that OPA had gone open source on the summer. I guess I'll try to stick with ocsigen/eliom for the time being, though..
<adrien>
this is exactly why I hate msys
<adrien>
rm.exe crashed... I tried to remove *one* file
avsm has quit [Quit: Leaving.]
jimmyrcom has quit [Ping timeout: 276 seconds]
lopex has joined #ocaml
avsm has joined #ocaml
_andre has joined #ocaml
avsm has quit [Quit: Leaving.]
dnolen has joined #ocaml
avsm has joined #ocaml
avsm has quit [Client Quit]
Boscop has joined #ocaml
Boscop has quit [Changing host]
Boscop has joined #ocaml
Boscop has left #ocaml []
rossberg has quit [Remote host closed the connection]
ttamttam has quit [Remote host closed the connection]
sebz has joined #ocaml
Associat0r has quit [Quit: Associat0r]
rossberg has joined #ocaml
jimmyrcom has joined #ocaml
pr has quit [Read error: Operation timed out]
pr has joined #ocaml
pr has quit [Changing host]
pr has joined #ocaml
jimmyrcom has quit [Ping timeout: 276 seconds]
Snark has quit [*.net *.split]
hnrgrgr has quit [Ping timeout: 268 seconds]
Snark has joined #ocaml
oriba has quit [Quit: oriba]
<metasyntax|work>
zorun: ping
<zorun>
metasyntax|work: pong
<metasyntax|work>
zorun: I think the ocaml-lwt problem with module Types is the same as utop - it requires the compiler libs to build the toplevel.
<metasyntax|work>
zorun: I'm fairly new to Arch Linux and building packages and whatnot, but I've gotten into the (probably bad) habbit of managing my own packages in a repo hosted on Bitbucket - https://bitbucket.org/taylor_venable/aur/overview
<zorun>
actually, I've come to the same conclusion just before going to sleep yesterday :)
<metasyntax|work>
At some point I'll find the time to go through and make sure I report all the updates in the AUR or bug tracker.
<metasyntax|work>
Thanks for the pointers in your AUR comments by the way. :-)
<zorun>
metasyntax|work: you're welcome, you've done most of the work ;)
<zorun>
good idea for your hg repo
<zorun>
though there is a global git repo for the whole AUR (useful for older versions, etc)
<_habnabit>
oh, derp. I forgot to change the = to a :
<thelema>
<bonk>
pdhborges has joined #ocaml
<_habnabit>
yeah, that did it. thanks!
junsuijin has joined #ocaml
mdelaney has joined #ocaml
jimmyrcom has joined #ocaml
joewilliams is now known as joewilliams_away
joewilliams_away is now known as joewilliams
<metasyntax|work>
Is anybody using utop under xterm? My xterm produces ^H for backspace, which utop ignores; I have to type C-? to backspace. Using stty, I have erase=^H and werase=^?
<thelema>
metasyntax|work: it works for me under gnome-terminal
<thelema>
(with default backspace/erase settings)
<metasyntax|work>
I tested it in urxvt (which produces ^? for backspace) and it works.
<adrien>
if it's like I-cannot-remember-what, then you could work around it by configuring xterm keys but that involves other issues
<adrien>
VT100.Translations: #override \
<adrien>
<Key>BackSpace: string(0x7F)
<adrien>
I think
<metasyntax|work>
Yeah, I remember having to do those for some other program before. Maybe I'll find something in the source code. lambda-term comes with a lambda-term-inputrc file, but that doesn't seem to have an effect.
<adrien>
best would be to change lamba-term or utop or whatever of course, good luck with that, and if you find a solution, can you ping me? thanks
* adrien
thinks he's going to directly crash in his bed
<diml>
metasyntax|work: in lambda-term there is an example called 'events'
<diml>
it shows keys typed
<diml>
can you try it ?
<metasyntax|work>
diml: Sure, I'll go give that a try.
<metasyntax|work>
diml: When I hit backspace it prints "Key { control = true; meta = false; shift = false; code = Char 0x68 }"
<metasyntax|work>
Seems right to me, 0x68 = h ; so backspace = ^H
<diml>
you can try to add C-h: delete-prev-char in your ~/.lambda-term-inputrc
<metasyntax|work>
Does that go under [read-line] or [edit]?
<diml>
under [edit]
joewilliams is now known as joewilliams_away
joewilliams_away is now known as joewilliams
<metasyntax|work>
Didn't make a difference, the behaviour is the same.
<diml>
this is strange
<diml>
it works for me, if i add C-h: ... in my ~/.lambda-term-inpurc and type Ctrl+H it erases the previous character
<flux>
olasd, so how's the utop packaging going, I'm still feeling lazy ;-)
<metasyntax|work>
diml: Maybe it's a weird thing outside of just the terminal; it doesn't work pressing Ctrl+H in urxvt either.
<diml>
metasyntax|work: is your utop compiled with lambda-term 1.1 ? lambda-term-inputrc has been introduced in 1.1
<metasyntax|work>
diml: It should be, but I'll go back and remove and recompile just to be sure.
<metasyntax|work>
diml: Well, I feel like a fool. I was accidentally running an old utop from /usr/local/bin instead of the new one from /usr/bin. I put "C-h: delete-prev-char" in my .lambda-term-inputrc and it worked. Thanks for the help, sorry about having the wrong version.
<_habnabit>
I'm trying to pass around both a module and an instance of its type without explicitly specifying the type.
<_habnabit>
since if in which_module I did (module Float: N with type t = Float.t), then it's incompatible with (module Int: N with type t = Int.t)
ccasin has joined #ocaml
sebz has quit [Ping timeout: 240 seconds]
<thelema>
yup, I think you can't use a pair for this, as what would be the result of `snd` on such a pair...
<_habnabit>
what could I use?
ccasin has quit [Client Quit]
ccasin has joined #ocaml
<thelema>
I don't know. My intuition says objects (state + functions on that state), but we tried that before.
<_habnabit>
I tried doing this with objects, but it doesn't seem to be able to accomplish this same thing.
<_habnabit>
unless you see a way of doing it?
<_habnabit>
well, worst case, I can use a bit of Obj.magic
<adrien>
*boom*
<adrien>
sorry, old habit ;-)
<thelema>
_habnabit: I'd recommend against it. strongly.
<adrien>
or, try it, have your program crash, stop using it :P
<_habnabit>
I don't see any other way to do this, though? I've been working on it for the last day and a half
pdhborges has joined #ocaml
pdhborges has left #ocaml []
<_habnabit>
I mean, I'm totally up for a discussion about how to better structure the code
<_habnabit>
because I'm totally at a loss here.
<flux>
well, you could try asking :-). (however, I won't be of help now, off to sleep)
<_habnabit>
eh? I /did/ ask
<_habnabit>
if you need clarification, that's fine, but I'd need to know what to clarify.
<flux>
oh
<flux>
(I just read the last few lines ;-))
<flux>
what is your goal?
<flux>
have a set of code work with either integers or floats, depending on a runtime argument?
<_habnabit>
read in from user input some parameters, which choose the black box method used. from there, the operations on that black box are always the same.
<_habnabit>
this is vastly simplified; I could paste the actual code, but it's quite long.
<_habnabit>
but it still illustrates what the goal is.
<_habnabit>
thelema, did you see the new paste as well?
<flux>
_habnabit, I think it's a good idea to hit the mailing list. your example of the problem is pretty good, and I _think_ it should be working simply with this new feature as well
<thelema>
_habnabit: yes, give me a sec to try extending it
<_habnabit>
thelema, okay, thank you.
<flux>
but, I'm off to sleep. happy hacking :)
<_habnabit>
flux, thanks anyway! I do really appreciate it.
<thelema>
I cheated a bit using Oo.copy to duplicate x in do_repetitive_work
metasyntax|work has quit [Quit: WeeChat [quit]]
<thelema>
_habnabit: ^^
<_habnabit>
hmm, the problem with that is that `add` is actually more complicated; it uses details that one type of object will have, but not the other.
<thelema>
If you have to get this info out of one type from a different object, you'll need a method for it.
<thelema>
the corresponding method on the other type can just raise an exception
<_habnabit>
... ah, that would do it.
* thelema
goes back to his work
<_habnabit>
if I had the implementation-specific bits encapsulated in some object, and then you called `y#get_float_impl_details` or whatever.
edwin has quit [Remote host closed the connection]
raphael-p has quit [Read error: Operation timed out]
raphael-p has joined #ocaml
<olasd>
flux: real life preempted me... But I have good hopes for this weekend
jimmyrcom has quit [Quit: Leaving.]
jimmyrcom has joined #ocaml
lamawithonel_ has quit [Remote host closed the connection]
caligula has joined #ocaml
junsuijin has quit [Quit: Leaving.]
lamawithonel has joined #ocaml
ccasin has quit [Quit: Lost terminal]
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
lpereira has quit [Quit: Leaving.]
jamii has joined #ocaml
sebz_ has joined #ocaml
sebz has quit [Ping timeout: 245 seconds]
sebz_ is now known as sebz
Morphous has quit [Ping timeout: 260 seconds]
sebz has quit [Quit: Computer has gone to sleep.]
Morphous has joined #ocaml
ftrvxmtrx has quit [Read error: Connection reset by peer]
ftrvxmtrx has joined #ocaml
jimmyrcom has quit [Ping timeout: 240 seconds]
elehack has quit [Quit: Headed out, possibly to home]
Asmadeus_ is now known as Asmadeus
lamawithonel has quit [Remote host closed the connection]
jamii has quit [Quit: Leaving]
<_habnabit>
is it possible to have a type that's 'any polymorphic variant' ?
ikaros has quit [Quit: Ex-Chat]
jimmyrcom has joined #ocaml
sebz has joined #ocaml
lopex has quit []
ftrvxmtrx has quit [Remote host closed the connection]