nullcat has quit [Read error: Connection reset by peer]
sailorswift has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
sailorswift has joined #ocaml
<def`>
lewis1711: value constructor actually
accidus has joined #ocaml
nullcat__ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
SomeDamnBody has quit [Ping timeout: 250 seconds]
pyon is now known as kawaii-imouto
sp0on has quit [Ping timeout: 252 seconds]
manud has quit [Quit: manud]
sailorswift has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
martinium has joined #ocaml
martinium has joined #ocaml
manud has joined #ocaml
manud has quit [Remote host closed the connection]
SomeDamnBody has joined #ocaml
lewis1711 has quit [Ping timeout: 255 seconds]
jabesed has quit [Ping timeout: 244 seconds]
lewis1711 has joined #ocaml
ygrek_ has quit [Ping timeout: 246 seconds]
badkins has quit []
dvb_ua has joined #ocaml
sp0on has joined #ocaml
sp0on has quit [Ping timeout: 264 seconds]
grouzen has quit [Ping timeout: 252 seconds]
grouzen has joined #ocaml
sp0on has joined #ocaml
sailorswift has joined #ocaml
walter|r_ has quit [Remote host closed the connection]
grouzen has quit [Ping timeout: 264 seconds]
sp0on has quit [Quit: WeeChat 0.4.2]
sp0on has joined #ocaml
zaquest has quit [Ping timeout: 256 seconds]
zaquest has joined #ocaml
ygrek has joined #ocaml
anti-freeze has joined #ocaml
xificurC has quit [Remote host closed the connection]
<anti-freeze>
Hi everyone. I just wanted to say that OCaml is awesome. I went to a coffeeshop at 9 PM to do some work and decided to check it out. Its no 6AM, still sitting there.
<anti-freeze>
now*
xificurC has joined #ocaml
<anti-freeze>
Real World OCaml, such a fantastic book. Kudos the the author(s)
anti-freeze has quit [Remote host closed the connection]
ygrek has quit [Ping timeout: 246 seconds]
SomeDamnBody has quit [Ping timeout: 244 seconds]
<yminsky>
anti-freeze: Thanks! Glad to know it's appreciated.
walter|r has joined #ocaml
walter|r_ has joined #ocaml
anti-freeze has joined #ocaml
walter|r_ has quit [Read error: Connection reset by peer]
walter|r has quit [Ping timeout: 256 seconds]
tennix has joined #ocaml
grouzen has joined #ocaml
grouzen has quit [Ping timeout: 255 seconds]
SomeDamnBody has joined #ocaml
anti-freeze has quit [Remote host closed the connection]
sp0on has quit [Ping timeout: 246 seconds]
lewis1711 has quit [Ping timeout: 246 seconds]
lewis1711 has joined #ocaml
<ollehar>
wow, minsky him self. gues it's a different crowd on this channel 5 in the morning. :)
<ollehar>
yep, been reading about type-inference and watching doctor who this night, but time to sleep finally.
ollehar has quit [Quit: ollehar]
sp0on has joined #ocaml
darkf has joined #ocaml
tennix has quit [Quit: ERC (IRC client for Emacs 24.5.1)]
SomeDamnBody has quit [Ping timeout: 244 seconds]
louis1711 has joined #ocaml
lewis1711 has quit [Ping timeout: 255 seconds]
SomeDamnBody has joined #ocaml
lewis1711 has joined #ocaml
sailorswift has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
louis1711 has quit [Ping timeout: 244 seconds]
SomeDamnBody has quit [Ping timeout: 252 seconds]
Akshay has joined #ocaml
<lewis1711>
ahh the dreaded "utils.ml" file
Akshay has quit [Ping timeout: 248 seconds]
sp0on has quit [Ping timeout: 240 seconds]
mcclurmc has joined #ocaml
WanderingGlitch has quit [Quit: Glitch out]
MercurialAlchemi has joined #ocaml
tmtwd has joined #ocaml
WanderingGlitch has joined #ocaml
Akshay has joined #ocaml
pyx has joined #ocaml
pyx has quit [Client Quit]
tmtwd has quit [Remote host closed the connection]
<dmbaturin>
Is there a way to make Lwt log all exceptions?
mcclurmc has quit [Remote host closed the connection]
hay207 has joined #ocaml
louis1711 has joined #ocaml
Kakadu has joined #ocaml
Haudegen has quit [Ping timeout: 265 seconds]
lewis1711 has quit [Ping timeout: 240 seconds]
louis1711 has left #ocaml [#ocaml]
Haudegen has joined #ocaml
Haudegen has quit [Ping timeout: 256 seconds]
Haudegen has joined #ocaml
Bhavya has joined #ocaml
Bhavya has quit [Read error: Connection reset by peer]
Bhavya has joined #ocaml
<IAmGilesCorey>
Hello
<IAmGilesCorey>
what is the best way to rewrite in the same variable ? I want to concatenate args to the same string
<dmbaturin>
Rewrite?
<IAmGilesCorey>
sorry, what is Rewrite?
<IAmGilesCorey>
I have just installed opam, but it seems it hasn't been properly addded to the path
<dmbaturin>
That's what I'm asking. What do you mean by rewrite?
<IAmGilesCorey>
I mean change the meaning of a variable, doing like you would do i++, or s = s ^ arg[i]; in a loop
<dmbaturin>
If you want a mutable variable, you create a reference (let foo = ref ""), then you can read its value with !foo and update it with := (let () = foo := !foo ^ "something")
<IAmGilesCorey>
I see, thank you
<IAmGilesCorey>
if I understand correctly opam can't change the global ocaml?
<IAmGilesCorey>
as in make the default ocaml 4 and I can use it in another terminal without calling opam first?
<dmbaturin>
No, your opam setup is yours, it's kept in ~/.opam
<IAmGilesCorey>
is there a way to install a global ocaml?
<IAmGilesCorey>
or global libraries?
<dmbaturin>
Many systems have it in their package repositories/ports/whatever they call it.
<IAmGilesCorey>
my system has an older ocaml
<dmbaturin>
Whether you can install ocaml globally with opam... Not sure, never tried.
<IAmGilesCorey>
anyway I think I may have to restart the machine, If I understand correctly .profile is loaded on login?
<IAmGilesCorey>
so I must restart for the opam to be added to the path and the init script be called?
<dmbaturin>
It's normally re-read when the shell starts, so starting another shell should suffice.
<IAmGilesCorey>
it's strange, it doesn't take it into account
<dmbaturin>
But you see that it's added to the .profile?
<IAmGilesCorey>
I echo $PATH and it's unchanged
Sorella has quit [Quit: Connection closed for inactivity]
<dmbaturin>
Well, re-login won't harm.
<IAmGilesCorey>
yes, I see an opam configuration line
<IAmGilesCorey>
and it calls init.sh
<IAmGilesCorey>
maybe it's the . space / ?
<IAmGilesCorey>
no it's not that
<IAmGilesCorey>
I am so ashamed right now :(
<dmbaturin>
This is what's in my .bash_profile: . /home/dmbaturin/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true
<IAmGilesCorey>
ok what is the argument you pass to the opam installer?
<IAmGilesCorey>
I followed the page and I passes /usr/bin/local
<IAmGilesCorey>
and it asked me for sudo for write permission
<IAmGilesCorey>
if I call init.sh from the terminakl I get permission denied
<IAmGilesCorey>
It doesn't have +x?
<dmbaturin>
I keep mine in ~/bin
<IAmGilesCorey>
I have the same line dmbaturin , I even execute it by hand and it still doesn't work
<IAmGilesCorey>
I even added chmox +x
<dmbaturin>
Since init.sh is sourced rather than executed, it doesn't need +x
<IAmGilesCorey>
but if I execute it by hand from the terminal, it sohuld work?
<IAmGilesCorey>
I get no output (I remove the > dev null) and the path is unchanged
<dmbaturin>
Note the space between . and dir. In bash it's a shortcut for "source something/init.sh"
<dmbaturin>
You can source it by hand.
Haudegen has quit [Ping timeout: 256 seconds]
<IAmGilesCorey>
ok, where is the opam exe supposed to be?
<IAmGilesCorey>
now the script changed the path and I have ocaml
<IAmGilesCorey>
but opam is still not runnable
<IAmGilesCorey>
omg
<def`>
opam should be in your PATH before running the init script
<IAmGilesCorey>
I am so sorry, I wrote the wrong path during install
<def`>
And about sourcing, linux distros usually source the profile when you start a new shell, OSX tends to source at session loging
<def`>
login*
<def`>
(that can be setup, and also depends on whether the line lies in .bashrc or .bash_profile)
<IAmGilesCorey>
everything seems to work now, thank you def` and dmbaturin
<IAmGilesCorey>
the opam not being in the path was a mistake on my part
<def`>
cool :)
<IAmGilesCorey>
if I want to distribute an ocaml program, and it has dependencies, the other people to build it have to instlal them manually with opam or that can be configured in a make file like? to automatically download dependencies?
Haudegen has joined #ocaml
<def`>
You want to distribute in source form?
<IAmGilesCorey>
yes
<def`>
The best is probably to just make your program an opam package.
<dmbaturin>
IAmGilesCorey: OCaml libraries are usually linked statically, so when you distribute binaries, dependencies are not an issue. For the source form, making an opam package is indeed a good idea.
<IAmGilesCorey>
so that means people download the source and do opam make or something?
grouzen has joined #ocaml
<def`>
yes, opam install my-package
<IAmGilesCorey>
sorry if this is a stupid question, but I did opam instlal batteris, and now I opened ocaml in a terminal and I can't import Batteries, it doesn't find it
<def`>
#require "batteries";;
<IAmGilesCorey>
what if I want them to only make the executable, not install it?
<IAmGilesCorey>
like make in other language, but with dependencies
<dmbaturin>
IAmGilesCorey: Also, you may want to install utop, it's an alternative to the standard REPL that has history, completion and so on.
<IAmGilesCorey>
so topfind and requuire are for interactive shells only?
sp0on has joined #ocaml
<dmbaturin>
IAmGilesCorey: They also work when executing scripts with ocaml, but yes, they are interpreter-specific. When compiling, libraries are linked rather than loaded.
<IAmGilesCorey>
I mean, what if my program is a command line tool? not an ocaml library? I cna still use opam to build it?
<dmbaturin>
Sure. There are a number of standalone programs in the main opam repo (utop, menhir, ...).
<IAmGilesCorey>
the main issue with that is people don't get an executable in the place where they downloaded the source?
<dmbaturin>
If they are using opam, it's safe to assume that they have opam init in their shell config, and it takes care of the PATH issues.
creichert has quit [Quit: Leaving]
<IAmGilesCorey>
the issue is I want to distribute this to people that don't have opam install and don't want to use opam, but maybe directly copy the compiled executable to /usr/bin and stuff
<IAmGilesCorey>
I mean, people that don't necessari;ly use ocaml
Akshay_ has joined #ocaml
tane has joined #ocaml
<dmbaturin>
Well, I don't think people who don't use $language should build anything from source at all. They should always use binary packages.
<dmbaturin>
mode and perm are labeled arguments with default values.
<tane>
labels
<IAmGilesCorey>
I see, I never knew about this functionality in Ocaml
<tane>
if you look at a function type, the optional parameters are indicated by a '?'
<IAmGilesCorey>
ok that is silly
<IAmGilesCorey>
BatFile.lines_of expects a filename, so I can't pass it as a function to BatFile.with_file_in :(
<IAmGilesCorey>
I see tane
<tane>
isn't lines_of exactly what you want then anyway?
<tane>
otherwise give some IO function to with_file_in
<dmbaturin>
Yeah, don't assume I said it from memory. I just looked up BatFile.with_file_in type in the REPL. ;)
<tane>
like IO.read_all
Kakadu has quit [Remote host closed the connection]
<IAmGilesCorey>
ok, I understand now I think
ygrek has joined #ocaml
<IAmGilesCorey>
is it possible to import BatFile directly? so I don't have to prefix stuff?
<dmbaturin>
open BatFile
<IAmGilesCorey>
thank you
<flux>
iamgilescorey, eventually, you may find out that opening modules that provide 'generic' functionality may not be the best when you read the code afterwards
<IAmGilesCorey>
it's strange I pass it read write permission and the mode create and I get no such file or directory exception
<flux>
iamgilescorey, there are two options people commonly use: module aliases (module F = BatFile) and local opens (let open BatFile in expr, BatFile.(expr))
<flux>
but, if you're just getting the ropes, I suppose it doesn't really matter, just a couple options to keep on your mind :)
<IAmGilesCorey>
I see, aliases sound nice
<IAmGilesCorey>
I am very confused by the api, it returns me an BatEnum.t type? why not a list of lines?
<flux>
iamgilescorey, well, the enumeration is lazy, so it doesn't load all the lines at once
<flux>
iamgilescorey, I think yuo can see the benefit when you try to read a file with a billion lines ;)
<flux>
but, yuo can convert such an enumeration to a list
<flux>
iirc BatList.of_enum
<IAmGilesCorey>
I see, thank you
<IAmGilesCorey>
it's strange that it's lazy, when the docs say with_file_in closes the file at the end
<flux>
yes, you probably want to convert the enumeration to a list before the function argument to with_file_in finishes
<IAmGilesCorey>
sorry about all the noob questions :(
<IAmGilesCorey>
can you get utop kind of thing in like emacs?
<IAmGilesCorey>
how can I select the stuff at the bottom in utop? from it's suggestions?
Hannibal_Smith has joined #ocaml
<flux>
I don't know of a similar emacs mode
<flux>
I haven't really used utop that much, refer to documentation ;)
<IAmGilesCorey>
wht do you use to write your ocaml code in? utop?
<IAmGilesCorey>
oh
<flux>
I use emacs to edit a file and then send fragments to the toplevel within emacs
<IAmGilesCorey>
It's very strange that when I do it I don't get the right permissions
<IAmGilesCorey>
ok I am sorry again
<IAmGilesCorey>
it's the file manager (GUI) that says there are no permissions
<IAmGilesCorey>
but the terminal shows rw
<IAmGilesCorey>
I think it's a cache thing probably
<IAmGilesCorey>
now I understand why you said it's a peculiar filename, I guess I confused ~ being expanded to home, but that only happens in the terminal I guess
<flux>
it's the shell that expands ~
<flux>
so if you want to happen what I think you want to happen, you need to write: Sys.getenv "HOME" ^ "/.uMRU"
<IAmGilesCorey>
I see
<flux>
maybe if you had "~/.uMRU" before then I understand the earlier error message
<IAmGilesCorey>
the default pwd when running a program is not home?
<flux>
default pwd is whatever you have before running the program..
<IAmGilesCorey>
I see
<flux>
if you double-click it from a file manager then I guess it's maybe the home
<IAmGilesCorey>
that makes sense, thank you
<IAmGilesCorey>
I have a feeling like I will pass more time trying to build the script than writing it
<IAmGilesCorey>
I mean the actual make file
<flux>
what are you using for building?
<IAmGilesCorey>
I have no idea what I should use
<flux>
well, if your program very isn't exotic, you can probably use ocamlbuild.. it of course has something to set up, but I find it relatively easy.
<IAmGilesCorey>
Ideally I'd want someone to cd into the source dir, run a make kind of thing and get an exe
<IAmGilesCorey>
if I use opam can it resolve dependencies automatically?
<flux>
sadly ocamlbuild itself also wants to have a driver script, because it always* needs some arguments
<flux>
well, it cannot find uninstalled opam packages, but it does deal with installed packages
<flux>
with ocamlbuild -use-ocamlfind
<IAmGilesCorey>
I mean, you said I can pake an opam package?
<flux>
you want to make an opam package?
<IAmGilesCorey>
Would that be the easiest?
<IAmGilesCorey>
making an opam package means publishing it to opam servers? or just a special file that opam can read?
<IAmGilesCorey>
I assume opam can install local packages as well?
<flux>
yes, opam can install local packages as well, and is in fact pretty neat for that
<flux>
opam just needs a description file to work
<IAmGilesCorey>
I think opam is for me then
<flux>
I've used oasis for that. oasis is a metabuildsystem that can both generate opam control files as well as use ocamlbuild to build your program.
<IAmGilesCorey>
the ml in ocaml stands for meta langauge?
<IAmGilesCorey>
because that is so meta
<flux>
;)
<IAmGilesCorey>
I have the idea in my head of this program, it is simple enough it's just my lack of experience with ocaml and general noobiness that means it takes me a long time
<IAmGilesCorey>
anyway thank you for your help flux , I'll get to work first on the script then look into building it /package it
<flux>
good luck :)
<IAmGilesCorey>
thank you :)
dvb_ua has quit [Quit: WeeChat 1.1.1]
AlexRussia has quit [Quit: WeeChat 1.3-dev]
ygrek has quit [Ping timeout: 255 seconds]
AlexRussia has joined #ocaml
sp0on has quit [Ping timeout: 246 seconds]
sp0on has joined #ocaml
<IAmGilesCorey>
really sorry but I am having trouble with tuareg, it doesn't seem to be loaded
BitPuffin|osx has quit [Ping timeout: 256 seconds]
<IAmGilesCorey>
when I open an ocaml file in emacs I get no syntax highlighting or tuareg menu
<IAmGilesCorey>
another noob question, how do I run ocaml stuff.ml with Batteries included ?
<dmbaturin>
IAmGilesCorey: In the interpreter? Add ##require "batteries";;
<IAmGilesCorey>
not in the inerpreter, as in run a file to test it
<IAmGilesCorey>
I use open but it says module unbound
<IAmGilesCorey>
I thought opam handles modules?
<dmbaturin>
The interpreter can run in non-interactive mode (#!/usr/bin/env ocaml)
<dmbaturin>
If you want to compile it with batteries, the easiest way is "ocamlfind ocamlopt -package batteries -linkpkg -o stuff stuff.ml"
<IAmGilesCorey>
so running ocaml file.ml is not the same s running a compiled file?
<IAmGilesCorey>
I just want to test it as if I would run the executable
<dmbaturin>
No, running it in ocaml is equivalent to #use from interactive mode or pasting the program into it (except it supresses the debug output such as inferred types when run non-interactively).
<IAmGilesCorey>
I see
<IAmGilesCorey>
but the actual code should contain open not use?
<dmbaturin>
Sure.
<dmbaturin>
Well, it's better not to open modules without a strong need. Some modules include submodules like Infix so you can only import infix operators from them.
<dmbaturin>
You can open modules only within a scope (let open BatFile in ...)
manizzle has joined #ocaml
ggole has joined #ocaml
sp0on has quit [Ping timeout: 265 seconds]
contempt has joined #ocaml
sp0on has joined #ocaml
<IAmGilesCorey>
ocaml -I + batteries won't execute my .ml with batteries included?
<ggole>
It's better to iterate the sequence and sum lengths to get the exact size you need, allocate that, then go fill it in.
<ggole>
(Which is why String.concat and Array.concat exist.)
<IAmGilesCorey>
is there a way to not surround stuff by paranthesis?
<IAmGilesCorey>
I want to do List.tl List.tl but it is confused it seems cause List.tl is not a list?
<IAmGilesCorey>
so I have ot surround it with parenthesis
<flux>
List.tl @@ List.tl ["hello"; world"] maybe
<ggole>
@@,
<flux>
but if you're using List.tl multiple times, you perhaps want to use pattern matching instead
<ggole>
Personally, I prefer the parens
<IAmGilesCorey>
I see, so @@ does what?
<IAmGilesCorey>
ok
sh0t has joined #ocaml
<ggole>
Applies a function to an argument
<IAmGilesCorey>
I think I find parens clearer
<ggole>
There's also |> which is the same thing, but in reverse
<ggole>
Which can be a nice readability improvement if you have a long chain
<IAmGilesCorey>
in reverse?
<IAmGilesCorey>
I don't understand
<ggole>
f @@ arg is the same as arg |> f
<flux>
I find @@ useful in particular when the last argument is a function, in particular if that's the end of the function (or a let-expression)
<IAmGilesCorey>
oh, I see
<IAmGilesCorey>
there is no reverse of lines_of in batteries? I mean write_lines?
<IAmGilesCorey>
I have no idea if Bat_file.write_lines recreates the file or appends
KDr2 has quit [Ping timeout: 264 seconds]
<Maelan>
11:11 IAmGilesCorey│ how can I select the stuff at the bottom in utop? from it's suggestions?
<Maelan>
Alt + left/right arrow, Alt + tab
Haudegen has quit [Ping timeout: 265 seconds]
<IAmGilesCorey>
I see, thank you Maelan
<IAmGilesCorey>
There is no constructor for BatEnum from a list?
<Maelan>
I found BatList.enum ;-)
<IAmGilesCorey>
a list is an enum?
<Maelan>
I guess no.
<Maelan>
This is only the name of the function.
<IAmGilesCorey>
oh I see, thank you
<IAmGilesCorey>
I searched for to_enum because there is from_enum
<IAmGilesCorey>
sorry
<Maelan>
Yes, this is a strange naming convention.
KDr2 has joined #ocaml
Haudegen has joined #ocaml
lyxia has joined #ocaml
Akshay_ has quit [Ping timeout: 244 seconds]
<IAmGilesCorey>
List.filter (fun s -> s != "first") ["second"; "first"]
<IAmGilesCorey>
I am very confused
<IAmGilesCorey>
string list = ["second"; "first"]
<IAmGilesCorey>
It does not seem to filter?
<tane>
List.filter (fun s -> String.equal s "first") ["second"; "first"];;
<IAmGilesCorey>
oh :(
<tane>
or not equal.. :)
<IAmGilesCorey>
I thought ocaml overcharged that
<tane>
anyway, use String.equal
<tane>
well, you can use utop to test your assumptions
<tane>
"a" == "a";;
<IAmGilesCorey>
how do I import String in utop?
<tane>
it should be there
<IAmGilesCorey>
I get no such package String
<IAmGilesCorey>
oh there is no equal in String I tyhink
<tane>
yes, i was using BatString i suppose :)
<IAmGilesCorey>
oh, thank you
<tane>
the standard ocaml string module provides `compare` though
<IAmGilesCorey>
what is the equivalnet of ! ?
<tane>
you mean "not"?
<IAmGilesCorey>
yes, I meant that, thank you
<ggole>
List.filter (fun s -> s <> "first") ["second"; "first"]
<ggole>
!= is "pointer inequality"
jrslepak has quit [Ping timeout: 256 seconds]
jrslepak has joined #ocaml
kdas__ has quit [Quit: Leaving]
<Maelan>
… and == is "pointer equality"
nullcat has joined #ocaml
<Maelan>
while = is structural equality
slash^ has quit [Read error: Connection reset by peer]
<ollehar>
not instead of !, && instead of and...
<ollehar>
and instead of type rec
<ollehar>
well
<ollehar>
hm
<ggole>
Forward declarations
<IAmGilesCorey>
man, those must have been the slowerest code I've ever done
<IAmGilesCorey>
26 lines or so in hours :(
jabesed has quit [Ping timeout: 246 seconds]
<Maelan>
22:50 flux│ btw, here's a script I sometimes use for pasting stuff to irc.. :) xsel | tr '\t' ' ' | tr '\n' ' ' | sed 's/ */ /g' | xsel -i
<Maelan>
You should consider ‘xsel | xargs | xsel -i’ ;-)
<Maelan>
same but shorter
DanielRichman has quit [Remote host closed the connection]
DanielRichman has joined #ocaml
Akshay_ has joined #ocaml
lobo has joined #ocaml
<dmbaturin>
IAmGilesCorey: Try a dependently types language and at the beginning you'll achieve a record speed of one line per hour. ;)
<dmbaturin>
* typed
<IAmGilesCorey>
I never heard of dependently type languaged
<IAmGilesCorey>
langauge
<ggole>
Just GADTs is enough for that -_-
<IAmGilesCorey>
I remmeber studying those at university
rand000 has joined #ocaml
<IAmGilesCorey>
I think ocaml is cool
<IAmGilesCorey>
but I find it strange that as a functional language it has exceptions that you're not forced to catch
<IAmGilesCorey>
to me exception should be like a match, you can't ignore them
<IAmGilesCorey>
I mean ocaml has a strong type system but you can still have stuff that doesnt work at runtime
<ggole>
Well, OCaml isn't a total language. Not even close.
<IAmGilesCorey>
what do you mean a total langauge?
<IAmGilesCorey>
I mean Ocaml doesn't let you add an int to float, without explicit conversion, but it lets you not catch an ecxception
<ggole>
Constructs which can 'fail' in the way that you mentioned are usually called 'partial'. Ones that don't are 'total'.
<dmbaturin>
A total language is a language that doesn't allow partial functions (i.e. all functions always terminate).
<IAmGilesCorey>
I think all code that can throw an exception should be forced to be cared of, the compiler should force you
<dmbaturin>
* For any input.
<ggole>
Total languages are languages designed to provide the machinery necessary to program effectively with the latter.
<dmbaturin>
There are (experimental) languages with effect systems that make sure every side effect is accounted for.
<IAmGilesCorey>
Well I don't think I've meant something that extreme
<IAmGilesCorey>
but I mean like in java you have checked exceptions and you must catch them
<IAmGilesCorey>
I just find it bizzare that ocaml has a strong type system than java, doesn't let you do many implicit stuff, like compared to types, operations etc
<ggole>
You can use option or result for that
<IAmGilesCorey>
but still lets you ignore a statement that throws an exception
<IAmGilesCorey>
yes but I mean the compiler doesn't force you, if I execute some code from Batteries without reading the doc I might now even know it throws an exception
<IAmGilesCorey>
and even if I know I might forget to catch it, I think the compiler should make you IMHO
<IAmGilesCorey>
like wiht pattern matching if you forget some matches, I may be wrong but I think ocaml tells you, and you must use _
<dmbaturin>
Note that non-exhaustive match is a warning rather than an error.
<IAmGilesCorey>
oh I see
<IAmGilesCorey>
well to me Ocaml is stric in certain areas but very permissive in others
<IAmGilesCorey>
and I find that strange
<ggole>
You'd need to redesign a lot of stuff for that to work
<ggole>
Since many array or string operations would potentially raise
<dmbaturin>
A useful one, but the compiler prefers to allow what it can't prove is wrong. :)
<IAmGilesCorey>
To me a language should never allow code that might throw an uncatches exception or do stuff that might cause an error or stuff
<IAmGilesCorey>
I mean that way you force the programmer to be aware that his code might fail and have a solution
<IAmGilesCorey>
that is in theory at least, in practice people would most likely leave the error checking code emty
<IAmGilesCorey>
I know in java the IDE just generates the code to catch the exception and logs it, so people till remain lazy
<dmbaturin>
Well, the best option is to write code that is provably correct, but it's not always possible.
<IAmGilesCorey>
well in the case of exception its possible for the compiler to give a warning if you don't catch the exception
<IAmGilesCorey>
It's already done in java, but for some reason in java you also have unchecked exception that you are not forced to catch
<ggole>
So if you write x / y, you get a warning? That seems pretty heavy.
<IAmGilesCorey>
I have never used haskell but I've read a bit about it, doesn't haskell try to make it like side-effects proof?
<IAmGilesCorey>
ggole: no, java has two types of exceptions, ones that you can ignore, like division by zero
<IAmGilesCorey>
and others that you must thread like FiloNotFound or some IO stuff
<dmbaturin>
Haskell essentially hides side effects behind pure-looking code.
<IAmGilesCorey>
so you can't compile without catching those exceptions
<IAmGilesCorey>
but does haskell have exceptions?
<IAmGilesCorey>
or stuff that can break at runtime?
<dmbaturin>
And it doesn't let you mix effectful and really pure code together.
<ggole>
That's basically the distinction between exceptions and option/result
<IAmGilesCorey>
how do you work with code that might fail? you pass it in None or a sum type?
<IAmGilesCorey>
so haskell instead of an exception returns Sucess or some union tag for the type of error?
<ggole>
They have Maybe and Either, and some monad stuff to chain them automatically
<IAmGilesCorey>
that is like None and Some in ocaml?
pgomes has joined #ocaml
pgomes has quit [Client Quit]
<ollehar>
There are other libs that doesn't use exceptions for control flow
<ollehar>
But yes, effect typing...
<dmbaturin>
Note that even haskell has error :: [Char] -> a function. :)
jabesed has joined #ocaml
<ggole>
None and Some are constructors of (ocaml's) option: Maybe is the Haskell equivalent
<dmbaturin>
data Maybe a = Just a | Nothing
<dmbaturin>
type 'a option = Some of 'a | None
<IAmGilesCorey>
oh I see
<IAmGilesCorey>
To me, at least in theory the idea of having that seems good
<IAmGilesCorey>
or to have exceptions being force to be taken care by the user
<IAmGilesCorey>
of course not as extreme and division
<IAmGilesCorey>
as*
DanielRichman has quit [Remote host closed the connection]
DanielRichman has joined #ocaml
<dmbaturin>
The bind from Maybe monad is equivalent to let (>>=) v f = match v with None -> None | Some v -> f v
keen__________25 has joined #ocaml
keen__________24 has quit [Ping timeout: 252 seconds]
<ollehar>
(someone should make a phd about adding effect types to ocaml...)
<ollehar>
(no one? fine, I'll do it)
<dmbaturin>
So if anything in a foo x >>= bar >>= baz pipeline returns None, it's sent back rather than down the pipeline. By replacing None with a non-nullary constructor that can carry a value, it looks like exception handling.
<dmbaturin>
With a really elaborate bind function you can make it look exactly like exception handling. :)
<dmbaturin>
ollehar: My goal in life is to learn enough PLT to actually do things like that.
<ollehar>
dmbaturin: koka is open source, just steal it ^^
<dmbaturin>
IAmGilesCorey: It's quite annoying that many functions from pervasives throw Not_found rather than return an option, but you can just use their counterparts from batteries or elsewhere. The standard library is going to stay this way for compatibility.
<dmbaturin>
Older code was usualy "more imperative" than what you see now. And CAML is old, if you count from the original CAML implementation, like 30 years old.
<ollehar>
ah, links seems really cool. :)
<ollehar>
still, why invent a new language instead of extending an existing one? so much reinventing the wheel otherwise.
<Drup>
ollehar: I tend to agree, but the difficulty is not nearly the same.
<dmbaturin>
ollehar: Is looks like it's the normal ML workflow. Invent a dialect, have the idea/feature merged back in mainstream MLs, neglect the dialect. :)
<ollehar>
drup, sure
<ollehar>
that's why I said "subset" [to begin with]
<dmbaturin>
From some Garrigue's papers it looks like OCaml with labeled arguments and polymorphic variants was once a fork/dialect.
<ollehar>
well, everything is a fork at one point...
<ollehar>
also, there's is a question of how many features a programming language can have without turning into a mess (to maintain/update).
<ollehar>
if the features are orthogonal, then no problem
<ollehar>
it can also be a problem to teach the language to new-comers.
Hannibal_Smith has quit [Ping timeout: 244 seconds]
pgomes has joined #ocaml
Kakadu has joined #ocaml
<ollehar>
aww, links is stone dead :(
soultadu has joined #ocaml
<Drup>
indeed it is
tane has quit [Ping timeout: 244 seconds]
obadz has quit [Ping timeout: 264 seconds]
<Maelan>
i
<Maelan>
(oops)
tane has joined #ocaml
obadz has joined #ocaml
tane has quit [Ping timeout: 244 seconds]
BitPuffin|osx has joined #ocaml
<ollehar>
you guys think ocaml is too big?
<ollehar>
I don't know if anyone here maintains the code-base
tane has joined #ocaml
tmtwd has joined #ocaml
<Akshay_>
what you mean by too big ?
obadz- has joined #ocaml
obadz has quit [Ping timeout: 246 seconds]
<ollehar>
feature-wise, akshay_
<ollehar>
or LOC-wise, maybe :P
nullca___ has joined #ocaml
nullcat has quit [Ping timeout: 256 seconds]
nullcat_ has joined #ocaml
nullca___ has quit [Ping timeout: 256 seconds]
curiosity has joined #ocaml
<curiosity>
what is janestreet using for its unit tests? ounit? or something different?
slash^ has quit [Read error: Connection reset by peer]
nullcat has joined #ocaml
nullca___ has quit [Ping timeout: 246 seconds]
Haudegen has joined #ocaml
hugomg has joined #ocaml
nullcat__ has joined #ocaml
nullcat has quit [Read error: Connection reset by peer]
nullcat has joined #ocaml
nullcat__ has quit [Ping timeout: 244 seconds]
nullcat has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Haudegen has quit [Ping timeout: 246 seconds]
<hugomg>
Hi there, #ocaml! Now that wodi is not maintained anymore, what are the alternatives if I want to create standalone executables on Windows? Can Opam do that now or do the executables still require cygwin to run?
<dmbaturin>
hugomg: The compiler from the package from official downloads requires cygwin, but executables it produced don't.
<hugomg>
can I use that compiler with opam?
curiosity has quit [Quit: Leaving]
<dmbaturin>
Wait, but opam doesn't work on windows. Or it does work in cygwin?
<hugomg>
i heard it worked with cygwin. I could be wrong though
Haudegen has joined #ocaml
Sorella has joined #ocaml
Kakadu has left #ocaml [#ocaml]
zpe has joined #ocaml
<dmbaturin>
hugomg: Also, to me it looks like the windows compiler only wants the assembler and possibly other programs from cygwin, but doesn't need cygwin to run.
<dmbaturin>
So it possibly can be made to use the native assembler from mingw (but I can be wrong, and I'm very clueless when it comes to windows programming).
zpe has quit [Remote host closed the connection]
<grouzen>
Hi folks, came to us with one question - what's the best way to define 'compare', or '<=>' op for int from perl in ocaml?
Haudegen has quit [Ping timeout: 256 seconds]
<flux>
this is probably ok: let (<=>) a b = match () with _ when a < b -> -1 | a > b -> 1 | _ (* a = b *) -> 0
<flux>
..except the second match also needs a "_ when"
<flux>
or you could just chain ifs
<flux>
:)
<grouzen>
yup, both ways look ugly ;)
<grouzen>
but thanks, your solution looks intresting to me
<ggole>
grouzen: Pervasives already has 'compare' that does that?
Haudegen has joined #ocaml
Akshay_ has quit [Read error: Connection reset by peer]
darkf has quit [Quit: Leaving]
systmkor has joined #ocaml
ygrek has joined #ocaml
walter|r has joined #ocaml
pgomes has left #ocaml ["Leaving"]
sh0t has quit [Ping timeout: 240 seconds]
mort___ has joined #ocaml
lordkryss has joined #ocaml
<Maelan>
I spent the whole day trying to code a little Bash wrapper around ocamldep.
<Maelan>
Just realized I would have been done for hours if I’ve had done it in OCaml.
<Maelan>
First it sounded like a good idea.
<Maelan>
Then I tried to do things cleanly.
<Maelan>
Bash… arrays… are… weird…
<Maelan>
Not even speaking about how to deal with spaces. :/
<apache2>
IFS=
mort___ has left #ocaml [#ocaml]
<grouzen>
ggole: yeah, you're right. I was trying to google by
<grouzen>
'ocaml compare' and got nothing
<dmbaturin>
Maelan: At some point I started using ocaml as a scripting language even where python or ruby what be more "socially acceptable".
<dmbaturin>
* would be
<dmbaturin>
In any case, I try to avoid writing shell at any cost when it comes to nontrivial scripts.
<Maelan>
Yeah dmbaturin, I do this from time to time. But [Ba]sh scripting is usually quite convenient for text processing, and because of its strong system integration.
<dmbaturin>
Some say back then standalone AWK scripts were common. Maybe it's actually a good idea.
<Maelan>
(I should not care about spaces that much, seeing how pathetically ‘make’ cope with them anyway.)
slash^ has joined #ocaml
ollehar has quit [Ping timeout: 246 seconds]
dhil has joined #ocaml
shinnya has quit [Ping timeout: 250 seconds]
toomuchtvrotsurb has joined #ocaml
toomuchtvrotsurb has quit [Remote host closed the connection]
walter|r has quit [Remote host closed the connection]
nullcat has joined #ocaml
sheijk has joined #ocaml
ollehar has joined #ocaml
obadz- is now known as obadz
Anarchos has joined #ocaml
struktured has joined #ocaml
jabesed has quit [Ping timeout: 246 seconds]
ggole has quit [Remote host closed the connection]
MrScout has joined #ocaml
MrScout has quit [Read error: Connection reset by peer]
MrScout has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
Haudegen has quit [Ping timeout: 244 seconds]
jabesed has joined #ocaml
toomuchtvrotsurb has joined #ocaml
Haudegen has joined #ocaml
ollehar has quit [Quit: ollehar]
ygrek has quit [Ping timeout: 246 seconds]
MercurialAlchemi has quit [Ping timeout: 244 seconds]
<Anarchos>
nullcat x and y are not physically equal.
<flux>
where does physical equality come into play, in that complicated piece of code?-)
<Anarchos>
no idea. It was just my impressions while looking at the code.
<Anarchos>
but it seems he is embodying x and y in two distinct modules
<nullcat>
physical equality... ?
<nullcat>
where..
yomimono has joined #ocaml
<flux>
I wonder if this could be related to the generative attribute of functors, ie. when you instantiate a functor twice with same argument, you will get a separate module?
<nullcat>
you mean different module?
<flux>
yes..
<nullcat>
i tend to agree with this explanation
<nullcat>
but I cannot explain to myself why I have two different modules here
<nullcat>
it's ... a really weird piece of code here
<Anarchos>
nullcat did you try to run it through ocamldebug ?
<nullcat>
never used before....
<Anarchos>
you should, it is really easy to use
<Drup>
nullcat: each constructor 'T' created by the application of the MakeNTType functor is different
<nullcat>
ok
<Drup>
you could formulate it like that: constructors are identified by their path, nor their name
<Drup>
so module if you have module M and module N, both resulting from two *different* application of MakeNTType
<nullcat>
i wrote same hypothesis in email to jeremy.. i couldn't wait him to reply so i ask here
<nullcat>
i see
<Drup>
M.T x and N.T x are not equals, regardless if x is equal
<nullcat>
old T and new T
<nullcat>
right?
<Drup>
yes, except it's not old and new, rather "the one in module M" and "the one in module N"
<nullcat>
ok
<Drup>
(side note: you can generate unique values like that)
<nullcat>
Drup: is it possible to make any changes to have desired behaviour?
<nullcat>
yeah
<nullcat>
i know.. i just..
<Drup>
either do not apply the functor multiple time or factor the line "type _ nttype += T : t nttype" out of the functor
<nullcat>
that i really want is that for a given type t, i add a unique corresponding constructor
<nullcat>
for s, I have S, for t i have T..
<nullcat>
...
<nullcat>
factor that line out??
<Drup>
you can do that
<Drup>
sure
<nullcat>
well then t is not unbound
<nullcat>
is not bound
<nullcat>
sorry
<nullcat>
you mean put line 21 out of functor??
<Drup>
yes
<Drup>
hum, you actually use the type t in this line
<Drup>
so, wait
<nullcat>
yeah.........
<Drup>
basically, you want the module resulting of the functor to hold a witness of the type t
<nullcat>
yeah
<Drup>
That is an interesting question :D
<nullcat>
hahaha
<nullcat>
it will be really really helpful to me to solve this
<nullcat>
then I can push forward much much faster...
<Drup>
I don't have an idea on how to do that right now. :p
<nullcat>
good
<Drup>
if jeremy answers, please show me
<nullcat>
no problem
jabesed has quit [Ping timeout: 264 seconds]
<Drup>
I'm not sure you can implement that, because it would allow you to tell if two abstracts types are different, and I'm pretty sure you can't do that in OCaml.
<Drup>
(this is the point in the conversation where I ask "why do you want to do that ?" :p)
<nullcat>
the answer is long but i am writing it now
<nullcat>
consider a recursive parser expression written in OCaml. You are expanding (generating optimized code) this parser combinator. You don't want to fall into infinite recursion.
<nullcat>
for part "Generating code for gshow", that "let rec h' : ...". I need to do something similar. This means I need to use type equality witness
manud has joined #ocaml
sgnb has quit [Remote host closed the connection]
meteo__ has quit [Remote host closed the connection]
lobo has quit [Quit: leaving]
sp0on has quit [Ping timeout: 244 seconds]
cross has quit [Ping timeout: 246 seconds]
cross has joined #ocaml
maufred has quit [Remote host closed the connection]
maufred has joined #ocaml
Hannibal_Smith has joined #ocaml
ygrek has joined #ocaml
jonludlam has quit [Quit: Leaving]
sgnb has joined #ocaml
sporkmonger has quit [Quit: sporkmonger]
sp0on has joined #ocaml
shinnya has joined #ocaml
madroach has quit [Ping timeout: 264 seconds]
madroach has joined #ocaml
SomeDamnBody has joined #ocaml
nullcat has quit [Quit: My Mac has gone to sleep. ZZZzzz…]