MercurialAlchemi has quit [Ping timeout: 240 seconds]
philtor has quit [Ping timeout: 240 seconds]
freusque has joined #ocaml
MercurialAlchemi has joined #ocaml
Simn has joined #ocaml
jao has quit [Ping timeout: 240 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
kolko has quit [Ping timeout: 240 seconds]
kolko has joined #ocaml
FreeBirdLjj has joined #ocaml
freusque has quit [Ping timeout: 256 seconds]
jnavila has joined #ocaml
jnavila has quit [Client Quit]
jnavila has joined #ocaml
Algebr has quit [Ping timeout: 240 seconds]
nilof_ has joined #ocaml
larhat has joined #ocaml
<companion_cube>
so you can ask where someone on the chan is from?
AltGr has joined #ocaml
kakadu has joined #ocaml
ygrek has joined #ocaml
zwild has joined #ocaml
zwild has left #ocaml [#ocaml]
zpe has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
mfp has joined #ocaml
<companion_cube>
reynir: don't hesitate to make a PR anyway
<companion_cube>
or to ask for the commit rights
johnelse_ is now known as johnelse
mengu has joined #ocaml
pigeonv has joined #ocaml
balod has quit [Remote host closed the connection]
balod has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
mengu has quit [Remote host closed the connection]
mengu has joined #ocaml
pigeonv has quit [Ping timeout: 256 seconds]
orbifx-m has joined #ocaml
<orbifx-m>
is it possible to define 'constraints' in generic function parameters?
<orbifx-m>
because I want to constraint two or more parameters, relative to others
octachron has joined #ocaml
<zozozo>
how so ?
<companion_cube>
the only constraints you can have are: 1/ same type (use the same type variable) 2/ subtyping constraints
<companion_cube>
type 'a t constraints a = [< `A | `B]
<companion_cube>
this kind of stuff
<orbifx-m>
companion_cube: I could use modules maybe to achieve that
<orbifx-m>
but what I'd like is a fun a b where b is depends on the type of a
<orbifx-m>
s/is//
<companion_cube>
that's going to be tough
<companion_cube>
`val f : 'a -> (module S with type foo='a) -> …` is possible though
<companion_cube>
but only for the type variables, not for parametrized types
<orbifx-m>
why not?
<companion_cube>
because OCaml doesn't allow it.
<companion_cube>
you can not abstract over parametrized types
<companion_cube>
(except with functors)
_andre has joined #ocaml
<octachron>
orbifx-m, it might be useful to precise what you are trying to do, you could be asking a question that is much harder than the problem that you are trying to solve
<orbifx-m>
OK, I think I understand why. by type variables, are you referring to the so phantom types?
frefity has quit [Ping timeout: 264 seconds]
<companion_cube>
just the 'a
<orbifx-m>
octachron: I want to know if I can have a generic function with one parameter constraint by some information of the other (a set of permitted polymorphic variants maybe)
<orbifx-m>
constrained ^
<freehck>
hello people. is it possible it specify bind-name for a labeled argument and its type at the same time? I mean `~password:pass` specify that the value of argumend "password" will be bound with the symbol pass inside the function. And `~(password:string)` says that labeled argument "password" has type "string. How to say both these things simultaneously?
<octachron>
orbifx-m, "let f (x : [< `A|`B] as 'a) (y:'a) = … " ?
<octachron>
freehck, "let f ~x:(x:int) = x"
<freehck>
octachron: thx!
<companion_cube>
`let f ~(x:int) = …` shorter
<freehck>
companion_cube: it was about syntax :)
<freehck>
~password:(pass:string)
<companion_cube>
ah
<companion_cube>
because octachron's answer didn't rename x :p
<orbifx-m>
octachron: there you have specified A | B, I want it to depend on y
<octachron>
companion_cube, yes, my example was bad. Here is a better one: "let f ~x:(y:int) = y"
<orbifx-m>
say if y was a record or module
<companion_cube>
yes, better :p
<orbifx-m>
or maybe by the type of y itself if it's a phantom type
<octachron>
orbifx-m, try to write what you want in your prefered fantasy syntax, it would be easier to see if it can be mapped to a possible ocaml construction
frefity has joined #ocaml
sz0 has joined #ocaml
<octachron>
orbifx-m, silly example: in "let f (x:'a) (y:'a) = ()", the type of x and y are constrained relatively to each other.
<orbifx-m>
let f x y constraint x = y.permitted
<companion_cube>
would permitted be a field?
<orbifx-m>
where x, y are the types
<orbifx-m>
companion_cube: could be. I suspect it could be a module, but that would be more verbose
<companion_cube>
.permitted will only work for a record or module, yes
<companion_cube>
`val f : 'a -> (module Foo with type permitted = 'a) -> …`
<companion_cube>
this would work
silver has joined #ocaml
<companion_cube>
I think you should probably use a functor
<orbifx-m>
why so?
smondet` has joined #ocaml
smondet has quit [Remote host closed the connection]
<companion_cube>
because this is going to be painful with mere polymorphism (read: lots of first-class modules)
<companion_cube>
and if you only manipulate modules, why not use a functor?
<octachron>
orbifx-m, your y.permitted constraint is essentially a type-level function, depending on the required complexity of this function, functors can be the easiest path
<octachron>
orbifx-m, then if you are still working on your typed filepath example, a simpler solution might exists
<orbifx-m>
octachron: I am yes.brainstorming. it's an overkill for what I need but I'm interested in the problem
<orbifx-m>
in my case I can abstract three types and be done with it.
<octachron>
a possibility is to make the phantom type y carries around the permitted types, for instance
<octachron>
"let f (x:'a t) (y:('b * 'a) t) = … "
snowcrshd has joined #ocaml
ocalm has quit [Read error: Connection reset by peer]
<orbifx-m>
octachron: yes. that's the sort of solution I wanted
ocalm has joined #ocaml
<orbifx-m>
if I can make this concise enough to use instead of defining a functor and module or just abstracting three types..
<orbifx-m>
I could use it in this case too
malc_ has joined #ocaml
<octachron>
orbifx-m, honestly you should write down precisely which functions you are trying to write
<octachron>
and then see how much complexity do you really need
<octachron>
otherwise you may pay a very step price for trying to solve a too generic problem without need
frefity has quit [Ping timeout: 255 seconds]
<orbifx-m>
it's for fun, but you are right
<orbifx-m>
I only need one function. but it's a nice problem to learn more about Ocaml's type system
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 240 seconds]
FreeBirdLjj has joined #ocaml
frefity has joined #ocaml
<reynir>
companion_cube: No, it's very simple. »!drill reyn.ir« and you get back »37.139.20.143«, etc :-) I will take a look at adding it to calculon when I get time
sepp2k has joined #ocaml
<companion_cube>
^^
digiorgi has joined #ocaml
<digiorgi>
in the office i have windows only pcs, can i develop there ocaml? i mean, will tuareg and the other tooling still work on windows? (i'm a windows noob)
<companion_cube>
with cygwin it should work, I think
govg has quit [Ping timeout: 255 seconds]
<dmbaturin>
There's ongoing effort to make opam actually work on windows.
<orbifx-m>
digiorgi: there are always virtual machines. also kick up some fuss and ask for a Linux machine
freechips has joined #ocaml
FreeBirdLjj has quit [Read error: Connection reset by peer]
fraggle_ has quit [Ping timeout: 255 seconds]
FreeBirdLjj has joined #ocaml
frefity has quit [Ping timeout: 240 seconds]
frefity has joined #ocaml
<freehck>
I found that I usually create .mli files only when I want to hide type/function from module interface. Is there a way to not create .mli files? I know there's `private` keyword for types. Is there something similar for let bindings?
<companion_cube>
no, sorry
<companion_cube>
and private doesn't mean what you think it does
<companion_cube>
freehck: in general, .mli files are nice
<freehck>
it hides type definition, isn't it?
<freehck>
*doesn't it
fraggle_ has joined #ocaml
<freehck>
Ah... I see. private keyword enables destructing for pattern matching.
<companion_cube>
yes
<octachron>
freehck, more precisely private creates a private subtype, so you can convert between the subtype to the main type, but conversion in the reverse sense is not possible
<companion_cube>
octachron: that's for private aliases, but you also have private type definitions
<companion_cube>
which are read-only from the outside
<octachron>
companion_cube, ah right, I erroneously unified the two behaviors.
malina has joined #ocaml
mengu has quit [Remote host closed the connection]
sz0 has quit [Quit: Connection closed for inactivity]
FreeBirdLjj has quit [Remote host closed the connection]
<freehck>
octachron: btw, I still don't know why and how can I use this conversions.
<freehck>
It's of course interesting that I can do for x of type (Abstr.t = int) list list something like this (x :> int list list), but I've never seen the case.
<freehck>
And the keyword to hide some definitions while autogenerating its interface would be a great stuff.
<Drup>
freehck: honestly, just write your mli, it provides documentation.
nomicflux has joined #ocaml
mengu has joined #ocaml
frefity has quit [Quit: Ex-Chat]
frefity has joined #ocaml
mengu has quit [Ping timeout: 258 seconds]
noddy has quit [Ping timeout: 255 seconds]
<Simn>
I feel stupid, why does `let rec test (x : 'a) = test "foo" in test 12` not compile?
<Drup>
'a in (oca)ml are unification variables, not universally quantified type variables
<Drup>
if you want a function of type forall 'a -> _, you need to write it like that :
<Drup>
let rec test : 'a . 'a -> _ = fun x -> test "foo" in test 12 ;;
<companion_cube>
freehck: `type t = private int` is sometimes convenient
<companion_cube>
basically, these values can only be constructed by functions in this module
<companion_cube>
which can enforce invariants (e.g. only accepting positive integers)
<companion_cube>
if you want to, say, print a `t` you can just `Format.printf "%d@." (x:>int)`
<Simn>
Drup, thanks! Can't say I fully understand it yet, but it works fine.
noddy has joined #ocaml
nomicflux has quit [Quit: nomicflux]
al-damiri has joined #ocaml
fraggle_ has quit [Remote host closed the connection]
lopex has joined #ocaml
Denommus has joined #ocaml
noddy has quit [Ping timeout: 260 seconds]
MercurialAlchemi has quit [Ping timeout: 240 seconds]
<orbifx-m>
octachron, Drupe, companion_cube, I got a solution with phantom types and one module for abstraction
silver_ has joined #ocaml
silver has quit [Ping timeout: 255 seconds]
silver_ is now known as silver
<freehck>
companion_cube: well I can't see the difference between (x:>int) and (Positive.to_int x)
<freehck>
I think there's more information in the 2nd case
<Drup>
freehck: there is little difference, "private" is a memory layout optimisation that breaks abstraction boundary, there is little reason to use it in practice, exposing a to_int function is cleaner
<companion_cube>
freehck: no real difference
<companion_cube>
except, well, `[x;y]:> int list` is totally free at runtime
<zozozo>
Drup: well, for sum types on which you want to match, private types are useful
<Drup>
zozozo: yes, I meant private aliases
average has quit [Ping timeout: 245 seconds]
<zozozo>
in that case, sure, ^^
kakadu has quit [Quit: Konversation terminated!]
kakadu has joined #ocaml
kakadu has quit [Client Quit]
yomimono has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
sh0t has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe_ has joined #ocaml
zpe has quit [Read error: Connection reset by peer]
tobiasBora has quit [Quit: Kthxbye]
shinnya has joined #ocaml
_y has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
ocalm has quit [Quit: Leaving]
unbalancedparen has joined #ocaml
fraggle-boate has quit [Remote host closed the connection]
ryanartecona has joined #ocaml
yomimono has quit [Ping timeout: 255 seconds]
fraggle-boate has joined #ocaml
slash^ has joined #ocaml
MercurialAlchemi has joined #ocaml
digiorgi has quit [Quit: Leaving]
unbalancedparen has quit [Ping timeout: 264 seconds]
noddy has joined #ocaml
jnavila has quit [Quit: It was time]
noddy has quit [Ping timeout: 256 seconds]
unbalancedparen has joined #ocaml
zpe_ has quit [Remote host closed the connection]
yomimono has joined #ocaml
noddy has joined #ocaml
philtor has joined #ocaml
malc_ has quit [Ping timeout: 240 seconds]
tane has joined #ocaml
rwmjones has quit [Ping timeout: 240 seconds]
rwmjones has joined #ocaml
AltGr has left #ocaml [#ocaml]
jnavila has joined #ocaml
lopex has quit [Quit: Connection closed for inactivity]
average has joined #ocaml
shinnya has quit [Ping timeout: 240 seconds]
ryanartecona has quit [Quit: ryanartecona]
slash^ has quit [Read error: Connection reset by peer]
orbifx-m has quit [Ping timeout: 260 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 240 seconds]
Simn has quit [Ping timeout: 264 seconds]
Algebr has joined #ocaml
ryanartecona has joined #ocaml
noddy has quit [Quit: WeeChat 1.7]
_y has joined #ocaml
ygrek has quit [Ping timeout: 260 seconds]
<flux>
"We are please to announce that the beta of Opam 2.0.0 is out!"
<flux>
+d ;-)
<Drup>
(and it's great)
<theblatte>
\o/
<flux>
so what will I break after switching to 2.0?
<Leonidas>
probably everything ;-)
copy` has joined #ocaml
yomimono has quit [Ping timeout: 260 seconds]
<Leonidas>
it seems to support local switches, so that's by far my most anticipated feature
<Leonidas>
if it could automatically switch depending on project folder, that'd be awesome
ygrek has joined #ocaml
freusque has joined #ocaml
<Drup>
Leonidas: "opam build" will use the locally available switch. The traditional command will not, but you can use "eval $(opam env --switch path/to∕my/local/switch)" to switch locally to your shell
<Drup>
traditional shell commands*
rpg has joined #ocaml
ryanartecona has quit [Quit: ryanartecona]
snowcrshd has quit [Remote host closed the connection]
<Leonidas>
Drup: thanks, looks like opam build will become my new best friend :)
<octachron>
Leonidas, yes: with "type … = …" adds the type equality to the signature, exposing the abstract type.
larhat has quit [Ping timeout: 252 seconds]
<Leonidas>
octachron: thanks
<lobo>
just read about "with type" in "developing applications with objective caml" today :-) almost an ancient book, but the examples were simple/understandable
<Leonidas>
I have printed the book on university printers once, its on my shelf :D