johnf_ has quit [Read error: Connection reset by peer]
darkf has joined #ocaml
teknozulu has joined #ocaml
struk|desk|away is now known as struk|desk
hxegon is now known as hxegon_AFK
darkf has quit [Ping timeout: 240 seconds]
<orbifx>
cya all
darkf has joined #ocaml
gaze__ has joined #ocaml
<gaze__>
hey, anyone familiar with ocaml's compiler internals? I'm reading through asmcomp and can't figure how how the control flow graph is represented
<Drup>
asmcomp is really low level
mfx2 has joined #ocaml
<gaze__>
well, I'm more interested in things that CSE and DCE are performed on
<gaze__>
I'm just curious what the right data structure to use to represent something you might perform these passes on is in ocaml
<Drup>
there is no DCE
<Drup>
As for CSE, it's at the clambda level, iirc
darkf_ has joined #ocaml
darkf has quit [Ping timeout: 250 seconds]
orbifx has quit [Quit: WeeChat 1.3]
<gaze__>
asmcomp/CSEgen.ml?
<gaze__>
looks like it performs some global value numbering
<Drup>
well, that looks promising :D
<gaze__>
but ah... yeah, I'm not super familiar with ocaml to begin with... but anyway, I keep seeing this Reg.t structure
<Enjolras>
Drup: isn't DCE something which was supposed to be supportedin 4.02 ?
<Drup>
Enjolras: that's CSE
<Enjolras>
ok. I thought both were introduced :)
<Drup>
gaze__: this is the part of the compiler I don't know at all, I can't help you much
<gaze__>
ah fair enough :)
<Drup>
gaze__: but, send an email to the mailing list, you'll have your answers
darkf_ has quit [Ping timeout: 240 seconds]
<gaze__>
okay and then for a super noob question... what is this .t? Is it just that it's convention to maybe have some container C and define the type of the container in the C module as t?
mfx2 has quit [Quit: AtomicIRC: The nuclear option.]
darkf has joined #ocaml
<fds>
gaze__: Yes, it's just a conventional name for the `main type' of a module.
hxegon_AFK is now known as hxegon
<aantron>
gaze__: to add to what fds said, it is useful when you have un-opened modules (which is quite common). for example, if you have a module Data_structure, it would be really annoying to type Data_structure.data_structure each time you wanted to refer to the type
darkf has quit [Ping timeout: 250 seconds]
darkf has joined #ocaml
darkf has joined #ocaml
darkf has quit [Changing host]
silver has quit [Read error: Connection reset by peer]
nicholasf has quit [Remote host closed the connection]
<aantron>
nice
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
Algebr`` has quit [Ping timeout: 240 seconds]
nicholasf has joined #ocaml
wiredsister has joined #ocaml
nichola__ has joined #ocaml
nicholasf has quit [Ping timeout: 240 seconds]
aantron_ has joined #ocaml
yunxing has quit [Remote host closed the connection]
tennix has joined #ocaml
nichola__ has quit [Ping timeout: 250 seconds]
aantron has quit [Ping timeout: 244 seconds]
MasseR has quit [Ping timeout: 244 seconds]
vishesh has joined #ocaml
tennix has quit [Ping timeout: 244 seconds]
hcarty1 has joined #ocaml
MasseR has joined #ocaml
wiredsister has quit [Ping timeout: 250 seconds]
tennix has joined #ocaml
tennix has quit [Ping timeout: 240 seconds]
lokien_ has quit [Quit: Connection closed for inactivity]
tennix has joined #ocaml
jeffmo has quit [Quit: jeffmo]
nicholasf has joined #ocaml
Pepe_ has quit [Ping timeout: 252 seconds]
<teknozulu>
Any ideas for a (potentially functorial?) approach to "extracting" the types of a function with signature a -> b? I want to wind up in a situation where I'm able to write "type a" and "type b"
maverous has joined #ocaml
<maverous>
hey guys working on a really simple function but cant seem to get the types correct
<teknozulu>
Specifically, I want to be able to create a module that uses "type a(b) [@@deriving bin_io]"
<teknozulu>
maverous pastebin
<maverous>
its not long enough for a pastebin
<maverous>
this is like one line
<maverous>
and less about code
<maverous>
and more about concept
<maverous>
so I have to use the fold left function to count the occurences of element x in list y and the function needs to be of type 'a -> 'a list -> int
<maverous>
from my basic understanding of ocaml that means I should create a list which only contains the x's found in y and then use length on that?
<aantron_>
thats one way, but you can easily skip creating the intermediate list
<maverous>
while still having 'a -> 'a list -> int?
<aantron_>
yes
<maverous>
interesante
struk|desk is now known as struk|desk|away
<maverous>
hmm
<maverous>
hint?
<aantron_>
use fold_left :) have you ever written anything else with fold_left before?
<maverous>
nope haha
<aantron_>
try doing a simpler task that involves fold_left
<aantron_>
like counting the number of elements in a list, or summing up a list of numbers
<aantron_>
to get an idea for what it's doing. that should help you do more complicated things with it
<maverous>
okay
<maverous>
playing around with it now
<maverous>
i think the thing that is throwing me off is the types
<maverous>
as in using fold to go from 'a to
<maverous>
'a list to int
<aantron_>
ok :)
<aantron_>
thats not what it's doing. the type is fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
<aantron_>
the way you read that is "go from a function, an 'a, and a 'b list, to an 'a"
<aantron_>
or more specifically for fold_left, since we know what it does, we can say "go from one value of type 'a, applying the function over 'b list, to get a final value of type 'a"
<aantron_>
in ocaml, everything until the last top-level arrow is the argument types, and the last thing left is the result type
<maverous>
ohhhh
<maverous>
and because it is count x y
<maverous>
x is 'a and y is 'a list
<aantron_>
precisely
<aantron_>
and the result has to be an int
<maverous>
so then it circles back for me
<maverous>
actually
<maverous>
let me test this out
johnelse has quit [Ping timeout: 252 seconds]
struk|desk|away is now known as struk|desk
<maverous>
ok aantron_
<maverous>
im so close
<maverous>
but right now i have int -> int list -> int
johnelse has joined #ocaml
<aantron_>
well, i dont know what you are doing.. implementing your final function, or doing arithmetic
<maverous>
i got it!
<aantron_>
:)
<maverous>
thanks man!
<aantron_>
you're welcome
teknozulu has quit [Ping timeout: 252 seconds]
<maverous>
butttt
<aantron_>
for extra understanding you can try to implement fold_left yourself, if you are already familiar with "let rec" and such. otherwise, maybe later
<maverous>
it doesnt work
<maverous>
lol
<maverous>
so the type stuff is correct
<maverous>
but the output isnt
<maverous>
wanna take a peek?
<aantron_>
sure. pastebin, here, or pm works
<maverous>
pm'd
johnelse has quit [Ping timeout: 248 seconds]
johnelse has joined #ocaml
yunxing has joined #ocaml
maverous has quit [Quit: WeeChat 1.3]
pierpa has quit [Ping timeout: 240 seconds]
hcarty1 has quit [Ping timeout: 276 seconds]
teknozulu has joined #ocaml
fluter has quit [Ping timeout: 250 seconds]
MercurialAlchemi has joined #ocaml
gaze__ has joined #ocaml
<gaze__>
hey, for folks that use both ocaml and haskell, do people use the ocaml toplevel like haskell people use GHCi?
<gaze__>
I can't find something analogous to :r... Is ocaml more of a compile and run and test sorta thing or do people make as heavy use of the toplevel as haskell folks do?
fluter has joined #ocaml
seliopou_ has quit [Ping timeout: 248 seconds]
Algebr`` has joined #ocaml
gaze__ has quit [Ping timeout: 252 seconds]
ygrek has quit [Ping timeout: 248 seconds]
MercurialAlchemi has quit [Ping timeout: 252 seconds]
struk|desk is now known as struk|desk|away
nicholasf has quit []
damason has quit [Ping timeout: 244 seconds]
seliopou has joined #ocaml
Algebr`` has quit [Remote host closed the connection]
Algebr` has joined #ocaml
kushal has joined #ocaml
aantron_ has quit [Remote host closed the connection]
MercurialAlchemi has joined #ocaml
<Algebr`>
should caml_strdup always be used when passing a result of String_val to some C code?
aantron has joined #ocaml
yunxing has quit [Remote host closed the connection]
malc_ has joined #ocaml
malc_ has quit [Quit: ERC (IRC client for Emacs 25.0.50.2)]
larhat has joined #ocaml
<Algebr`>
ocp-build is coming out with new version every day for past 5 days
toolslive has quit [Ping timeout: 250 seconds]
Haudegen has quit [Ping timeout: 276 seconds]
seangrove has quit [Ping timeout: 240 seconds]
AlexRussia has quit [Ping timeout: 248 seconds]
toolslive has joined #ocaml
toolslive has quit [Remote host closed the connection]
Haudegen has joined #ocaml
<MasseR>
Can someone point me to a paper/blog/article/opinion on how come (S)ML-style modules are the best thing since sliced bread?
larhat has quit [Quit: Leaving.]
<Algebr`>
i think cohttp is one of the best examples of using the module system effectively, its an http package with different backends for concurrency and multiple backends for ssl
<MasseR>
Yeah, I've used cohttp, and others that can use either lwt or async
<MasseR>
But that isn't something that can't be done as easily with interfaces
julien_t has joined #ocaml
<Algebr`>
I think how cohttp uses functors is very effective
<aantron>
interfaces as in other languages?
<Algebr`>
not sure what you mean by interfaces, like java interfaces?
<MasseR>
Yeah
<MasseR>
Or not even interfaces, classes and interfaces
<MasseR>
public Http(AsyncProvider async) { ... }
<MasseR>
Dependency injection
<aantron>
interfaces is a major use of the module system
<MasseR>
Yeah. So what is the difference that makes modules better? Or am I wrong here, they aren't necessarily better, but perhaps different with same/similar power?
<aantron>
an ml module includes types. i dont think this effect is so easy to achieve in java, though its pretty typical with c++ templates
<aantron>
it has been a long time since i coded java, but does java allow a static method in an interface?
<MasseR>
I think java8 does
<aantron>
one of the points of the module system is that at least notionally, it decouples "state" ("objects") from modularity, whereas in languages like java these things tend to be conflated
<MasseR>
a java class can include types as well
<aantron>
my memory is hazy though i wrote a lot of java, how would you encode an abstract type in a java interface?
<aantron>
(not to mention i last worked in java 6)
<MasseR>
Haven't verified, but probably: public class Foo { public abstract class Bar { ... } }
<MasseR>
oh, in an interface?
<MasseR>
A good question
<aantron>
maybe its sufficient to encode it in an abstract class
<MasseR>
public interface Foo { public abstract class Bar { } }
<MasseR>
compiler is ok with that
<aantron>
next there is the question of generating instances of this by a functor that is defined over instances of another interface. ultimately its all representable in java (or js, or asm - thats why its possible to compile ML to all of those), its jsut a question of how easy is it?
<MasseR>
And this is probably quite close to the question I have :)
<mrvn>
A module is not an object, it has no instances.
ygrek has joined #ocaml
<mrvn>
YOu could say every module is a singleton
<MasseR>
mrvn: Agreed. But with my original question, this doesn't explain how modules are 'better', just that they are 'different', maybe even more restricted
<mrvn>
also no inheritance.
<Algebr`>
MasseR: the module system lets you make new modules from other modules with functors
<aantron>
but there are first class modules. its not a question of instances of modules, but instances of an interface
<mrvn>
modules are statically duck typed.
<aantron>
MasseR: the equivalent to a functor in java would be something like taking instances of one interface with static methods, passing it to something, and getting an instance of another one out
<MasseR>
Algebr` as a counterpoint, you can inherit classes in java
<mrvn>
can java return interfaces?
wiredsister has joined #ocaml
<Algebr`>
I wouldn't call compare it to inheritance though, like module Names = Set.Make(String)
<aantron>
you can mark the return type of a method with an interface type
<MasseR>
mrvn: that would be higher kinded types, right?
<mrvn>
aantron: one defind outside
<mrvn>
MasseR: yes
<aantron>
you can sort of inherit in ml as well, using include, it just has a different meaning because the relevant typing is not nominative
<MasseR>
No, java can't do tha
<MasseR>
t
Simn has joined #ocaml
<MercurialAlchemi>
mrvn: outside of what?
<mrvn>
ocaml has higher order functions but that isn't limited to modules.
<MasseR>
Algebr`: that's pretty much inheritance/composition with duck typing
<MasseR>
A nicer syntax
<mrvn>
MercurialAlchemi: outside the function returning it
<MercurialAlchemi>
hm, that doesn't make sense in Java
<MercurialAlchemi>
you don't define interfaces in functions
<mrvn>
In ocaml you can
<mrvn>
And every invokation of the function returns a unique type.
<mrvn>
(if you want)
<MasseR>
MercurialAlchemi: for my condition, that's ok. I'm trying to formulate in my head the differences :)
<MercurialAlchemi>
you'd have your MyInterface.java file somewhere, and you can have YourFile.java which uses MyInterface
<MasseR>
and whether the differences are good or bad :)
nojb has joined #ocaml
<aantron>
sounds like defining modules, not interfaces..?
<MercurialAlchemi>
MyInterface can even be in a different Java lib, as long as it sits in your classpath when you compile and you imported in YourFile
<mrvn>
MercurialAlchemi: That's the difference between java and higher order languages that allow passing types. They can build completly new types in the function (or functor).
<MasseR>
Algebr`: actualy, your Set.Make(String) specifically is just generics
julien_t has quit [Ping timeout: 244 seconds]
<MercurialAlchemi>
mrvn: yeah, you can't do that in Java
<mrvn>
MasseR: but only because it doesn't create a non generics type.
<MercurialAlchemi>
though I'm not sure how you build "completely new types" in ocaml outside of a functor?
<MasseR>
mrvn: not sure what you mean by that
<mrvn>
MercurialAlchemi: module M = struct type t end and return M
<mrvn>
MasseR: functors can do things generics can't do
<mrvn>
MasseR: e.g. when called twice with the same argument the resulting types can be different.
<MasseR>
That sounds dangerous
<mrvn>
MasseR: sometimes you want unique types.
<def`>
How can that be dangerous :D
<MercurialAlchemi>
mrvn: within a module, sure but in a function? utop seems to think it's a syntax error
<aantron>
MercurialAlchemi: mrvn left off the type definition and some other syntax
<MasseR>
Oh and sorry, suddenly so much lines, I have trouble internalizing some of the explanations
<mrvn>
MercurialAlchemi: first class modules need some extras to make the syntax work.
<MasseR>
I'll be reading the backlog for a while
<MercurialAlchemi>
ah, first class modules
<MercurialAlchemi>
yeah, of course
<aantron>
however
<aantron>
the module system is good even when not using first-class modules
<aantron>
i think arguments that have to resort to them are not so strong
<MasseR>
10:17 <aantron> next there is the question of generating instances of this by a functor that is defined over instances of another interface. <- Can you give me an example on this? Or was the Set.Make for this?
<mrvn>
Other than trying it out I haven't yet used first class modules.
<aantron>
Set.Make works for this
<aantron>
but note that it is not quite the same as List<T>
<MasseR>
No, it would be quite the same as Set<Comparable<T>> or something like that
<mrvn>
.oO(No, it's Set<T> :)
<aantron>
the point is Set.Make (Blah) is not an object
<mrvn>
But just in this case because Set.Make is written that way.
<MasseR>
Where the class has a (visible) constraint, but ml modules have duck-typing requirements
<aantron>
or rather a value of type Set.Make (Blah)
<mrvn>
Set.Make(Bla) is a factory I would say.
<aantron>
yes its closer to a factory in the terms of other languages
<MasseR>
Decoupling state from modularity is probably a big point for ml-style modules
<MasseR>
Otherwise I have mostly seen how ml is different/similar to oo-classes without clear cut benefits on either end
<mrvn>
The major difference is the added type safety and higher order.
<MasseR>
Could you elaborate on the type safety
<mrvn>
and in the case of ocaml the much more readable syntax :)
<MasseR>
Other than ml style types are more type safe than java types :). How does module-system help?
<aantron>
well type safety is a big difference :)
<aantron>
as well as that in ML, everything is by default "final" in java terms
<aantron>
(almost)
<mrvn>
MasseR: for that the module system is more like a namespace. No different form other langauges. The extra type safety is a global feature of ml languages.
<MasseR>
agreed, but that's outside of the module constraint :)
<MercurialAlchemi>
Java does have one big advantage over ocaml, though
<aantron>
right, but the point i am making is that you can write ML in Java (kind of), and you can write Java in ML (kind of), but the point isnt that one is representable in terms of the other
<MercurialAlchemi>
you can have collections of arbitrary types easily
<aantron>
its a matter of how easy it is to write a program you can understand and maintain
<MasseR>
MercurialAlchemi: hnngh,
<mrvn>
aantron: you can write ocaml in java but it will be unreadable and the compiler will allow code that ocaml would detect as wrong.
<aantron>
yes
<MasseR>
MercurialAlchemi: I don't like the slippery slope argument, but that leads easily to List<Object> :(
<aantron>
thats why i said the types matter, and so does the syntax
<mrvn>
on the other hand if you write java in ocaml then it would only accept valid code.
<MercurialAlchemi>
MasseR: sometimes it's what you need
warp has joined #ocaml
<MasseR>
Or my favorite. xpath.xpath("foo", doc) // -> Object
<MercurialAlchemi>
I mean, union types are great, but only if you know what you're going to get in advance
<MasseR>
Then depending on the input you might get a collection of elements, a single element, a string, null, a number
<companion_cube>
mrvn: although you can now use map and the likes in java
<MercurialAlchemi>
(ok, it's better now that they can be extended, but still)
<mrvn>
companion_cube: verry limited
<companion_cube>
or kotlin (I feel like kotlin is exactly java but less verbose)
<MasseR>
And suddenly you have a runtime error because you didn't get <foo><bar></foo> but <foo><bar/><bar/></foo>
<MasseR>
:(
<companion_cube>
MercurialAlchemi: we can have iterators in OCaml, too
<mrvn>
you want verbose? I once has a 120k long c++ error message.
<MercurialAlchemi>
MasseR: yeah, sure, you lose safety
<MasseR>
Not that, that specific case would have bitten me dozens of times
<aantron>
mrvn: nice
<MercurialAlchemi>
companion_cube: it's not so much a matter of iterator as a matter of casting A into B
<companion_cube>
oh, you mean the type of elements
<MercurialAlchemi>
yeah
<MercurialAlchemi>
wouldn't be such a big deal if we had introspection
<companion_cube>
are you promoting Collection<Object> ?!
<mrvn>
ocaml has no down casts.
* aantron
waits for Obj.magic to be mentioned
<MercurialAlchemi>
companion_cube: sometimes that's handy
<companion_cube>
I don't think that's good :/
<mrvn>
aantron: that's not a down cast, just a magic cast
<MasseR>
aantron: just like you can pretend unsafePerformIO, or unsafeCoerce does not exist, you can pretend Obj.magic does not exist :)
<MercurialAlchemi>
well, it's like may things, most of the time you don't want it, but when you do and you don't have it, it's quite annoying
<MasseR>
As for Object, it just exists
<aantron>
i certainly pretend it doesnt exist, ive never used it and never seen it mentioned so many times as i have by people in this channel :)
<MasseR>
I've seen it only in jsofocal
<mrvn>
aantron: you probably used it and never knew it. As it should be.
<aantron>
mrvn: i probably compiled to native code and never knew it either?
<mrvn>
It's for cases where you know you are right but can't figure out how to tell ocaml that or where that becomes exceptionally complex.
<MercurialAlchemi>
companion_cube: having a List<Object> equivalent wouldn't be such a big problem if you had a "cast" operator returning an option type
<companion_cube>
to me that's a design problem
<MercurialAlchemi>
you wouldn't lose type safety
<MasseR>
MercurialAlchemi: what do you mean by an option type?
<companion_cube>
type 'a option
<mrvn>
MercurialAlchemi: You can easily have a List<Object>, where Object is a class in ocaml.
<aantron>
type 'a option = Some of 'a | None
<mrvn>
MercurialAlchemi: or you can use GATD and use witness types to make an universal container.
<MasseR>
That's what I thought. How does that help with type safety with Object?
<MercurialAlchemi>
mrvn: that crosses the threshold of annoyance
<companion_cube>
you can also have a of list of a GADT, like: type box = Box : 'a * 'a operations -> box
<aantron>
it forces you to check the results of casts instead of risking exceptions
copy` has quit [Quit: Connection closed for inactivity]
<companion_cube>
where operations is a record/object of things you can do on 'a
<MasseR>
aantron: a good point
<companion_cube>
as said mrvn
<mrvn>
MasseR: you can put anything derived from Object into the list but you can then only get Objects back and can't down cast.
<mrvn>
What you can also do with GADTs is have a universal list and then run operations on all elements of a given type from that list and skip all others.
<mrvn>
For example you can have a object storage where every object has a "'a key". Then you can retrieve objects given an instance of "'a key" and it will only ever return a "'a".
<MercurialAlchemi>
MasseR: you're objecting about the fact that you need to say explicity what you're capturing?
<mrvn>
companion_cube: {i: (lambda x: x+i) for i in [1,2,3,4,5]}[3](2) gives what?
<MasseR>
MercurialAlchemi: for that example yes
<MasseR>
I have/had other complaints as well, but I haven't written php for a couple of years now
<mrvn>
hint: 7
ousado has joined #ocaml
<companion_cube>
mrvn: heh
<MercurialAlchemi>
with the number of times I captured values by accident in Perl, I'd say it's not a bad thing
<MercurialAlchemi>
(PHP could use more 'explicit' anything anyway)
<mrvn>
MercurialAlchemi: I found that verry confusing.
<companion_cube>
scoping in python is a mess anyway
<mrvn>
I have a lot of "lamba x,a=a,b=b,c=c,d=d,...: ..."
<mrvn>
MercurialAlchemi: PHP could be used less
<MercurialAlchemi>
mrvn: it's the same in C++, I think
<MercurialAlchemi>
but yeah, the world could use less PHP
<mrvn>
MercurialAlchemi: in C++ it's clearly a variable that changes.
<MercurialAlchemi>
amusingly enough, modern JS has saner scoping rules than Python (if you eschew 'var')
LoicBSD has joined #ocaml
LoicBSD is now known as lmaury
<flux>
it's fair to eschew 'var'?-)
<mrvn>
Another thing I hate about python is that asignment is a statement and not an expression.
<mrvn>
lambda x: s[x] = ' ' is not allowed.
<MercurialAlchemi>
flux: yeah, if you can use ES6 syntax, just use 'let' and 'const'
<companion_cube>
lua is remarkably well designed in this area
<MercurialAlchemi>
actually, modern JS is not so bad, apart from all the broken stuff
<MercurialAlchemi>
companion_cube: how so?
<MercurialAlchemi>
don't much about it apart from 1-based indexes and the reputed speed of lua-jit
<companion_cube>
small, consistent language with proper scoping and closures from the beginning
<companion_cube>
and the syntax is nice, you have `end` terminator for most constructs, better than OCaml
<MercurialAlchemi>
kind of like ruby in this regard, then
<companion_cube>
except it's small and fast :D
<companion_cube>
(the syntax is incredible short, actually)
<MercurialAlchemi>
yeah, no one ever accused Ruby of being that
wiredsister has quit [Ping timeout: 240 seconds]
<MercurialAlchemi>
companion_cube: isn't it from Brazil originally?
<companion_cube>
yes
_berke_ has joined #ocaml
butts_butts has joined #ocaml
Algebr` has quit [Ping timeout: 250 seconds]
aantron has quit [Remote host closed the connection]
butts_butts has quit [Remote host closed the connection]
djellemah_ has joined #ocaml
<flux>
lua is pretty nice. for a dynamic language.
<companion_cube>
it looks nice for being embedded into a static language
<flux>
and pretty fast to learn. I wrote a game with a colleague during a weekend (hackfest), though he brought in some domain knowledge and basic engine.
<flux>
but the experience didn't compell me into writing more lua-based stuff, I have ocaml.. ;)
<companion_cube>
I'd think it's nice for embedding into, say, a heavy rust program
<flux>
but! if I chose to write an ocaml program where essential funtionality is provided by user-written scripts, I would certainly consider it
<flux>
in particular as someone has written ocaml-lua :)
<companion_cube>
^
<flux>
sadly it might even be easier to use ocaml-lua than plain ocaml for that purpose :)
_berke_ has quit [Remote host closed the connection]
jwatzman|work has joined #ocaml
silver has joined #ocaml
nicoo has quit [Remote host closed the connection]
nicoo has joined #ocaml
<snhmib>
is it so hard to load another ocaml program?
<companion_cube>
dynamically? yes, you'd need the compiler
ygrek_ has joined #ocaml
<snhmib>
for lua you need one also?
<flux>
it's available as a library
<snhmib>
why is it harder to load ocaml code than foreign code?
<snhmib>
oh ok
ygrek has quit [Ping timeout: 248 seconds]
<snhmib>
ocaml doesn't have like a dlopen kind of thing? :(
<flux>
it does, Dynlink
<flux>
but it only deals with stuff that's been compiled already
<flux>
and the stuff must be on the filesystem as well
<companion_cube>
lua isn't really compiled, and anyway the interpreter is tiny (a few hundreds kB)
<flux>
a compiler&linker&loader library for ocaml, completely modularized to allow custom storage would be pretty cool ;)
<flux>
oh and errors should come in a structured fashion as well
<companion_cube>
but it would still be bigger, I think :)
<companion_cube>
I agree it would be nice
<flux>
oh and you should be able to suspend&resume the compiler, as in to allow incremental compliation of one file ;)
<flux>
suspend & store the state & resume from arbitrary state
<flux>
well, a man can dream!
<flux>
and then once it arrives, I can say "cool!" and carry on without using it.. ;)
<companion_cube>
heh
<companion_cube>
I know what you mean
ygrek_ has quit [Ping timeout: 244 seconds]
Nazral has joined #ocaml
Sim_n has joined #ocaml
Simn has quit [Ping timeout: 240 seconds]
Algebr` has joined #ocaml
jwatzman|work has quit [Ping timeout: 250 seconds]
jwatzman|work has joined #ocaml
jwatzman|work has quit [Client Quit]
<flux>
companion_cube, no --< in CCList.Infix?-(
<flux>
and -- is unable to create an empty range as well :/
<companion_cube>
currently, no, indeed
<companion_cube>
-- is bidirectional, but it's inclusive
<companion_cube>
if you want I can add (---) for exclusive range, or something
<flux>
I think -- and --- are too close to each other, and --<, as pervert it might be, communicates the significance of the end-point better
<flux>
I certainly would wonder which if -- and --- is exclusive, but I think --< is pretty clear.. :)
<companion_cube>
but what would be ascending -- that excludes the upper bound?
<flux>
(s/and/or/)
<flux>
I would failwith if upper bound is less than left bound for --<
<flux>
invalid_argument or something.
<companion_cube>
oh ok, I thought it was for decreasing ranges
<flux>
I really don't have an idea what kind of code would dynamically benefit from swapping range direction..
<companion_cube>
but you would still want decreasing ranges
<flux>
I can use List.rev.. :)
lokien_ has joined #ocaml
<flux>
I think decreasing ranges are not so common that an operator is warranted.
<companion_cube>
ok, I can add --<, but it won't be available before next release
<companion_cube>
oh, there is range' btw
<companion_cube>
it's not infix, but still
<flux>
not everything needs an operator :)
<flux>
do I get the --< also for CCVector and friends?-)
<companion_cube>
heeeh
<flux>
that's a very nice syntax you chose
<companion_cube>
add an issue then, I'll do it later
<companion_cube>
(which syntax?)
<flux>
the CCVector.(1 -- 10)
nicholasf has joined #ocaml
<companion_cube>
ah, yeah, it's from batteries actually
<flux>
oh :-), I had completely missed that
nicholasf has quit [Client Quit]
<flux>
of course it depends on nobody opens CCVector, but nobody does that, right.. :)
djellemah_ has quit [Ping timeout: 250 seconds]
<companion_cube>
well I don't, do as you will :p
<flux>
hmm, I wonder though, isn't it asymmetric to have CCList.Infix.(--) and then CCVector.(--)?
<companion_cube>
I need to add CCVector.Infix, indeed
<companion_cube>
but there is also CCList.(--)
<flux>
so what happens to CCVector.(--) in that case?
<companion_cube>
it stays
<companion_cube>
Infix is just so you can open it without also importing the non-infix values
<flux>
oh, ok, so I get to open just the Infix module if I want, that's nice
<companion_cube>
yep, same as Lwt
<companion_cube>
(and others)
_andre has joined #ocaml
<flux>
I wrote an issue! eloquent long prose!
antkong has quit [Quit: antkong]
<companion_cube>
heh!
butts_butts has joined #ocaml
Algebr` has quit [Ping timeout: 248 seconds]
malc_ has joined #ocaml
sillyotter has joined #ocaml
sillyotter has quit [Client Quit]
butts_butts has quit [Ping timeout: 244 seconds]
octachron has joined #ocaml
jwatzman|work has joined #ocaml
<Nazral>
Hi
<Nazral>
I'm learning to use js_of_ocaml, and I have an issue with xmlhttprequest: I make a successful request req and I would like to do dom_element##textContent <- req##responseText. I was expecting this to work but it doesn't
<Nazral>
I'm not sure how to solve that
bobry has joined #ocaml
<flux>
this process may be good for solving issues involving eliom or js_of_ocaml: post code online (ie. pastebin, github), then ping drup 8-)
<Nazral>
Oh I'm wrong, it seems that my problem comes from how I define pre
<Nazral>
http://pastebin.com/pBpG9RRt this solves the error with how I declare the "pre" tag but I still have "Error: This expression has type Js.js_string Js.t but an expression was expected of type Js.js_string Js.t Js.opt"
Algebr` has joined #ocaml
JacobEdelman_ has joined #ocaml
<Drup>
how dear, that's so low level
<Drup>
That looks like javascript, it's terrible
<Nazral>
sorry
<adrien>
"that's so low level. that looks like javascript.3
<snhmib>
but the type it says it is and the expected type are the same!
<snhmib>
if i combine the functions create_model and create_view in a single function it works fine
hyperboreean has joined #ocaml
Algebr` has joined #ocaml
<octachron>
snhmib, have you tried to add a type annotation to the model argument of create_view?
<snhmib>
how do i do that with a named argument?
<octachron>
~model:(model:GTree.tree_store)
<snhmib>
oh an extra model ok :)
<octachron>
the second "model" is the variable name: the full syntax is ~label:(variable_name:type_constraint)
<snhmib>
cool, thanks!
<snhmib>
it worked :D
<Nazral>
Drup: what's the proper way to use Dom_html.setTimeout ?
<octachron>
snhmib, after verification, "~(model:GTree.tree_store)" works too
nicoo has quit [Remote host closed the connection]
tennix has joined #ocaml
nicoo has joined #ocaml
djellemah_ has joined #ocaml
djellemah has quit [Ping timeout: 255 seconds]
<Nazral>
Ok I'm a bit lost, I'd expect http://tyruiop.org/~tyruiop/test.ml to work, but the timeout doesn't happen and the firefox console tells me "uncaught exception: 0,248,Failure,-3,unix_select not implemented"
<companion_cube>
you must be using some Unix-dependent code in js_of_Ocaml
<Drup>
Nazral: don't use Lwt_main
<Drup>
you don't need it
<Drup>
When you want to launch a task in background, just use Lwt.async
<Nazral>
ok
Algebr` has quit [Ping timeout: 240 seconds]
hcarty1 has joined #ocaml
<Nazral>
It all works fine now, thanks :)
tane has joined #ocaml
JacobEdelman_ has quit [Ping timeout: 250 seconds]
<Drup>
Note that you can achieve the same effect as setTimeout in a nicer way, with Lw_js.sleep
<Nazral>
I imagine Lwt allows to do similar things somehow
butts_butts has quit [Ping timeout: 244 seconds]
<Drup>
Yes
struk|desk|away is now known as struk|desk
dexterph has quit [Remote host closed the connection]
djellemah_ is now known as djellemah
AlexRussia has quit [Quit: WeeChat 1.4-dev]
dexterph has joined #ocaml
sh0t has joined #ocaml
bobry has quit [Quit: Connection closed for inactivity]
orbifx has joined #ocaml
Algebr` has joined #ocaml
butts_butts has joined #ocaml
<orbifx>
How do you deal with integer overflowing?
Mercuria1Alchemi has joined #ocaml
<zozozo>
I don't, :p
<zozozo>
actually, I usually use relatively "small" integers, and I use Zarith when I need arbitrary precision integers
<mrvn>
orbifx: I should add bindings for gcc's overflow hellper functions.
Algebr` has quit [Ping timeout: 240 seconds]
<orbifx>
mrvn: you should? To what?
<Drup>
orbifx: zarith
<mrvn>
orbifx: so you can do "a * b < c" without overflow screwing it up
<orbifx>
In zarith?
<orbifx>
I'm was doing some additions and noticed the issue. Then wondered what the typical approaches around it are. Using some expressions or libraries..
kushal has joined #ocaml
JacobEdelman_ has quit [Quit: Connection closed for inactivity]
<orbifx>
What is the "expense" of using bignum libraries, like zarith?
<freehck>
people, I forgot one thing: are object fields accessible directly outside the object?
<freehck>
I remember that I could define accessors and mutators, but could they be modified by something outside the class definition?
<mrvn>
# let foo = object val x = 1 end foo#x;;
<mrvn>
Error: This expression has type < > It has no method x
<freehck>
mrvn: x is not a method, it's specifically a field.
<mrvn>
freehck: does that answere your question?
<freehck>
no, I want to be sure that there's no way to access object fields outside the object.
<freehck>
*no other way except of methods.
<mrvn>
there isn't
<malc_>
незачто
<malc_>
whops
<freehck>
oh, russians. :)
srcerer_ has joined #ocaml
tg` has joined #ocaml
srcerer has quit [Ping timeout: 240 seconds]
maker has quit [Ping timeout: 240 seconds]
tg has quit [Ping timeout: 240 seconds]
Haudegen has quit [Read error: Connection reset by peer]
tg` is now known as tg
butts_butts has quit [Remote host closed the connection]
al-maisan has quit [Ping timeout: 240 seconds]
al-maisan has joined #ocaml
<Drup>
orbifx: bigint is expansive, zarith is not
<Drup>
small integers in zarith are normal integers
<Drup>
(and big integers uses gmp, which is very fast)
Haudegen has joined #ocaml
maker has joined #ocaml
<orbifx>
Drup: does it do conversions only when necessary?
sh0t has quit [Ping timeout: 250 seconds]
<zozozo>
orbifx: as far as i know, yes it does conversion automatically
<zozozo>
ah sorry, read too fast, don't know about only necessary
<orbifx>
Nice. Thanks.
<Drup>
orbifx: only when overflow is happening, yes
<Drup>
I'm not sure if it converts back when you get small integers, I don't think so
<orbifx>
Ow ok
<Drup>
It's magical, yes
<orbifx>
I've Scaled my values for now.
<orbifx>
Hehe
<Drup>
zarith even got a good api
<Drup>
x)
<companion_cube>
it only lacks doc
badon_ has joined #ocaml
badon has quit [Disconnected by services]
badon_ is now known as badon
copy` has joined #ocaml
Algebr` has joined #ocaml
eeks_ has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 252 seconds]
Algebr` has quit [Ping timeout: 255 seconds]
th5 has joined #ocaml
Algebr` has joined #ocaml
slash^ has joined #ocaml
ygrek_ has joined #ocaml
octachron has quit [Quit: Leaving]
<j0sh>
companion_cube: read the code for sequence last night, blew my mind. there are a lot of nice little tricks in there for something so easy to read...
shinnya has joined #ocaml
<companion_cube>
it's fun playing with continuations!
<companion_cube>
although I find sequence easier than gen, where you have to think in state machines
<j0sh>
i've been trying to figure out where i would use gen instead of sequence?
<companion_cube>
when you want to consume a stream of values bit by bit (lexer, IO, in general)
<j0sh>
ah, streams?
<j0sh>
got it
<companion_cube>
well I mean, if you want to read a file line by line, gen might be better
<companion_cube>
but in general I use sequence by default
<companion_cube>
for handling values inside OCaml
<j0sh>
yeah, i really like how lists are basically zero-cost to convert
<companion_cube>
ah yeah, creating a sequence is easy!
<companion_cube>
same for arrays, etc. anything that provides a `iter` function
<j0sh>
didn't notice arrays too... even better
aantron has joined #ocaml
antkong has joined #ocaml
orbifx has quit [Quit: AtomicIRC: The nuclear option.]
th5 has quit [Read error: Connection reset by peer]
ontologiae has quit [Ping timeout: 244 seconds]
sh0t has joined #ocaml
marsam has joined #ocaml
seangrove has joined #ocaml
Ankhers has quit [Quit: Leaving]
etherael has quit [Ping timeout: 240 seconds]
etherael has joined #ocaml
Ankhers has joined #ocaml
marsam has quit [Remote host closed the connection]
kushal has quit [Ping timeout: 250 seconds]
<Nazral>
How do I get something from 'a opt -> 'a in js of ocaml ?
kushal has joined #ocaml
<aantron>
you mean how to call a function that expects an 'a opt?
<aantron>
or how to extract a value of type 'a from a value of type 'a opt?
<aantron>
what if happens if you surround cssfly##textContent in parens?
<Nazral>
.. oh it works
<Nazral>
thanks ! :)
warp has quit [Ping timeout: 244 seconds]
<aantron>
as the error message suggests, the js_of_ocaml syntax extension was interpreting the syntax "a##b (c)" as a method call (ignore the space)
etherael has quit [Ping timeout: 252 seconds]
etherael has joined #ocaml
ketaco has joined #ocaml
<ketaco>
ahh it's a wonderful day
sh0t has joined #ocaml
<seangrove>
Algebr: Does your iOS stuff only work for jailbroken devices?
* seangrove
coughs
<seangrove>
"You do not need to have a jailbroken iOS device to run OCaml,"
kushal has quit [Quit: Leaving]
<Drup>
Nazral: you should use the ppx, not the camlp4 extension.
<Nazral>
Drup: how do I do that ?
<Drup>
js_of_ocaml.ppx instead of js_of_ocaml.syntax
<Drup>
and see the documentation for what the syntax looks like
octachron has quit [Read error: Connection reset by peer]
octachron has joined #ocaml
octachron has quit [Client Quit]
wolfcore has quit [Ping timeout: 244 seconds]
boegel has quit [Ping timeout: 240 seconds]
<Nazral>
Ok
pierpa has joined #ocaml
nojb has quit [Ping timeout: 248 seconds]
wolfcore has joined #ocaml
nicholasf has joined #ocaml
nicholasf has quit [Remote host closed the connection]
yunxing has joined #ocaml
boegel|quassel has joined #ocaml
sh0t has quit [Ping timeout: 250 seconds]
boegel|quassel is now known as boegel
boegel has quit [Client Quit]
boegel has joined #ocaml
ketaco has quit [Quit: Lost terminal]
Mercuria1Alchemi has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
ia0 has quit [Quit: reboot]
ia0 has joined #ocaml
AlexRussia has joined #ocaml
sh0t has joined #ocaml
ggole has quit []
teknozulu has joined #ocaml
kushal has joined #ocaml
nicholasf has joined #ocaml
seangrove has quit [Ping timeout: 244 seconds]
seangrov` has joined #ocaml
<hcarty1>
How do you pass a "raw" pointer to ctypes? To get a pointer to a static value from a C library, for example.
srcerer_ is now known as srcerer
seangrov` has quit [Read error: Connection reset by peer]
teknozulu has quit [Ping timeout: 252 seconds]
Haudegen has quit [Ping timeout: 248 seconds]
chindy has joined #ocaml
<Algebr`>
No
kushal has quit [Quit: Leaving]
Kakadu has joined #ocaml
<chindy>
RealWorldOcaml says that you cannot check whether the first two elements of a list are same using patter matching, but cant you do | x::s::xs when x==s -> _???
<Drup>
Yes
<chindy>
"A pattern can check if a list has two elements, but it can't check if the first two elements are equal to each other."
<Drup>
but "| x :: x :: xs -> ..." doesn't do what you expect
<chindy>
Drup, what does it do ?
<companion_cube>
this should so be a warning
<Drup>
companion_cube: pretty sure it is
<companion_cube>
(I mean a warning enabled by default)
<Drup>
ah, well ...
<companion_cube>
yes, it's unused variable
<chindy>
Try ocaml does not give a warning
<Drup>
The warning is not enabled by default
<chindy>
Drup, also its x::s::xs
<Drup>
No, that's my point
<chindy>
but what does it do that i would not expect it to do ?
<companion_cube>
Drup: indeed, and that's my point
<Drup>
So many points
<Drup>
:D
<chindy>
?
<Drup>
chindy: when you use twice the same variable, it doesn't ensure that both value are the same, the second one will just shadow the other one
<chindy>
Drup, yea but my code is | x::s::xs when x==s -> _
<Drup>
Yes, your code works
<chindy>
so i have x s and a condition x==s
<companion_cube>
careful with that ==, though
<Drup>
(you should use = though, not ==)
<chindy>
okay
<companion_cube>
:D
<Drup>
RWO is talking about my version, which doesn't work
<chindy>
Drup, whats the difference? one is the instance one is equality?