<Drup>
that's the logo from ocaml.org, so It's probably a good idea to use it :p
<dmbaturin>
Yeah, but it needs a caml of different type for the second type variable.
<dmbaturin>
And I was certainly too lazy to draw one.
<Drup>
Just be careful not to use a dromedary :p
darkf has joined #ocaml
<rom1504>
so what kind of transformation on ocaml is it ?
<dmbaturin>
Drup: Makes me think, if I make a polymorphic function with more arguments of distinct types than there are letters, what will happen?
<Drup>
the function in the poster ? Reverse application :)
<dmbaturin>
rom1504: Yep, it's the |>
<Drup>
dmbaturin: you can have multi-letter type variables.
<Drup>
(very useful for documentation purposes)
<vfoley>
What's the least error-prone way of reading two integers on a single line? Scanf.scanf "%d %d" is being a bit erratic with me.
<dmbaturin>
Erratic?
rgrinberg has quit [Quit: Leaving.]
<vfoley>
In further input, I get an End_of_file exception
<vfoley>
I do Scanf.scanf "%d %d" (fun a b -> ...) and I then call my own read_binary_number a times. It works if I type the input in the console, and fails when I pipe in data.
mcclurmc has quit [Remote host closed the connection]
mcclurmc has joined #ocaml
ygrek has joined #ocaml
rgrinberg has quit [Ping timeout: 264 seconds]
rgrinberg has joined #ocaml
q66 has quit [Quit: Leaving]
<rom1504>
dmbaturin: hmm what is the "|>" ?
<dmbaturin>
rom1504: let (|>) x f = f x
bbloom has joined #ocaml
<dmbaturin>
It's in the standard library since 4.001 (or 002?).
<bbloom>
quick question: does ocaml do full tail call elimination? or only for tail-recursion?
<Drup>
the former
<rom1504>
dmbaturin: ok
nojb has joined #ocaml
oscar_toro has quit [Ping timeout: 250 seconds]
badon has quit [Remote host closed the connection]
badon has joined #ocaml
nojb has quit [Quit: nojb]
struktured has joined #ocaml
nojb has joined #ocaml
nojb has quit [Client Quit]
hilquias has quit [Remote host closed the connection]
rgrinberg has quit [Quit: Leaving.]
nojb has joined #ocaml
nojb has quit [Client Quit]
marynate has joined #ocaml
enitiz has joined #ocaml
ygrek has quit [Ping timeout: 240 seconds]
BitPuffin has quit [Ping timeout: 256 seconds]
shinnya_ has quit [Ping timeout: 244 seconds]
samrat has joined #ocaml
<bbloom>
Drup: thank you
hekmek has quit [Quit: Verlassend]
Yoric has joined #ocaml
vfoley has joined #ocaml
vfoley has joined #ocaml
Yoric has quit [Ping timeout: 265 seconds]
Tamae has joined #ocaml
huza has joined #ocaml
huza has quit [Remote host closed the connection]
vanila has quit [Quit: Leaving]
nullcat has joined #ocaml
samrat has quit [Quit: Computer has gone to sleep.]
marynate has quit [Ping timeout: 255 seconds]
marynate has joined #ocaml
pobivan has joined #ocaml
natrium1970 has joined #ocaml
elfring has joined #ocaml
WraithM has quit [Remote host closed the connection]
WraithM has joined #ocaml
huza has joined #ocaml
<natrium1970>
I’m noticing that “fun x -> x = 5” seems to generate longer, slower-appearing code than the more verbose function 5 -> true | _ -> false
natrium1970 has quit [Quit: natrium1970]
marynate has quit [Ping timeout: 240 seconds]
huza has quit [Remote host closed the connection]
marynate has joined #ocaml
nullcat has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<Drup>
and with "fun (x:int) -> x = 5" ?
<adrien>
he left
<adrien>
I'm really curious about the "slower-appearing" though :P
MercurialAlchemi has joined #ocaml
_5kg has quit [Ping timeout: 265 seconds]
tane has joined #ocaml
samrat has joined #ocaml
smtb987 has joined #ocaml
samrat has quit [Quit: Computer has gone to sleep.]
samrat has joined #ocaml
samrat has quit [Client Quit]
<rom1504>
this syntax was making his brain lag, that would explain "slower-appearing" anyway :)
enitiz has quit [Ping timeout: 264 seconds]
marynate has quit [Read error: Connection reset by peer]
marynate has joined #ocaml
sinelaw has joined #ocaml
mcc has joined #ocaml
_5kg has joined #ocaml
enitiz has joined #ocaml
smtb987 has quit [Quit: Page closed]
samrat has joined #ocaml
mcc has quit [Quit: This computer has gone to sleep]
kapil__ has quit [Quit: Connection closed for inactivity]
kakadu has joined #ocaml
enitiz has quit [Remote host closed the connection]
Yoric has joined #ocaml
RossJH has joined #ocaml
leowzukw has joined #ocaml
hilquias has joined #ocaml
mort___ has joined #ocaml
Simn has joined #ocaml
sol__ has joined #ocaml
hilquias has quit [Remote host closed the connection]
mort___ has quit [Quit: Leaving.]
tane has quit [Quit: Verlassend]
Arsenik has joined #ocaml
<dmbaturin>
Now I'm curious what the difference in assembly generated from x = 5 and the case expression version.
<def`>
the case generates a jump
<def`>
the x = 5 generates code to test and to turn cpuflags to an appropriate ocaml integer
<def`>
I guess that if the branch is predicted correctly, a modern intel cpu might makes better use of the pipeline than in the "x = 5" case where there is a lot of dependencies on %rax register
samrat has quit [Quit: Computer has gone to sleep.]
<dmbaturin>
def`: Oh, I see. What I don't get though: where does $11 constant come from in this case: http://pastie.org/9812156
<dmbaturin>
This is for let iffive x = x = 5
marynate has quit [Read error: Connection reset by peer]
<def`>
5 in ocaml integer representation
<def`>
(x * 2 + 1)
marynate has joined #ocaml
jabesed has joined #ocaml
marynate has quit [Max SendQ exceeded]
jonludlam has joined #ocaml
marynate has joined #ocaml
huza has joined #ocaml
<huza>
join
matason has joined #ocaml
marynate has quit [Max SendQ exceeded]
marynate has joined #ocaml
shinnya_ has joined #ocaml
huza has quit [Remote host closed the connection]
nojb has joined #ocaml
skchrko has quit [Ping timeout: 264 seconds]
marynate has quit [Max SendQ exceeded]
lnich has quit [Ping timeout: 255 seconds]
huza has joined #ocaml
marynate has joined #ocaml
<dmbaturin>
def`: Ah, yeah, the tag bit. I see.
lnich has joined #ocaml
marynate has quit [Max SendQ exceeded]
ddosia1 has joined #ocaml
_5kg has quit [Ping timeout: 245 seconds]
<ddosia1>
Hi. Is there any list function like reduce or fold but with ability to prevent further list traversal and return current accum?
<nojb>
yes, let rec left_fold f i = function [] -> i | x :: xs -> match f i x with None -> i | Some i -> left_fold f i xs
huza has quit [Remote host closed the connection]
matason has quit [Ping timeout: 250 seconds]
<ddosia1>
nojb: thanks, I am trying to avoid to write all the functions by myself and use already written one. just want to learn standard library and core library
<nojb>
there is no such function in stdlib
<nojb>
don’t know about core though
<ddosia1>
you never know for sure :)
<dmbaturin>
ddosia1: By refusing to reimplement standard library you go against ocaml traditions. ;)
skchrko has joined #ocaml
leowzukw has quit [Ping timeout: 246 seconds]
leowzukw_ has joined #ocaml
jonludlam has quit [Quit: Coyote finally caught me]
<Leonidas>
just like every C programm contains an informally-specified, bug-ridden slow implementation of half of common lisp, every ocaml program contains a reimplementation of half of a decent standard library.
<jabesed>
ddosia1: I get it that ocaml is strict and therefore, left fold tends to be the most used, but it always felt kind of wrong to call the left fold "fold"
<jabesed>
ddosia1: doesn't that confuse the crap out of beginners when they move on to implement folds in trees and the like?
<dmbaturin>
Leonidas: Nice, didn't know of it. I'm a bit confused by type signature search though. Why searching for 'a -> 'b gives 'a -> 'a, and even types that are neither less nor more general than it?
<Leonidas>
dmbaturin: I believe the search is not too exact on purpose for the case that you don't exaclty know how the signature is supposed to look like
lordkryss has joined #ocaml
<Leonidas>
better to find some function that kinda does what you want and you can change your thinking to use that, then to find 0 hits and reimplement it.
<ddosia1>
jabesed: in erlang they called foldl and foldr :P
<Leonidas>
but you'd have to ask Jun Furuse for details on why it does something :-)
rgrinberg has joined #ocaml
<Leonidas>
ddosia1: what is the I for?
<Leonidas>
'i'
<ddosia1>
l for left and r for right
<jabesed>
ddosia1: same in Haskell
<ddosia1>
but probably should be "h" for left and "l" for right, if you know what I mean ;)
<ddosia1>
as well as "j" for down and "k" for up
<jabesed>
ddosia1: but from what I've seen, and I think it's the same in Ocaml, fold tends to also be used for more complex (e.g. non-linear) data structures and as a synonym of catamorphism
<Leonidas>
hmm, I'd probably rather go with an option type or plain either
<ddosia1>
Leonidas: I d started with option type, but this does not allow me return anything meaningfull in negative case
<ddosia1>
my original task is to convert hex string to int, and if it contain wrong chars just return 0
<jabesed>
ddosia1: meaning, a fold is what you get by "substituting constructors with functions of the same arity"
<ddosia1>
probably in this case I can go with option
huza has joined #ocaml
<ddosia1>
jabesed: man, I wish I understand what you are talking about
<dmbaturin>
Leonidas: Is it open source?
<dmbaturin>
Oh, found it.
<ddosia1>
guys, can you point me some article to learn how to use error-aware data types, like option? I know there is ">=" thing and ">|" but it is hard to grasp this idea without a guide
<Leonidas>
dmbaturin: yes
_5kg has joined #ocaml
<Leonidas>
ddosia1: you mean >>= and >|=?
<ddosia1>
yeah
<Leonidas>
ddosia1: yes, then use type ('a, 'b) either = Left of 'a | Right of 'b
<Leonidas>
ddosia1: if you have 'a option and do option_value >>= (fun x -> …) then x will be the unwrapped value of the option value and you have to return an option value
<Leonidas>
>|= unwraps the input and wraps the output automatically.
<dmbaturin>
Which >>= and >|= are you talking about? Something from the core?
<Drup>
Well, the best way is still to see how it's implemented.
<Leonidas>
but OCaml doesn't really have >>= and >|=, just some libraries define it
<ddosia1>
Core.Option.>>=
<Leonidas>
dmbaturin: I'm talking about Lwt ;-)
<Drup>
>>= (or otherwise call bind) would be implemented for option as "let bind f = function None -> None | Some x -> f x"
<dmbaturin>
Leonidas: Ah. And ddosia1 is talking about core apparently. :)
<Leonidas>
dmbaturin: >>= in core would work the same
<ddosia1>
I think the idea is the same
<Drup>
and >|= (or map) would be implemented by "let map f = function None -> None | Some x -> Some (f x)"
<dmbaturin>
Yeah, I guess they all have the same semantics as haskell bind, or at least I hope so.
<Drup>
ddosia1: the implementation should give you a big clue on how to use them :p
<ddosia1>
Are this idioms spread among ocaml users? Or it is like artificial thing came from haskell and to so widely used?
<ddosia1>
*not* so widely used
<Drup>
it's not really artificial, but it's not common either, because OCaml is not design to make this things as easy to use as in Haskell
<ddosia1>
I wonder is there some fellows who came to ocaml from haskell...
<ddosia1>
and what was the reason
<Drup>
I know at least one :p
<ddosia1>
Drup: any particular reason?
<def`>
I did too
<Drup>
def`: you were the "at least one" in question x)
<def`>
:)
<ddosia1>
ahh, I thought you were talking about yourself ;)
<Drup>
I did some haskell, but it was just temporary
<Leonidas>
well, using >>= in ocaml is kinda ok
<Leonidas>
i wouldn't say it is exotic
<Leonidas>
Lwt uses it heavily
<ddosia1>
Leonidas: is it ok to like import this functions for convenience?
<ddosia1>
or do everytime Option.( a >>= b ...)
<Leonidas>
i often local alias it. or local open
<Drup>
ddosia1: don't you have a module Option.Infix that you can open ?
<Leonidas>
let open Option in ...
<ddosia1>
Drup: I dont know about that :D
huza has quit [Quit: WeeChat 0.3.8]
<Leonidas>
oor option.infix, that's probably better
<def`>
ddosia1: I changed from Haskell to OCaml mainly because of evaluation strategy
<dmbaturin>
ddosia1: In the absense of ad-hoc polymorphism it's not that easy to implement bind for anything, I guess that's why it's less common.
<ddosia1>
def`: oh really? I thought laziness is so clever
<Drup>
oh, it's very clever
<tobiasBora>
Hello !
<def`>
ddosia1: it's clever, but not for running code
<ddosia1>
is there infix pow function?
<ddosia1>
tobiasBora: hi there
<nojb>
** : float -> float -> float
<def`>
I gained a strong module system, huge win for designing software, I lost some mathematical thinking (which is not a problem for software actually running)
<jabesed>
ddosia1: it's no big deal: "type 'a list = [ ] | :: of 'a * ('a list)" so you have two constructors, [ ] : lista 'a and (::) : 'a * ('a list) -> 'a list and if you look at foldr its arguments are an element e:'b and a binary function f : 'a * 'b -> 'b
<Drup>
you lost monads overload, which is probably a win :>
<def`>
So I like using haskell for playing with concepts, but when it comes to implementation OCaml is my choice.
<jabesed>
ddosia1: in other words the arguments of foldr are obtained directly from the constructors of the type
<def`>
(And the extremely simple and clean OCaml runtime is very enjoyable, it's the high-level language where I feel closer to the machine ;-))
nojb has quit [Quit: nojb]
<jabesed>
ddosia1: it's just a function for each constructor, and the signature of the function is almost the same as that of the constructor, you just substitute 'b for list 'a, since your purpose is to transform a list 'a in a value 'b
<jabesed>
ddosia1: [] :: list 'a ===> e:'b (::) : 'a * ('a list) -> 'a list ===> f : 'a * 'b -> 'b
<jabesed>
ddosia1: and that is the essence of what a catamorphism does, it operates your structure by transforming constructors into functions
<jabesed>
ddosia1: and that's usually called a fold
<jabesed>
ddosia1: and used not only in lists but also trees and other structures
<ddosia1>
I will put this on the stack and will think about this thoroughly
nojb has joined #ocaml
<ddosia1>
catomorphism: 'a -> '=^..^=
<Drup>
(Note: "^-^" is a valid ocaml operator)
huza has joined #ocaml
_jerry_ has joined #ocaml
<Drup>
well =^..^= too, in fact.
Hannibal_Smith has joined #ocaml
<ddosia1>
:D
<dmbaturin>
Remember that the first character defines associativity though.
<tobiasBora>
I'm playing with opam/oasis and I would like to know what is the good way to proceed to uninstall an app that have installed a data in $datadir/$package app
<tobiasBora>
for the moment I run a command with PreUninstallCommand with rm $datadir/$pkg_name
<tobiasBora>
but the environment variable is wrong
<tobiasBora>
so I need to run in the remove function a ./configure --prefix ...
Yoric has quit [Remote host closed the connection]
pobivan has quit [Quit: pobivan]
oscar_toro has quit [Read error: Connection reset by peer]
oscar_toro has joined #ocaml
oscar_toro has quit [Max SendQ exceeded]
oscar_toro has joined #ocaml
oscar_toro has quit [Quit: Leaving.]
oscar_toro has joined #ocaml
oscar_toro has quit [Ping timeout: 264 seconds]
hugomg has joined #ocaml
kakadu has quit [Remote host closed the connection]
hugomg has quit [Ping timeout: 240 seconds]
Yoric has joined #ocaml
araujo has quit [Read error: Connection reset by peer]
araujo has joined #ocaml
ygrek has joined #ocaml
<nullcat_>
If I want to mirage from Async to Lwt, should I keep the async code and do it like cohttp to support both Async and Lwt, or I should move to Lwt completely? any suggestion?
<whitequark>
depends on use case. personally I have no interest in supporting async
araujo has quit [Client Quit]
<nullcat_>
because?
Arsenik has quit [Remote host closed the connection]
<whitequark>
um, because it's work, and I'm lazy?
sinelaw has quit [Quit: Leaving]
<whitequark>
that, and I don't like async's error handling model
<nullcat_>
you mean using Erlang-like monitor?
<whitequark>
yeah
<whitequark>
lwt's exceptions are much nicer in my view
<nullcat_>
i see
rgrinberg has quit [Quit: Leaving.]
Thooms has quit [Quit: WeeChat 1.0.1]
rgrinberg has joined #ocaml
Haudegen has quit [Ping timeout: 250 seconds]
Haudegen has joined #ocaml
huza has joined #ocaml
rgrinberg has quit [Quit: Leaving.]
mengu has quit [Remote host closed the connection]
mengu has joined #ocaml
enitiz has joined #ocaml
hugomg has joined #ocaml
mengu has quit [Ping timeout: 240 seconds]
Yoric has quit [Remote host closed the connection]