gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.1 http://bit.ly/nNVIVH
smerz has quit [Remote host closed the connection]
Fnar has quit [Quit: Client exiting]
bjorkintosh has quit [Read error: No route to host]
bzzbzz has quit [Quit: leaving]
Tobu has quit [Ping timeout: 272 seconds]
iago has quit [Quit: Leaving]
oriba has quit [Quit: oriba]
thizanne has joined #ocaml
Tobu has joined #ocaml
mjonsson has quit [Quit: Leaving]
Tobu has quit [Ping timeout: 272 seconds]
Tobu has joined #ocaml
ftrvxmtrx_ has quit [Quit: Leaving]
JoeyA has joined #ocaml
ftrvxmtrx has joined #ocaml
Tobu has quit [Ping timeout: 272 seconds]
manu3000 has joined #ocaml
caligula has joined #ocaml
caligula has quit [Client Quit]
caligula has joined #ocaml
JoeyA has quit [Quit: Leaving]
Tobu has joined #ocaml
cyphase has quit [Ping timeout: 240 seconds]
ulfdoz has joined #ocaml
ulfdoz has quit [Ping timeout: 245 seconds]
Tobu has quit [Ping timeout: 248 seconds]
Tobu has joined #ocaml
caligula_ has joined #ocaml
caligula has quit [Ping timeout: 244 seconds]
curryboy has quit [Ping timeout: 244 seconds]
curryboy has joined #ocaml
cyphase has joined #ocaml
ankit9 has joined #ocaml
manu3000 has quit [Quit: manu3000]
cyphase has quit [Ping timeout: 252 seconds]
ankit9 has quit [Ping timeout: 272 seconds]
cyphase has joined #ocaml
ankit9 has joined #ocaml
tmaedaZ has quit [Ping timeout: 248 seconds]
tmaedaZ has joined #ocaml
ttamttam has joined #ocaml
ggherdov has joined #ocaml
ankit9 has quit [Ping timeout: 272 seconds]
Submarine has quit [Ping timeout: 272 seconds]
alxbl has quit [Ping timeout: 248 seconds]
Cyanure has joined #ocaml
mika1 has joined #ocaml
cago has joined #ocaml
mononofu has joined #ocaml
alxbl has joined #ocaml
Snark has joined #ocaml
emmanuelux has quit [Ping timeout: 264 seconds]
djcoin has joined #ocaml
Cyanure has quit [Remote host closed the connection]
ggherdov has quit [Quit: bye folks]
ocp has joined #ocaml
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
thomasga has joined #ocaml
Submarine_ has joined #ocaml
Submarine_ has quit [Changing host]
Submarine_ has joined #ocaml
dsheets has quit [Read error: Connection reset by peer]
Submarine has quit [Quit: Leaving]
dsheets has joined #ocaml
Se7en has left #ocaml []
Cyanure has joined #ocaml
cyphase has quit [Quit: http://www.cyphase.com/]
Kynes` has quit [Read error: Operation timed out]
err404 has joined #ocaml
ocp has quit [Quit: Leaving.]
GPHemsley has quit [Read error: Operation timed out]
GPHemsley has joined #ocaml
GPHemsley has quit [Changing host]
GPHemsley has joined #ocaml
munga has joined #ocaml
smiler has quit [Changing host]
smiler has joined #ocaml
munga has quit [Ping timeout: 265 seconds]
curryboy has quit [Quit: Lost terminal]
thomasga1 has joined #ocaml
thomasga has quit [Read error: Connection reset by peer]
thomasga1 has quit [Ping timeout: 272 seconds]
thomasga has joined #ocaml
zx80 has joined #ocaml
Drakken has left #ocaml []
bacam has quit [Ping timeout: 245 seconds]
bacam has joined #ocaml
seanmcl has joined #ocaml
thomasga has quit [Ping timeout: 272 seconds]
thomasga has joined #ocaml
emmanuelux has joined #ocaml
smondet has joined #ocaml
gnuvince has quit [Ping timeout: 250 seconds]
eni has joined #ocaml
seanmcl has quit [Quit: seanmcl]
eni has quit [Ping timeout: 265 seconds]
zx80 has quit [Ping timeout: 272 seconds]
ftrvxmtrx has quit [Quit: Leaving]
gnuvince has joined #ocaml
Drakken has joined #ocaml
eni has joined #ocaml
Se7en has joined #ocaml
bjorkintosh has joined #ocaml
Se7en has quit [Ping timeout: 240 seconds]
smondet has quit [Ping timeout: 245 seconds]
Cyanure has quit [Remote host closed the connection]
ttamttam has quit [Ping timeout: 252 seconds]
Se7en has joined #ocaml
ftrvxmtrx has joined #ocaml
mika1 has quit [Quit: Leaving.]
cago has quit [Quit: Leaving.]
ttamttam has joined #ocaml
lopex has quit [Read error: Operation timed out]
lopex has joined #ocaml
smondet has joined #ocaml
eni has quit [Quit: Leaving]
ztfw`` has joined #ocaml
Se7en has quit [*.net *.split]
ztfw` has quit [*.net *.split]
patronus has quit [*.net *.split]
mrvn has quit [*.net *.split]
svenl has quit [*.net *.split]
rwmjones has quit [*.net *.split]
mal`` has quit [*.net *.split]
svenl has joined #ocaml
Se7en has joined #ocaml
patronus has joined #ocaml
mrvn has joined #ocaml
rwmjones has joined #ocaml
mal`` has joined #ocaml
<orbitz> Hello
<thelema> hi orbitz
<orbitz> I am trying to implement a phantom type, modifying Martin Jambon's and I think I don't egt it
<orbitz> I have a moduled called estring (encoded string), and it hs a type 'a esttring
<orbitz> and then I want other moduels to provide liek utf8 estring and sql estring yadda
djcoin has quit [Quit: WeeChat 0.3.2]
<orbitz> Does that make sense so far?
<thelema> it does.
<thelema> You're using a polymorphic variant for the 'a, right?
<orbitz> in utf_string.mli i have type utf8; val make_utf8 : string -> utf8 Estring.estring, then in .ml i do let make_utf8 s = s
<orbitz> but hat fails
<orbitz> Yep, estring.mli has type 'a estring
<orbitz> so make_utf8 does not compile with: Error: This expression has type string but an expression was expected of type utf8 Estring.estring
<orbitz> does estring need some sort of 'make' function?
Submarine_ has quit [Quit: Leaving]
thelema_ has joined #ocaml
<orbitz> Whoop disconnected thelema_ ?
<thelema_> reading backlog, one sec
<thelema_> ok, your problem is one of visibility.
<orbitz> Ok, what is or isn't visible that should or shuldn't be?
<thelema_> utf_string needs to be able to see that `'a estring = string` in order to compile
<orbitz> Ok
<thelema_> otherwise it can't know that make_utf8's implementation is typesafe
<orbitz> Right
<orbitz> How can I let it know that without defeating the phantom typing?
<thelema_> but I assume you want to hide the actual implementation of estring from client code, otherwise it would be able to get around the phantom typing
<orbitz> Right
thelema has quit [Ping timeout: 265 seconds]
<thelema_> and use any kind of estring as a string
<thelema_> ocaml's module system doesn't have "private except to certain modules"
<orbitz> Can estring provide a make function?
<thelema_> the only way to do this is to have Utf8_string inside Estring
<thelema_> and set one interface for the whole thing
<orbitz> Is there any way to do this so it can be extendible? So someone else coudl have a sql estring?
<thelema_> estring could provide a make function to make an estring of arbitrary type, but that doesn't help - you'd be able to make a utf8 string and sql string from teh same source
<orbitz> true
<thelema_> I don't think ocaml's type system allows this to be extendible in the way you want
<orbitz> That's a shame
<thelema_> at least not while maintaining separate compilation
<orbitz> Yeah
<thelema_> so just don't use phantom types for this.
<orbitz> What are the other options?
<thelema_> have a UTF8.t and a Sql_string.t
<orbitz> This seems like a sterotypical phantom tpes example
<thelema_> leave the implementation abstract, and give backdoors to convert to and from strings if the client really needs
<thelema_> at least sql_string doesn't make sense as a phantom type
<orbitz> I'm thinking more broadly thouhg, like the concept of a distance
<thelema_> a distance?
<orbitz> between two places
<orbitz> and the unit the distance is in
<thelema_> ah, like meters/yards
<thelema_> units, yes
<orbitz> yeah
<thelema_> units really need something a bit stronger than phantom types, especially to do division.
<thelema_> and multiplication
<orbitz> Hwo come?
<thelema_> phantom types can't do things like ('a unit -> 'b unit -> ('a/'b) unit)
<thelema_> you can do addition and subtraction just fine with phantom types
<thelema_> 'a unit -> 'a unit -> 'a unit
<orbitz> Ah I see
<orbitz> So where do phantom types shine?
<thelema_> permissions - read-only arrays/strings
<thelema_> hmmm.
<orbitz> Hrm, maybe I'll try read only string
<thelema_> jane street did something complex with phantom types here: https://ocaml.janestreet.com/?q=node/96
<ssbr_> Hm, so -dtypes doesn't produce an annotation for variables when they are defined, only when they are used?
<orbitz> interesting
<orbitz> thanks thelema_
<ssbr_> if I look at the annotation for "datalog_buf" at val datalog_buf = Buffer.create 1024 -- nothing. But later when a function is called with datalog_buf as an argument, -dtypes records its type there
<ssbr_> I guess I'm supposed to look at the type of Buffer.create? :)
<ssbr_> (int -> Buffer.t)
<thelema_> ssbr_: correct, -dtypes doesn't allow "where's this defined" lookups, mostly "the expression here has type x"
<thelema_> ssbr_: you could. what's up with "val datalog_buf = Buffer...." 'val'?
<ssbr_> uhhh, is that not a part of the object syntax?
<ssbr_> I confess I'm not as familiar with ocaml as I should be for someone messing around with ocaml code
<thelema_> ah, inside an object
<thelema_> I'm used to `val` going in .mli files
<thelema_> I guess that's a minor limitation of -dtypes
<ssbr_> I'm liking -dtypes though :)
<ssbr_> thelema_: well, not that minor
<mfp> vim's omlet does have IIRC <Leader>d which jumps to the definition if on the same file
<ssbr_> I don't like having to look up where things are used to figure out their type
<ssbr_> if I can't figure it out from looking at the declaration
<thelema_> ssbr_: minor for those of us that don't use objects
<ssbr_> oh, huh
<ssbr_> you're right, it's only for objects and classes
<ssbr_> regular function/value definitions get annotated fine
<ssbr_> e.g. if I look at the annotation for let x y = ... , it'll tell me the type of x if I run the annotation looker-upper tool there
<ssbr_> in_channel -> unit. How nice.
<pippijn> thelema_: oh god
<pippijn> phantom_thirteen?
<pippijn> :|
<thelema_> pippijn: yes, not code I'd write if I could avoid it.
<pippijn> same here
iago has joined #ocaml
<ssbr_> guh
<ssbr_> no wonder I was having a hard time reading this -- author used the same variable names for keys/values in a hashtable depending on what part of the code you read
iago has quit [Ping timeout: 244 seconds]
ulfdoz has joined #ocaml
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
ttamttam has quit [Ping timeout: 265 seconds]
ikaros has joined #ocaml
ttamttam has joined #ocaml
gnuvince has quit [Ping timeout: 265 seconds]
gnuvince has joined #ocaml
cdidd has quit [Remote host closed the connection]
Tobu has quit [Ping timeout: 272 seconds]
BiDOrD_ has joined #ocaml
BiDOrD has quit [Ping timeout: 245 seconds]
Tobu has joined #ocaml
gnuvince has quit [Ping timeout: 244 seconds]
gnuvince has joined #ocaml
eni has joined #ocaml
sgnb has quit [Remote host closed the connection]
Cyanure has joined #ocaml
iago has joined #ocaml
zx80 has joined #ocaml
bjorkintosh has quit [Read error: Connection reset by peer]
snearch has joined #ocaml
snearch has quit [Read error: Connection reset by peer]
snearch has joined #ocaml
jave has quit [Quit: ZNC - http://znc.in]
Tobu has quit [Remote host closed the connection]
jave has joined #ocaml
sgnb has joined #ocaml
snearch has quit [Quit: Verlassend]
zx80 has quit [Ping timeout: 272 seconds]
Tobu has joined #ocaml
djcoin has joined #ocaml
msimoni has joined #ocaml
ttamttam has left #ocaml []
tautologico has joined #ocaml
gnuvince has quit [Ping timeout: 248 seconds]
thomasga has quit [Quit: Leaving.]
milosn has quit [Remote host closed the connection]
milosn has joined #ocaml
Submarine has quit [Quit: Leaving]
manu3000 has joined #ocaml
milosn_ has joined #ocaml
milosn has quit [Ping timeout: 250 seconds]
ulfdoz has quit [Quit: deprecated]
Snark has quit [Quit: Quitte]
mononofu has left #ocaml []
Cyanure has quit [Remote host closed the connection]
milosn_ has quit [Ping timeout: 244 seconds]
eni has quit [Ping timeout: 255 seconds]
hto has joined #ocaml
milosn has joined #ocaml
ikaros has quit [Quit: Ex-Chat]
djcoin has quit [Quit: WeeChat 0.3.2]
gnuvince has joined #ocaml
msimoni has quit [Quit: Leaving.]
ftrvxmtrx has quit [Ping timeout: 252 seconds]
ftrvxmtrx has joined #ocaml
cyphase has joined #ocaml
smondet has quit [Quit: Bye]
err404 has quit [Quit: Ex-Chat]