<struktured>
the fact that programs compile at all is in general a miracle
tmtwd has quit [Remote host closed the connection]
<darryn>
Computers are magic
jeffmo has quit [Quit: jeffmo]
BitPuffin|osx has quit [Ping timeout: 258 seconds]
n3ss3s has joined #ocaml
<struktured>
darryn: I fixed it. just remove "Rules." from Rules.allsquares in rules.ml
<struktured>
Rules.all_squares, with underscore, just take out the Module name prefix
<darryn>
give me a second
<darryn>
cool, it works :)
nullcat_ has quit [Ping timeout: 265 seconds]
<struktured>
noice. is the algorithm any good? i didn't bother to look. minimax derivatve?
<darryn>
It is playing fairly well
<darryn>
Do you play chess?
<struktured>
darryn: I used to play alot, now, redhotpawn.com and ocassional bout with friends nearby at a coffee shop
<darryn>
play on lichess?
<struktured>
no, should I?
<darryn>
Yes, it is a very nice website. Has a very nice android app too.
<darryn>
No signin required, if that's your thing
darkf has joined #ocaml
<struktured>
I could use a good app, sign in is fine if its only once ever, for all time. my reddit app is killing me lately. I have to sign in practically every time I use it
<struktured>
darryn: what are your ocaml goals exactly, re: chess?
<darryn>
For hobby/general programming.
<struktured>
what side? gui? portability? ai? analysis?
<darryn>
I am considering switching to haskell, just because the community is larger/gets more support.
<darryn>
Gui and Portability
<struktured>
so cell phone app then?
<struktured>
darryn: well I am throwing my vote for ocaml. I like it. give it a shot a bit longer before switching
<darryn>
I'd rather not work with smart devices
<darryn>
Well, I don't see a down side to switching over, haskell seems to have the upper hand. But like others said, I will probably just end up learning both
<struktured>
Despite your best efforts, you will know many programming languages
<darryn>
That's okay.
c74d3 is now known as c74d
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<darryn>
Does OCaml have good multi-platform support?
<struktured>
I have such a silly utop issue I'm embarrased to report it, but it's driving me nuts. When I ssh to a redhat 6/7 box, utop renders some weird ascii characters and is essentially unusable. Probably a simple fix by changing the terminal settings in some way... anyone else ever run into this?
<struktured>
darryn: eh....its a decent multi-unix platform..windows is spotty but can be accomplished if you care enough. mirage helps if you care that sort of thing, and mobile devices reportedly work with ocaml but I have no experience with it
<darryn>
would haskell work better for multi-platform?
<struktured>
dunno, can ask in their channel if you wish
<darryn>
I will..
ygrek has quit [Ping timeout: 244 seconds]
blandflakes has joined #ocaml
blandflakes has quit [Client Quit]
idegen has quit [Quit: Leaving.]
darryn has left #ocaml [#ocaml]
Pip has joined #ocaml
swgillespie has joined #ocaml
<rgrinberg>
ocaml in theory has good support for cross platform
<rgrinberg>
in practice, no one ever tests anything on m$ wind0ze
<Pip>
:D
<Pip>
Which one is better, Ocaml or Haskell?
<rgrinberg>
since this is #ocaml the answer is clear
<def`>
javascript?
<Pip>
Scala?
<rgrinberg>
def`: did you know that a tiny unpopular language like ocaml has better auto complete than js who probably had 1000x the engineering man years :P
<rgrinberg>
and as a bonus, the auto complete was made by a couple of college kids
<def`>
rgrinberg: you can't be serious!
<Pip>
lol
<Pip>
Google was created by some college kids
<rgrinberg>
Pip: search is much easier than js auto complete
<Pip>
Oh
<Pip>
Sounds like high end AI
nullcat_ has joined #ocaml
<def`>
see, if js is harder to complete its because its more powerful
<rom1504>
clearly :p
mcc has joined #ocaml
<Pip>
I see
<rom1504>
anyway, you're called Pip , so you should use python
<Pip>
I did learn Python
<Pip>
But I also want to try something new
<rom1504>
you won't be able to do pip install in ocaml :p
<Pip>
I don't use Python much
<Pip>
Is Java a terrible language?
<def`>
Yes ?
<Pip>
Why?
<Pip>
I never liked Java, I don't know why
<def`>
From a type system pov: omnivariant arrays
sh0t has quit [Remote host closed the connection]
<def`>
From a software engineering pov: having to manually write names such as AbstractTemplateFactory just highlight how much the language is poor at abstracting
<def`>
how poor the language is at abstracting*
<mcc>
There is definitely a lot of repetitive typing in Java :( And the platform is kind of heaviweight.
<Pip>
True
manizzle has joined #ocaml
<dmbaturin>
There's a book "how to get around C++/Java limitations", also known as "design patterns".
<Algebr>
lol
<Pip>
dmbaturin, Are you serious?
<Pip>
I know the book "Design Patterns"
<Pip>
It's all about patterns in OOP
troydm has quit [Ping timeout: 264 seconds]
<dmbaturin>
Yep. How many of them are still applicable in more expressive languages? :)
<def`>
(-: time to sleep, good night!
psy_ has quit [Ping timeout: 256 seconds]
<Pip>
Good night
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
<mcc>
i do not disagree with dmbaturin's comment necesarily
Algebr has quit [Ping timeout: 272 seconds]
samg_ has joined #ocaml
ygrek has joined #ocaml
MrScout has quit [Ping timeout: 265 seconds]
jabesed has quit [Ping timeout: 256 seconds]
<paarth>
Honestly I consider any language that allows naive object downcasting to be unsafe
<dmbaturin>
mcc: It was not meant as _entirely_ serious of course, but among that book fans there's a trend to consider those patterns fundamental.
<dmbaturin>
SomeDamnBody: Does a trivial script that uses findlib, such as #use "topfind";; let () = print_endline "worked" work?
<SomeDamnBody>
I fired up utop and that worked
<SomeDamnBody>
apparrently, I was just new to oasis and ocamlbuild
<SomeDamnBody>
I am impressed and finding it surprisingly easy and high quality :)
<paarth>
let's say I've got a number of items that are going to follow the same pipeline. I could do something like " [a';b';c'] = [a;b;c] |> List.map pipeline_func "but that results in warnings about pattern incompleteness. Is there a better way of handling this case?
<dmbaturin>
paarth: I think the non-exhaustive warning is safe to ignore in this case (since there's no chance map will make a [] out of [a;b;c]).
<paarth>
dmbaturin, I agree, but my vain desire for clean build output forced me to ask
<paarth>
thanks
<dmbaturin>
What's the context?
<dmbaturin>
The list is always three items long?
<paarth>
dmbaturin, yes
<dmbaturin>
I'd probably make it a tuple (or record), although I'd have to define a "map" for it and it would be a bit repetitive.
agarwal1975 has quit [Quit: Connection closed for inactivity]
<dmbaturin>
Or make it work with lists of any length, if the number of items is inherent to the implementation rather than the problem.
<paarth>
yeah. This is me being a bit lazy and not wanting to retype the pipeline bit
<paarth>
you know if I was being truly committed to being lazy this might be a good moment to play with ppx
MrScout has joined #ocaml
dtscode is now known as notdtscode
SomeDamnBody has quit [Ping timeout: 252 seconds]
notdtscode is now known as charmander
MrScout has quit [Remote host closed the connection]
wraithm has quit [Ping timeout: 272 seconds]
sepp2k has joined #ocaml
psy_ has joined #ocaml
jonludlam has quit [Ping timeout: 240 seconds]
Pip has joined #ocaml
Pibian has joined #ocaml
manizzle has quit [Remote host closed the connection]
Pip has quit [Ping timeout: 256 seconds]
rgrinberg has quit [Ping timeout: 250 seconds]
amnn has joined #ocaml
rgrinberg has joined #ocaml
manizzle has joined #ocaml
Bhavya has joined #ocaml
Pibian has quit [Changing host]
Pibian has joined #ocaml
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Bhavya has quit [Quit: Quit the channel]
SomeDamnBody has joined #ocaml
tinhead has joined #ocaml
obadz has quit [Ping timeout: 255 seconds]
obadz has joined #ocaml
SomeDamnBody has quit [Ping timeout: 272 seconds]
natrium1970 has joined #ocaml
Haudegen has quit [Ping timeout: 272 seconds]
Simn has joined #ocaml
tinhead has quit []
Pibian has quit [Ping timeout: 256 seconds]
Pibian has joined #ocaml
charmander is now known as notdtscode
natrium1970 has quit [Quit: natrium1970]
jonludlam has joined #ocaml
Haudegen has joined #ocaml
jonludlam has quit [Ping timeout: 265 seconds]
TheLemonMan has joined #ocaml
mcc has quit [Quit: This computer has gone to sleep]
noze has quit [Ping timeout: 272 seconds]
maufred has quit [Ping timeout: 264 seconds]
maufred has joined #ocaml
rgrinberg has quit [Ping timeout: 245 seconds]
A1977494 has joined #ocaml
jcloud has quit [Quit: Connection closed for inactivity]
amnn has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<ollehar>
Shouldn't we do that, too? Some great explanations are thrown around here.
<dmbaturin>
ollehar: The question is, where to store them (in the absense of wiki).
<ollehar>
we have no wiki?
<ollehar>
:(
<ollehar>
let's just store them in the haskell wiki, then ;)
<dmbaturin>
ocaml.org maintainers are usually responsive, but the development process with pull requests approved by maintainers is not well suited for quick edits.
sdothum has joined #ocaml
<ollehar>
gah, no, pulling is not good for that
<dmbaturin>
I don't think ocaml.org should be open to unapproved edits of course, but a wiki complementary to it could be a good thing too.
<ollehar>
wiki.ocaml.org?
<ollehar>
\o/
<flux>
how big a deal is it? it appears github just gives an 'edit' button which does the forking&editing for you. you still need to pr it?
<flux>
you of course need to have a github account.
<ollehar>
too technical, imo
<flux>
I suppose at least the link to the edit button of the particular page could be on each page
<dmbaturin>
flux: Sure. I didn't try the edit button (I just clone it the usual way and edit locally), but the patch still has to go through the maintainers anyway.
<ollehar>
a wiki would have a better "feeling"
<flux>
dmbaturin, I'm quite sure it wouldn't be a bottle neck..
<ollehar>
and welcome contributions more
<flux>
wikis tend to end up disorganized
jonludlam has joined #ocaml
<ollehar>
just need to disciplne the access rights in the wiki
<ollehar>
points and stuff like in stackoverflow
<flux>
there is already stackoverflow :)
<flux>
asking for access rights is even a bigger boundary of contribution IMO
<dmbaturin>
flux: From my experience, merging a non-controversial patch into ocaml.org still a week or more. Maybe adding more maintainers could speed it up, but there's no way it can be instant.
jabesed has quit [Ping timeout: 265 seconds]
<flux>
well, it can be instant if you have direct editing abilities in the pages, comparable to a standard wiki account?
seanmcl has joined #ocaml
<flux>
I think the maintainers wouldn't like to deal (at all) with vandalism.
<ollehar>
stackoverflow is NOT a wiki, the mods there are too strict.
<flux>
in any case, how do you add 'points and stuff like in stackoverflow' to a site? is there a pre-existing solution for that?
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
<dmbaturin>
flux: Well, that's why I say a wiki should be separate, complementary to ocaml.org
<ollehar>
uhm, don't know. just pulled that out of my ass. how is it done on wikipedia?
Algebr has joined #ocaml
<flux>
wikipedia doesn't have points, does it?
<ollehar>
probably not, but they must have some system...
<dmbaturin>
A type inference captcha could be used to prevent spam and vandalism by incompetent people. ;)
<flux>
I don't know Wikipedia has its software available publically
<adrien_znc>
it's fine but the issue is that they think it's the same as ocaml and that ocaml therefore has a non-existant ecosystem
<Drup>
companion_cube: except the tooling for ocaml doesn't work for camllight
<Drup>
(and what adrien_znc said)
<companion_cube>
what tooling?
<companion_cube>
seriously, those students are happy with camlWin (or winCaml, can't remember)
<companion_cube>
they won't use libraries anyway, nor modules
<Drup>
no, they are not happy with it
<Drup>
they just don't have the choice
<adrien_znc>
yes but then they think you need to use Graphics
<companion_cube>
well, what's better than graphics for them? don't tell me jsoo
<adrien_znc>
haha
<adrien_znc>
nah but they think there's nothing else
<adrien_znc>
so they finish their studies while believing ocaml can't be used for anything
<companion_cube>
maybe there should be more emphasis on caml <> OCaml
<Drup>
or maybe they should just use ocaml and remove camllight because it's a completely useless distinction ?
<Drup>
it's just an artefact from 15 years ago
<companion_cube>
and then poor students can't write functions in french :)
<Drup>
companion_cube: they can, if their file is in latin1
idegen has joined #ocaml
<thizanne>
last time I tried, the windows ocaml toplevel could randomly (?) fail
<companion_cube>
Drup: ... really?
<thizanne>
we didn't have these problems with caml light, and they are relevant when everybody programs by copy-pasting some file content in the toplevel
<companion_cube>
let yoplaît = Mangé would work?
<Drup>
thizanne: winCaml is not the most stable thing ever either
<flux>
Warning 3: deprecated: ISO-Latin1 characters in identifiers
<companion_cube>
you didn't try camlWin, it's much better
<companion_cube>
or win caml
<companion_cube>
fuck it, can't remember the good one
<Drup>
companion_cube: it produces a warning, but you can
<companion_cube>
yaay
<companion_cube>
then, if there was a decent IDE for OCaml on windows, it could be worth the change
<adrien_znc>
IDE?
<adrien_znc>
='(
<companion_cube>
something you can write code in, and eval the code easily
<companion_cube>
please don't say 'emacs'
<Drup>
ocamltop ?
<companion_cube>
I don't know, does it really work?
<companion_cube>
is it installable on windows? :p
<companion_cube>
I mean, it's probably using ocp-build
<Drup>
well, ocp-build works on windows
<companion_cube>
opam init default 4.01.0+ocp-bin ← oh god
<flux>
I guess caml light doesn't support utf8 identifiers either
<adrien_znc>
companion_cube: I tried emacs when I started with ocaml
<adrien_znc>
I stopped because it made my pinky hurt
<adrien_znc>
flux: Ctrl and Fn keys were inverted (laptop)
<q66>
ctrl - fn is the right order :)
tmtwd has joined #ocaml
<adrien_znc>
try C-w on a azerty keyboard with inverted fn and ctrl keys
<q66>
if it's a thinkpad (which gets the default order wrong) you can swap it in bios
<q66>
and you can also stop using azerty :)
<thizanne>
if you use emacs, you should bind control on caps-lock anyway
<thizanne>
(and I guess vim users do the same with esc)
<q66>
i have even better way
<q66>
stop using emacs
<q66>
:)
<Drup>
That was a very interesting set of recommendation, thank guys. :3
<adrien_znc>
q66: wasn't, but that was also 10 years ago
<adrien_znc>
but that made me try vim
<adrien_znc>
and I liked it
rgrinberg has joined #ocaml
Cyanure has joined #ocaml
hay207 has quit [Remote host closed the connection]
<companion_cube>
thizanne: in vim, ctrl-c is a perfectly good escape
AltGr has left #ocaml [#ocaml]
Gama11_ has joined #ocaml
Gama11 has quit [Ping timeout: 265 seconds]
<sh0t>
HI guys I installed oasis (on ubuntu) with opam but now if i type oasis setup -setup-update dynamic it says it's not installed...
<sh0t>
nvm i solved
<sh0t>
:)
milosn has joined #ocaml
rgrinberg has quit [Ping timeout: 272 seconds]
wraithm has joined #ocaml
Gama11 has joined #ocaml
Gama11_ has quit [Ping timeout: 276 seconds]
A1977494 has joined #ocaml
rgrinberg has joined #ocaml
A1977494 has left #ocaml [#ocaml]
<sh0t>
guys can someone help me with oasis?
<companion_cube>
well, ask
mhi^ has left #ocaml [#ocaml]
<sh0t>
sure so I have this project which at the moment I compile "by hand". The project is divided in a few files and the main is in the file, say, Main.ml. How do I specify in the file _oasis the dependencies ?
<sh0t>
the other files are not declared as modules...
<companion_cube>
oasis uses ocamlbuild, which is able to find (simple) dependencies by itself
<companion_cube>
if a.ml uses module B, ocamlbuild searches for b.ml in the same directory
<companion_cube>
for a simple project, you can have Executable foo Path: src/ MainIs: main.ml
<sh0t>
so I don't need to specify dependencies?
<companion_cube>
in simple cases, no
<flux>
and I think most programs are simple cases
<sh0t>
yeah flux at least in my case
<sh0t>
companion_cube, but the other files need to be declared as "modules"? SOrry I am not really familiar yet with module system of ocaml
<flux>
if you refer to module B, ocaml compiler knows to look for b.ml
<companion_cube>
Modules: A, B, C ... is used for libraries
<companion_cube>
because a library just contains modules that do not necessarily depend on one another
<flux>
and so does the ocamlbuild autodepedency system
<companion_cube>
whereas an executable has a main module, and its dependencies
<sh0t>
ok sorry I thkn you are underestimating my ignorance..:) I rephrase: I am not using the keyword "module". I just have a file and in it i "open" some other files.
<flux>
it's ok :)
<flux>
if you don't have "pack modules" then you don't need indicate dependencies
<flux>
and if you don't know what "pack modules" are, then you are not using them :)
<flux>
you can just stick a bundle of .ml-files in a directory and ocamlbuild foo.byte fill find out the module foo.ml and its dependencies automatically
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<sh0t>
so if i run oasis setup i get the configure and the Makefile...so then i run configure...seems to work...if i run make...i get this http://paste.ubuntu.com/11544583/
<sh0t>
ok i just moved away those files...
<sh0t>
but how do i make this automatic?
kdef has joined #ocaml
<sh0t>
i mean i dont' wanna run by hand ocamllex and ocamlbuild
Sim_n has joined #ocaml
tane has joined #ocaml
<flux>
oasis setup.ml -build seems to do it
<flux>
and ocamllex is automatically dealt with ocamlbuild
<flux>
if you have .mll-files
<sh0t>
mm ok
<sh0t>
lemme try
Simn has quit [Ping timeout: 276 seconds]
<sh0t>
Files parser.mly and parser.ml should not be together in src
<sh0t>
Files parser.mly and parser.mli should not be together in src
<sh0t>
flux, yo meant ocaml setup.ml -build right?
<flux>
yes
<flux>
well, it's right
<octachron>
sh0t: were the parser.ml{i} generated from parser.mly?
<flux>
you shouldn't have both parser.ml and parser.mly
rgrinberg has joined #ocaml
<flux>
I guess it requires to not have the .mli either
<sh0t>
yes octachron
<sh0t>
well i only want to have the mly...and generate the ml from it
yomimono has quit [Ping timeout: 246 seconds]
freling has quit [Quit: Leaving.]
leafac has joined #ocaml
<flux>
remove the .ml and .mli files then
<Denommus>
sh0t: it will be generated, don't worry
<octachron>
shOt: you don't need to have these files in your source directory, ocamlbuild will automatically generate them and place them in the _build directory
<Denommus>
sh0t: it just won't be the same place your mly file is
<sh0t>
File "parser.mli", line 43, characters 48-56:
<sh0t>
Error: Unbound module Ast
<sh0t>
this if i run ocaml setup.ml -build after the configure
<flux>
where is the Ast module defiend?
leafac has quit [Read error: Connection reset by peer]
<Denommus>
sh0t: before anything, are you producing a library or a binary?
<flux>
binary
<sh0t>
binary Denommus
<Denommus>
sh0t: do you have an ast.ml and ast.mli on the same directory as parser.mly?
<sh0t>
nope
<sh0t>
i have lexer.mll lexer.mll _oasis parser.mly src
<sh0t>
in one dir
<sh0t>
and in src i have all the rest
<sh0t>
only ml files in src
<flux>
so where does Ast come from?
<Denommus>
sh0t: how have you told oasis to handle the src directory, if at all?
<flux>
it wouldn't fail otherwise this way?
leafac has joined #ocaml
badkins has joined #ocaml
<sh0t>
ok in lexer.mll in the section header i open Ast but it doesn't happen anymore and now i get a different errro
<sh0t>
so the problem is that in parser.mly i have this line
<sh0t>
%type <Ast.stmt> main
<sh0t>
and ast is in src
blandflakes has joined #ocaml
<flux>
you have ast.ml in src?
<flux>
hmm, right, now I understand it
<flux>
you should have all the .mll and .mly files in the src directory as well
<sh0t>
ok but then flux it complains "i shouldnt have" those files in the same dir
<flux>
I don't know how ocamlbuild would handle dependencies crossing directories
<flux>
sh0t, have you written parser.mli yourself or generated it?
<sh0t>
the mli
<sh0t>
never created it
<sh0t>
so generated
<flux>
sh0t, let's say it this way: after ocaml setup.ml -clean you should have files lexer.ml, lexer.mli, parser.ml or parser.mli _nowhere_
<flux>
if that is the case, then ocaml setup.ml -build should not complain about having both parser.ml and parser.mly in the same directory, because parser.ml doesn't exist
<flux>
and when it does generate parser.ml, it won't go to the same directory
afiskon has quit [Quit: Leaving]
<flux>
if after the cleaning you have the forementioned files somewhere, remove them
<sh0t>
YEAH
<sh0t>
it works finally
<sh0t>
thanks guys
Submarine has quit [Remote host closed the connection]
<flux>
good time to use git commit ;)
rgrinberg has quit [Quit: WeeChat 1.2]
slash^ has joined #ocaml
badkins has quit [Remote host closed the connection]
<sh0t>
ahah yeah
<sh0t>
how do i clean everything?
<sh0t>
ocaml setup.ml -clean leaves something
<sh0t>
and also oasis setp-clean
gabemc has joined #ocaml
yomimono has joined #ocaml
zpe has quit [Remote host closed the connection]
yomimono has quit [Ping timeout: 252 seconds]
Kakadu has quit [Ping timeout: 246 seconds]
Intensity has joined #ocaml
shinnya has joined #ocaml
yomimono has joined #ocaml
octachron has quit [Quit: Leaving]
yomimono has quit [Ping timeout: 244 seconds]
<sh0t>
so guys a more general question. I am trying to develop an interpreter for a toy language where you only have references to actual data, and where every value is actually stored in arrays of varaible length. How would you go and implement this in ocaml..I 've been reading stuff about "ref" and "array" in ocaml. I guess in this case a lot of the work owuld be handled by ocaml language
<sh0t>
am I right?
leafac has quit [Quit: Leaving.]
MrScout has joined #ocaml
leafac has joined #ocaml
Sim_n has joined #ocaml
<Drup>
sh0t: -distclean
<sh0t>
i still have the configure and the makefile
Simn has quit [Ping timeout: 252 seconds]
tane has quit [Quit: Verlassend]
matason has quit []
matason has joined #ocaml
matason has quit [Client Quit]
MrScout has quit [Remote host closed the connection]
MrScout has joined #ocaml
<Drup>
well yeah, you want to remove that ?
Submarine has joined #ocaml
Submarine has joined #ocaml
nullcat has joined #ocaml
<flux>
sh0t, you probably add the files you want to keep to your git repository and then git clean -d -x --force ;)
<sh0t>
yeah Drup because say i add more files to my project i need to update my makefile right?
ggole has quit []
<sh0t>
ahh right but for simple projects ocaml finds dependencies by itself
<Drup>
sh0t: you don't need to remove them, just do oasis setup again
<sh0t>
ok
<flux>
but are they something you want to add to version control?
matason has joined #ocaml
ygrek has joined #ocaml
matason has quit []
matason has joined #ocaml
yomimono has joined #ocaml
jonludlam has quit [Ping timeout: 265 seconds]
gabemc has quit [Ping timeout: 256 seconds]
jwatzman|work has joined #ocaml
<sh0t>
yes flux
<sh0t>
in general yes
<sh0t>
sometimes i just mess around and it's not worth to commit/push htough...
<sh0t>
from my point of view...
nullcat has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<Drup>
sh0t: if you use setup-dynamic, you don't have to redo the setup.
<Drup>
and it's so thin than you can push it
<Drup>
(it should not be used for release, though)
Haudegen has quit [Ping timeout: 246 seconds]
<sh0t>
mm ok:)
darkf has quit [Quit: Leaving]
Gama11_ has joined #ocaml
badkins has joined #ocaml
simn__ has joined #ocaml
Gama11 has quit [Ping timeout: 258 seconds]
Sim_n has quit [Ping timeout: 252 seconds]
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
cml has quit [Ping timeout: 246 seconds]
sdothum has joined #ocaml
matason has quit []
sdothum has quit [Client Quit]
Anarchos1 has joined #ocaml
sdothum has joined #ocaml
<sh0t>
so guys a more general question. I am trying to develop an interpreter for a toy language where you only have references to actual data, and where every value is actually stored in arrays of varaible length. How would you go and implement this in ocaml..I 've been reading stuff about "ref" and "array" in ocaml. I guess in this case a lot of the work owuld be handled by ocaml language am I right?
swgillespie has joined #ocaml
<Drup>
I'm not really sure what the question is, tbh.
<nicoo>
It should, yes. You don't have to implement toy-language's arrays using OCaml arrays, though
<sh0t>
why ?
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
seanmcl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
waneck has joined #ocaml
seanmcl has joined #ocaml
Haudegen has joined #ocaml
<vbmithr_>
Is there a way to figure out what happens before an out of memory error ?
ygrek has quit [Ping timeout: 250 seconds]
<vbmithr_>
I mean, I'd like to see the allocations
<smondet>
orbitz: in `revops_fn.mli` the type 'a OpRev.t is abstract so there is no way to make it match anything
mengu has quit [Remote host closed the connection]
Hannibal_Smith has quit [Quit: Leaving]
mengu has joined #ocaml
mengu has quit [Remote host closed the connection]
<Denommus>
in Lwt, is there a function equivalent to (>>=), but that ignores the argument to the second function? (Like Haskell's (>>))
xificurC has quit [Ping timeout: 272 seconds]
leafac has quit [Quit: Leaving.]
badkins has quit []
__hx_waneck has quit [Read error: Connection reset by peer]
<flux>
even if there was (ie. you can just write let (>>) a b = a >>= fun _ -> b), it could be annoying because of side effects
leafac has joined #ocaml
waneck has joined #ocaml
<flux>
I think though that Jane Street Core comes with that kind of syntax extension, that does >>= but for unit functions, by means of syntax transformation
_hx_simn is now known as Simn
<Denommus>
flux: won't the side effects be "wrapped" inside Lwt.t anyway?
<flux>
no. consider return (i := 42) >> return (i := 45). it's not very different from foo (i := 42) + bar (i := 55)
<flux>
except for the numbers :)
<flux>
you need to have a function to postbone the evaluation of the right side
willy_ has joined #ocaml
<flux>
though my example is a bit malformed, oh well..
<flux>
actually it's probably ok if I used the syntax extension?
wwilly has quit [Ping timeout: 264 seconds]
<Denommus>
ok, then
Hannibal_Smith has joined #ocaml
matason has joined #ocaml
nopf has joined #ocaml
<Algebr>
Async had >>> I thought
kushal has quit [Ping timeout: 276 seconds]
_andre has quit [Quit: leaving]
<flux>
oh, maybe, I haven't used it
ncthom91 has joined #ocaml
willy_ has left #ocaml ["Leaving"]
<sh0t>
guys I am trying to define a new type to describe arrays of int references...i am trying with something like this: type numericRefArray={size: int; capacity:int; v: (ref 0) array};; of course it doesnt work. I tried to set int instead of 0 there which i think shouold be the right thing to do but it doesnt work either
ncthom91 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<zozozo>
sh0t: why would you want references in an array ?
<zozozo>
cells in arrays are already mutables
<sh0t>
mmm...so i am trying to implement this toy language where everything is an array of references...like int are just array of size of which point to an integer...
<sh0t>
*of sieze 1
<sh0t>
*size
<zozozo>
ok, but in the internal representation, you don't have to put references, since arrays are already mutable in ocaml
<zozozo>
also, do you nedd growable arrays, or arrays with fixed size are enough ?
<zozozo>
*need
<sh0t>
growable
<sh0t>
can i ask you how you would do that?
<zozozo>
ok, then the best way to do it, I think, is to first define a new type 'a vector, which is the type of growable arrays which contains values of type 'a
<zozozo>
sh0t: basically, you use an array of fixed size, until you d'ont have enough space left, in which case you reallocate a new bigger array and copy all contents
<sh0t>
sure but in this case i'd have an array of 'a not an array of ref 'a...or are u saying that's actaulyl what i'd get
<nullcat>
you dont't need to explicitly do pattern matching on record to extract the field
<nullcat>
......
<Drup>
it's equally effective with IRC instead of rubber ducks :D
<ollehar1>
also, use option or result instead of exceptions...
<sh0t>
Drup, ahah i am gonna go get a rubber duck asap
<sh0t>
nullcat, u mean i should just use dot notation?
<sh0t>
ollehar1, i don't know what they are yet...
<nullcat>
yes, dot is just fine
<ollehar1>
option = Some 'a | None
<ollehar1>
instead of nullable variables
<ollehar1>
So return None when no result, and Some 'a with there's a result
<ollehar1>
*when
<sh0t>
ahh like Maybe in haskell
Tekilla has joined #ocaml
<sh0t>
here we are with monads...:/
mort___ has left #ocaml [#ocaml]
kdef has joined #ocaml
<dmbaturin>
Well, option/maybe only becomes a monad when you implement corresponding bind and return. Nothing prevents you from using it in non-monadic fashion.
<dmbaturin>
You can use it as a functor (in haskell sense) rather than monad as well. :)
seanmcl_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ollehar1 has quit [Quit: ollehar1]
waneck has quit [Ping timeout: 250 seconds]
<sh0t>
yeah i really need to study category theory to really understand these things.
<Drup>
no you don't
swgillespie has joined #ocaml
<sh0t>
well let's just say I'd like to
<sh0t>
i am mostly interested in the theory of pl
<sh0t>
but yeah also practice a lot.
<nullcat>
watched a category theory course online, almost fell asleep after 15 mins. you don't need to understand them to write ocaml...
<dmbaturin>
nullcat: Which one?
<nullcat>
oregon summer school programming languages...
<nullcat>
i do really want to finish "types and programming language" this summer, which is already pretty theoretical to me..
<sh0t>
well i don't just wanna write ocaml but yeah i think u dont "need" cat.theory to program
<nullcat>
and if you understand theoretical stuff, it's definitely much better (like drup)
<nullcat>
yeah
<nullcat>
it's always good to know. i am not against it
<sh0t>
yeah
<Drup>
heeeh
<Drup>
I have no knowledge of category theory whatsoever
<nullcat>
well, i mean you know some theoretical knowledge (i saw that popl paper...)
<Algebr>
Uh, is there a way to overload compare ?
<Drup>
ah yes, I did the implementation of that :3
<nullcat>
:3
<dmbaturin>
sh0t: What's fun is that the paper that introduced monads doesn't even mention category theory. :)
<Drup>
dmbaturin: which one ?
<dmbaturin>
Drup: Wadler's Monads for Functional Programming.
<sh0t>
i htink the one of moggi was even earlier than that
<Drup>
ok, introduced monads *as a programming paradigm*
<Drup>
it's not the one introducing the concept :p
<dmbaturin>
Well, true.
Tekilla has quit [Quit: Quitte]
<dmbaturin>
Algebr: The built-in compare is a bit mysterious to me.
waneck has joined #ocaml
<dmbaturin>
It looks magically overloaded but I have no idea how it's done.
<Algebr>
its really mysterious to me.
<Algebr>
exactly
<Algebr>
I found a C thing in byterun.c, something like caml_runcompare,
<Drup>
it's a function written in C that inspect the memory representation of the object at runtime and decide, based on it, how it's going to compare things
<Drup>
it looks magic because it is.
madroach_ has joined #ocaml
madroach has quit [Read error: Connection reset by peer]
Hannibal_Smith has quit [Quit: Leaving]
<dmbaturin>
So there's no way to extend that magic?
natrium1970 has joined #ocaml
<dmbaturin>
* Without modifying the runtime.
w0rp has joined #ocaml
<zozozo>
dmbaturin: write your own functions in C and use bindings to them ?
<Drup>
dmbaturin: no
<dmbaturin>
zozozo: Well, I'd need to make the built-in implementation of compare use it somehow.
<zozozo>
ah, I didn't really get that part
<Drup>
dmbaturin: just use your own compare function
<natrium1970>
I’m trying to learn about GADTs, and I’ve been playing with the code from http://mads-hartmann.com/ocaml/2015/01/05/gadt-ocaml.html. How would I write the *eval* function so that it uses syntax like “ let get (type el) (x:el t) i : el = match x with ….” ?
<Drup>
natrium1970: you can't
<Drup>
:/
<nullcat>
#drupsaiditsnotok
<Drup>
it's not that it's not ok, it's that the syntax doesn't exist :(
<natrium1970>
What is it about their example (Janestreet) that make it compile and mine not?
Gama11_ has quit [Remote host closed the connection]
<Drup>
natrium1970: your function is recursive
<natrium1970>
Oh.
<Drup>
so, there are actually two notation
<Drup>
'a . ....
<Drup>
that is for polymorphic recursion
<Drup>
and "(type x) ..." which you used, to introduce an abstract type
<Drup>
and "type x . ..." do both at once
<paarth>
myself not knowing category theory and being conscious of sounding like a fool: I'm looking at the algebraic effects that we were talking about yesterday and so far my brain tells me this looks like tagging function application with effect state a la state monads
<paarth>
is that sane/stupid?
<Drup>
paarth: it's rather accurate, bur your comparison is weird, because in monads, it's precisely not a function application that is tagged, but a value.
seanmcl has joined #ocaml
<paarth>
Drup, TBH I didn't know that was a limitation people placed on monads. Does that restriction conflict at all with the idea of functions and data as being interchangeable?
<natrium1970>
Any idea why inside *eval*, it’s Eq(a, b) -> (eval a) = (eval b), but Lt (a, b) -> a < b (without eval)?
<Drup>
natrium1970: because it's wrong ? :D
<natrium1970>
It seems to work fine as-is.
<Drup>
well, it will type, because polymorphic comparison
<nullcat>
i think the author wrote it wrong...
<natrium1970>
I tried to make an example that would fail, but I couldn't.
<Drup>
it depends what you mean by fail
<natrium1970>
Give a wrong answer or runtime error.
<Drup>
something with a If
maurer has quit [Ping timeout: 252 seconds]
<natrium1970>
I tried this: printf "%b\n" (eval (Lt (If (Value (Bool true), Value (Int 1), Value (Int 2)),
<natrium1970>
If (Value (Bool true), Value (Int 3), Value (Int 4) ) ) ) )
<Drup>
exploiting than GValue _ < GIf _
maurer has joined #ocaml
<Drup>
5 < if(true, 2, 2)
<Drup>
I think that would be true
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<Drup>
paarth: it's not really a limitation
swgillespie has joined #ocaml
<Drup>
paarth: if you are interested, I think could look at 1) arrows 2) the talk about how the effect system of Idris work
<Drup>
+you
nullcat has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
emias has quit [Ping timeout: 264 seconds]
<natrium1970>
Drup: Thank you. Your example causes it to return a wrong answer (i.e. 5 < 2 evaluates to true). In more general question I had is whether there is a function that ensures that the comparison will be non-polymorphic, especially for int?
madroach_ has quit [Ping timeout: 264 seconds]
<Drup>
not in the stdlib
<Drup>
well
jonludlam has quit [Ping timeout: 265 seconds]
nullcat has joined #ocaml
<Drup>
if the type of the comparison is fully known at compile time, it will use a specialized version
madroach has joined #ocaml
<Drup>
so "4 < x" will always be fast
<natrium1970>
I found an example that was running much slower than expected the other day because the compiler was not able to infer that.
<Drup>
yes, you have to be careful since the compiler doesn't inline (for now)
<natrium1970>
I don’t suppose that there’s an easy way to get the compiler to tell me what type information it was able to get so that I can know for sure.
<zozozo>
checking the type with merlin would work I think
ernst_ has joined #ocaml
zapu has quit [Ping timeout: 240 seconds]
ernst has quit [Ping timeout: 256 seconds]
<sh0t>
guys if i declare in my parser.mly, something like %token <float vector> VECTORFLOAT i get: Error: Unbound type constructor vector
Anarchos1 has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
<sh0t>
but vector is defined in vector.ml as type 'a vector = { mutable size: int; vec : 'a array; }
<sh0t>
and I do open Vector in parser.mly
<Drup>
you can include ocaml code between {% ... %}