<pm_>
int is the type of the items inside the list. Is the analogy that float is the type of the type-unspecified item inside the 'asdf', since 'asdf' is polymorphic like list/
Yoric has joined #ocaml
darkf has joined #ocaml
Yoric has quit [Ping timeout: 256 seconds]
<pm_>
I think I see. 'asdf' isn't a complete type, but 'float asdf' is. I can't 'coerce' (3.14,1) to type 'asdf' because it's not specific enough. I notice that if I define:
<pm_>
# type 'a asdf = ASDF of 'a * int
yacks has joined #ocaml
<pm_>
then the type of 3.14 is inferred if I say:
<pm_>
# ASDF (3.14,2)
<pippijn>
the type of 3.14 is known
<pippijn>
it is used as a basis for the rest of the type inference
<pm_>
Am I right in thinking that the 'ASDF' part (type constructor?) fixes the context so that (3.14,2) is *not* recognized as '- : float * int = (3.14, 2)' ?
<pm_>
but correctly recognized as '- : float asdf = ASDF (3.14, 2)' /
Yoric has joined #ocaml
q66 has quit [Quit: Quit]
<pm_>
Thanks, thizanne & pippijn, for the hints. I'm going back to my tutorial, to try to crawl my way out of my ocaml infancy...
Yoric has quit [Ping timeout: 252 seconds]
ulfdoz_ has joined #ocaml
ulfdoz has quit [Ping timeout: 245 seconds]
ulfdoz_ is now known as ulfdoz
madroach has quit [Ping timeout: 248 seconds]
madroach has joined #ocaml
gnuvince has joined #ocaml
pm_ has quit [Quit: Page closed]
leoncamel has quit [Ping timeout: 240 seconds]
emmanuelux has quit [Remote host closed the connection]
ahokaomaeha has quit [Ping timeout: 255 seconds]
travisbrady has quit [Quit: travisbrady]
ctult has quit [Ping timeout: 256 seconds]
mattrepl has quit [Quit: mattrepl]
cfy has joined #ocaml
milosn has quit [Ping timeout: 255 seconds]
milosn has joined #ocaml
flux has quit [Read error: Connection reset by peer]
emias has quit [Ping timeout: 248 seconds]
emias has joined #ocaml
flx_ has joined #ocaml
flx_ is now known as flux
milosn has quit [Ping timeout: 276 seconds]
darinmorrison has quit []
milosn has joined #ocaml
cdidd has joined #ocaml
ahokaomaeha has joined #ocaml
ctult_ has joined #ocaml
ctult_ has quit [Ping timeout: 248 seconds]
Yoric has joined #ocaml
ahokaomaeha has quit [Quit: When I come back, please tell me in what new ways you have decided to be completely wrong.]
ahokaomaeha has joined #ocaml
ttamttam has joined #ocaml
ttamttam has quit [Remote host closed the connection]
ahokaomaeha has quit [Quit: When I come back, please tell me in what new ways you have decided to be completely wrong.]
ahokaomaeha has joined #ocaml
tac has joined #ocaml
axiles has joined #ocaml
ttamttam has joined #ocaml
Cyanure has joined #ocaml
pango is now known as pangoafk
Snark has joined #ocaml
Cyanure has quit [Remote host closed the connection]
yacks has quit [Remote host closed the connection]
tac has quit [Ping timeout: 245 seconds]
ontologiae has joined #ocaml
ahokaomaeha is now known as lolcathost|afk
ottbot has quit [Ping timeout: 276 seconds]
ttamttam has quit [Quit: ttamttam]
Cyanure has joined #ocaml
ontologiae has quit [Ping timeout: 276 seconds]
cago has joined #ocaml
lolcathost|afk is now known as ahokaomaeha
ttamttam has joined #ocaml
mika1 has joined #ocaml
ollehar has joined #ocaml
mcclurmc has quit [Read error: Operation timed out]
djcoin has joined #ocaml
hkBst has joined #ocaml
ollehar has quit [Ping timeout: 245 seconds]
yacks has joined #ocaml
hkBst has quit [Excess Flood]
hkBst has joined #ocaml
hkBst has quit [Changing host]
hkBst has joined #ocaml
thomasga has joined #ocaml
hkBst has quit [Ping timeout: 246 seconds]
ftrvxmtrx_ has joined #ocaml
hkBst has joined #ocaml
hkBst has quit [Changing host]
hkBst has joined #ocaml
ontologiae has joined #ocaml
Yoric has quit [Remote host closed the connection]
Yoric has joined #ocaml
ottbot has joined #ocaml
hkBst_ has joined #ocaml
hkBst has quit [Ping timeout: 246 seconds]
anderse has quit [Quit: anderse]
hkBst_ has quit [Read error: Connection reset by peer]
Cyanure has quit [Quit: Quitte]
hkBst_ has joined #ocaml
hkBst_ has quit [Changing host]
hkBst_ has joined #ocaml
leoncamel has joined #ocaml
hkBst_ has quit [Read error: Connection reset by peer]
hkBst_ has joined #ocaml
hkBst_ has quit [Changing host]
hkBst_ has joined #ocaml
ocp has joined #ocaml
tane has joined #ocaml
ontologi1e has joined #ocaml
ontologiae has quit [Read error: Connection reset by peer]
Yoric has quit [Ping timeout: 246 seconds]
anderse has joined #ocaml
rixed has joined #ocaml
darkf_ has joined #ocaml
yacks has quit [Quit: Leaving]
hkBst_ has quit [Read error: Connection reset by peer]
hkBst_ has joined #ocaml
hkBst_ has quit [Changing host]
hkBst_ has joined #ocaml
darkf has quit [Ping timeout: 246 seconds]
darkf_ is now known as darkf
Kakadu has joined #ocaml
hkBst_ has quit [Remote host closed the connection]
hkBst_ has joined #ocaml
hkBst_ has quit [Changing host]
hkBst_ has joined #ocaml
yacks has joined #ocaml
mika1 has quit [Read error: Connection reset by peer]
yacks has quit [Ping timeout: 252 seconds]
tane has quit [Quit: Verlassend]
yacks has joined #ocaml
mika1 has joined #ocaml
ontologi1e has quit [Ping timeout: 240 seconds]
yacks has quit [Ping timeout: 252 seconds]
hkBst_ has quit [Ping timeout: 246 seconds]
hkBst__ has joined #ocaml
yacks has joined #ocaml
q66 has joined #ocaml
gnuvince has quit [Ping timeout: 252 seconds]
ontologiae has joined #ocaml
tane has joined #ocaml
yacks has quit [Ping timeout: 255 seconds]
Kakadu has quit [Quit: Konversation terminated!]
gnuvince has joined #ocaml
yacks has joined #ocaml
Kakadu has joined #ocaml
Kakadu has quit [Read error: Connection reset by peer]
Kakadu_ has joined #ocaml
yacks has quit [Ping timeout: 252 seconds]
leoncamel has quit [Ping timeout: 255 seconds]
mattrepl has joined #ocaml
Reventlov has quit [Ping timeout: 256 seconds]
cago has quit [Quit: Leaving.]
metasyntax has joined #ocaml
cago has joined #ocaml
yacks has joined #ocaml
travisbrady has joined #ocaml
mcclurmc has joined #ocaml
dwmw2_gone is now known as dwmw2
travisbrady has quit [Quit: travisbrady]
darkf has quit [Read error: Connection reset by peer]
cfy has quit [Remote host closed the connection]
zorun has quit [Quit: Reconnecting]
zorun has joined #ocaml
hto has quit [Read error: Connection reset by peer]
hto has joined #ocaml
deavidsedice has joined #ocaml
cross_ has joined #ocaml
fasta_ has joined #ocaml
anderse_ has joined #ocaml
pango_ has joined #ocaml
maufred_ has joined #ocaml
reynir_ has joined #ocaml
zorun has quit [Ping timeout: 276 seconds]
anderse has quit [Ping timeout: 276 seconds]
ocp has quit [Ping timeout: 276 seconds]
iZsh has quit [Ping timeout: 276 seconds]
cross has quit [Ping timeout: 276 seconds]
reynir has quit [Ping timeout: 276 seconds]
ftrvxmtrx_ has quit [Ping timeout: 276 seconds]
fasta has quit [Ping timeout: 276 seconds]
pangoafk has quit [Ping timeout: 276 seconds]
mapour has quit [Ping timeout: 276 seconds]
maufred has quit [Ping timeout: 276 seconds]
deavid has quit [Ping timeout: 276 seconds]
Im_Also_Greg has quit [Ping timeout: 276 seconds]
iZsh has joined #ocaml
ocp has joined #ocaml
mapour has joined #ocaml
anderse_ is now known as anderse
ImAlsoGreg has joined #ocaml
ftrvxmtrx_ has joined #ocaml
Breadmonster has joined #ocaml
<Breadmonster>
Has anyone here actually met Yaron Minsky?
zorun has joined #ocaml
hcarty has joined #ocaml
<thelema>
Breadmonster: yes
<Breadmonster>
thelema: What's he like?
<Breadmonster>
I admire the man, he's built Jane Street to where it is today./
<thelema>
He's scruffy, gregarious, maybe a bit aspbergers. Quite smart; extremely experienced in a breadth of technical details.
<Breadmonster>
Did he offer you a job?
smondet has joined #ocaml
travisbrady has joined #ocaml
<thelema>
Breadmonster: no; I interviewed with JS a long time ago, and was rejected.
<Breadmonster>
Damn, I wanna get in.
<Breadmonster>
I've heard good things about it.
<thelema>
Me too.
<thelema>
I've not heard of him just offering OCaml coders jobs; they go through a pretty thorough interview process
<orbitz>
maybe Stephen Weeks didn't have to interveiw :)
<thelema>
Even Jeremie Dimino had to interview
Yoric has joined #ocaml
<Breadmonster>
Where did Yaron do his bachelors?
<Breadmonster>
And Stephen Weeks is a genius.
<Breadmonster>
There's no way I can rival that.
<Yoric>
And where did he hide the bodies?
<Breadmonster>
No idea, probably his mom's closet.
<Breadmonster>
thelema: Is he approachable?
<thelema>
Breadmonster: yes, although he's also plenty busy, so don't waste his time.
<Breadmonster>
I'd think so.
<Breadmonster>
I think he's MD at Jane Street.
<thelema>
"Yaron Minsky obtained his PhD in Computer Science from Cornell University in 2002 focusing on distributed systems."
<Breadmonster>
Which, at least, in the financial world is a huge task.
Breadmonster has quit [Quit: Page closed]
ocp has quit [Ping timeout: 276 seconds]
Yoric has quit [Ping timeout: 246 seconds]
travisbrady has quit [Quit: travisbrady]
chambart has joined #ocaml
<smango>
I've met Yaron Minsky briefly, he gave a few functional programming lectures at Cornell
travisbrady has joined #ocaml
<orbitz>
I've met him a few times, swell guy. I'd drink an alcoholic beverage with him.
Cyanure has joined #ocaml
mika1 has quit [Quit: Leaving.]
pango_ is now known as pango
hkBst__ has quit [Quit: Konversation terminated!]
cago has left #ocaml []
sgnb` has joined #ocaml
sgnb has quit [Ping timeout: 246 seconds]
Anarchos has joined #ocaml
PM has quit [Ping timeout: 246 seconds]
PM has joined #ocaml
ftrvxmtrx_ has quit [Quit: Leaving]
anderse has quit [Quit: anderse]
answer_42 has joined #ocaml
Yoric has joined #ocaml
ocp has joined #ocaml
<orbitz>
ahah, I think I'm getting closer on building my own monad
thomasga has quit [Quit: Leaving.]
ttamttam has quit [Quit: ttamttam]
S11001001 has joined #ocaml
ocp has quit [Quit: Leaving.]
djcoin has quit [Quit: WeeChat 0.3.9.2]
ttamttam has joined #ocaml
mcclurmc has quit [Ping timeout: 246 seconds]
dabd has joined #ocaml
Neo has joined #ocaml
Neo is now known as Guest30878
<Guest30878>
Hello
<orbitz>
hi
<Guest30878>
Need some ocaml help.
<orbitz>
feel free to ask
ttamttam has quit [Quit: ttamttam]
<Guest30878>
I am trying to use List.Fold to count the number of occurance in a list
<Guest30878>
for example: num_occurs 4 [1;3;4;5;4] = 2
<orbitz>
k
<Guest30878>
so the function signature should be: let num_occurs (n:int) (nums:int list) : int =
<orbitz>
I generally don't use type annotations in that way, but sure
<Guest30878>
just having a hard time figuring the lamda expression to pass into the fold.left or fold.right
<orbitz>
well, you shoudl start by getting the names right, it's List.fold_left and List.fold_right
<orbitz>
you probably want List.fold_left
<orbitz>
secondly, what are the 3 parameters fold_left takes?
ftrvxmtrx has quit [Ping timeout: 246 seconds]
<thelema>
Guest30878: think about what you have to do to consume a single element of your list; given the current count and your list element, what do you need to compute?
<Guest30878>
it takes the lamda expression, an int and a alist
<orbitz>
Guest30878: nope
<orbitz>
Guest30878: close
<orbitz>
Guest30878: the initial value of fold_left acn be any type, it does nothave to be int
<Guest30878>
ok
<orbitz>
Guest30878: and fold_left doesn't take a lambda expression, it takes a function
<thelema>
given your current count and a list element, how to compute count after processing?
osa1 has joined #ocaml
<Guest30878>
current count +1?
<thelema>
Guest30878: not always
<orbitz>
Guest30878: what paraemters does the function you give fold_left have to take?
<thelema>
adding 1 would give you the length of the list
<thelema>
adding 1 for every element would give you the length of the list
<Guest30878>
so have to put an if statement to check of = num
<thelema>
yup.
<thelema>
so how to write that in ocaml?
<Guest30878>
let num_occurs (n:int) (nums:int list) : int = List.fold_left (fun a _ -> if n = head then a + 1) 0 nums
<thelema>
(fun a head -> ...)
<Guest30878>
let num_occurs (n:int) (nums:int list) : int = let head::tail = nums in List.fold_left (fun a head -> if n = head then a + 1) 0 nums ;;
<thelema>
?? remove the "let head::tail ... in"
<Guest30878>
ok...let me see
<Guest30878>
let num_occurs (n:int) (nums:int list) : int = List.fold_left (fun a head -> if n = head then a + 1) 0 nums ;;
<thelema>
now, your if needs an "else"
<Guest30878>
the interpreter is complaining that the "a+1" has a type int but was expected of type unit
<Guest30878>
else a
<thelema>
exactly; "if ... then ..." is only valid when the "then" is a unit function
<thelema>
otherwise you need if..then..else
<Guest30878>
oh yes. Thank you so much for explaining
ftrvxmtrx has joined #ocaml
<Guest30878>
Here's my final version:
<Guest30878>
let num_occurs (n:int) (nums:int list) : int = List.fold_left (fun a head -> if n = head then a + 1 else a) 0 nums ;;
<orbitz>
i'd just write let num_occurs n nums = List.fold-left (fun acc e -> if n = e then acc + 1 else acc) 0 nums
<Guest30878>
much appreciated it. Thank you so much for spending the time to explain this!
chambart has quit [Ping timeout: 246 seconds]
Guest30878 has quit [Quit: Page closed]
Kakadu_ has quit []
yacks has quit [Remote host closed the connection]
mfp has quit [Read error: Connection reset by peer]
thomasga has joined #ocaml
tac has joined #ocaml
yacks has joined #ocaml
ollehar has joined #ocaml
mcclurmc has joined #ocaml
mfp has joined #ocaml
Simgate has joined #ocaml
thomasga has quit [Quit: Leaving.]
ottbot has quit [Ping timeout: 245 seconds]
Simgate has quit [Ping timeout: 276 seconds]
ontologiae has quit [Ping timeout: 255 seconds]
Reventlov has joined #ocaml
mye has joined #ocaml
sysopfb has joined #ocaml
sysop_fb has quit [Ping timeout: 255 seconds]
trep has joined #ocaml
sysopfb has quit [Ping timeout: 260 seconds]
jamii has joined #ocaml
yacks has quit [Read error: Connection reset by peer]
ttamttam has joined #ocaml
<fasta_>
I think this would be more abstract: let a x xs =List.length (List.filter (fun e -> e =x) xs);;
<dsheets>
((=) x)
<fasta_>
In Haskell, you would just write a e xs = length [x<-xs, x=e]
<fasta_>
dsheets: thanks, I tried to write just (=x), but that didn't work.
<dsheets>
let a x xs = List.(length (filter ((=) x) xs))
<fasta_>
In practical OCaml o-bitz solution is likely the most efficient, because mine only creates garbage.
<fasta_>
(I left the r out on purpose)
<dsheets>
ja a fold is better
<thelema>
List.filter ((=) x) %> List.length
<fasta_>
I think it's 'better' if one can just write the semantics of a program and get out a program that runs fast if so desired.
<fasta_>
E.g. a source-to-source transformation which would translate between my generative solution and a direct one.
<thelema>
let rec eqx ?(cnt=0) x = function [] -> cnt | h::t -> eqx ~cnt:(if h = x then cnt+1 else cnt) x t
<fasta_>
thelema: yeah, that's terrible.
<thelema>
ocaml needs inlining of HOFs before deforesting transformations
<fasta_>
Why aren't there more ocaml compilers like in the Haskell world?
<thelema>
as is, fold_left will be slower than hand-written recursion because even simple predicates aren't inlined
<thelema>
although for really long lists of ints, monomorphizing the (=) might be a bigger win
<fasta_>
thelema: are you saying that = does not compile to one native instruction?
<thelema>
how could it do so when lists are to be compared?
<thelema>
== does compile down to a single instruction
<thelema>
but it's usually not what you want.
<fasta_>
thelema: it's comparing elements.
<fasta_>
thelema: not lists.
<thelema>
the elements could be lists; polymorphism
<orbitz>
(=) is structural comparison
<fasta_>
thelema: yes, but then it should just partially specialize for each type.
<thelema>
fasta_: *every possible* type?
<fasta_>
thelema: every type that is used.
<fasta_>
thelema: it could have a generic one too for third parties without source.
<thelema>
that would push the codegen to link time, which (largely) defeats the purpose of separate compilation
<orbitz>
(=) or compare is knwon to be very slow and have odd edge cases
<thelema>
and greatly increases compilation time
S11001001 has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
<fasta_>
I think a compiler system should separate a few modes: very quick for development with very slow code, moderately quick for emergency deployments with reasonable code (30% slower at most), very slow for planned releases which could take 5 hours or so.
<thelema>
OCaml has the first two
<orbitz>
Who on earth is going to trust a 5 hour compilation?
<flux>
or wait 5 hours for 5% performance gain :)
<thelema>
flux: someone running a task that takes more than 100 CPU hours
<flux>
(well, I suppose it could be better, but still it couldn't be relied on if you still need to do "emergency deployments"..)
<flux>
thelema, so, maybe 0.1% or less of users?-)
<thelema>
flux: yes, almost noone
<orbitz>
I just woudln't trust otpimizations that take 5 hours, must be some gnarly edge cases inthere
<thelema>
otoh, I'd be fine with a system of annotating functions to tell the compiler to create monomorphic versions of a function for a list of types
<flux>
ocaml defunctorizer, where art thou
<thelema>
quite.
<fasta_>
orbitz: in my experience computers do what I tell them to do, unless someone else has written the program I am using.
<fasta_>
I have never encountered a computer executing a program in the wrong way, although I know that supposedly this is possible.
<orbitz>
fasta_: You've neve rbeen aware of it at least, but there is a reason people avoid -O3 and CompCert exists
ottbot has joined #ocaml
<adrien>
it's getting much better nowadays
<adrien>
(-O3 that is)
ahokaomaeha has quit [Quit: When I come back, please tell me in what new ways you have decided to be completely wrong.]
rwmjones has quit [Ping timeout: 256 seconds]
ottbot has quit [Ping timeout: 264 seconds]
ttamttam has left #ocaml []
tac_ has joined #ocaml
tac has quit [Ping timeout: 245 seconds]
rwmjones has joined #ocaml
ontologiae has joined #ocaml
thomasga has joined #ocaml
Thorn has joined #ocaml
smondet has quit [Remote host closed the connection]
answer_42 has quit [Ping timeout: 276 seconds]
<fasta_>
orbitz: doesn't compcert exist because of imperfections in humans (not computers)?
<fasta_>
orbitz: I have found compiler bugs before, but I haven't found an error in a CPU (although, I know that some people did for really esoteric code).
<Anarchos>
fasta_ the guy who wrote the BeOS file systems found a bug in the pentium while working at QNX
<fasta_>
Intel lost quite a lot of money on their recall, so I expect they have invested a lot of money in making sure that never happens again.
<fasta_>
(and that was even for a *potential* problem)
answer_42 has joined #ocaml
<orbitz>
I'm not sure what you're saying fasta. All technology comes from humans, so how can computers not have imperfections?
<adrien>
there are lots of CPU bugs
ottbot has joined #ocaml
<orbitz>
Also not sure what you mean by CompCert. AFAIK it exists so yo ucan have a compiler with guarantees about what it produces, because optimization is hard
Anarchos has quit [Quit: will come back later]
<thelema>
orbitz: translation is hard
<thelema>
conserving semantics across different representations of a program is hard
<orbitz>
indeed
<orbitz>
i must be missing something obious, writing my own monad is turning out to be more challengign tahn i thought
smondet has joined #ocaml
thomasga has quit [Quit: Leaving.]
cdidd has quit [Ping timeout: 276 seconds]
Reventlov has quit [Quit: leaving]
Snark has quit [Quit: Quitte]
ottbot has quit [Ping timeout: 255 seconds]
anderse has joined #ocaml
anderse has quit [Client Quit]
ftrvxmtrx has quit [Ping timeout: 240 seconds]
axiles has quit [Quit: Quitte]
chambart has joined #ocaml
Yoric has quit [Ping timeout: 260 seconds]
answer_42 has quit [Ping timeout: 276 seconds]
ollehar has quit [Ping timeout: 255 seconds]
ollehar has joined #ocaml
emmanuelux has joined #ocaml
Cyanure has quit [Ping timeout: 255 seconds]
ollehar has quit [Ping timeout: 252 seconds]
Yoric has joined #ocaml
tac_ is now known as tac
stevej has joined #ocaml
Cyanure has joined #ocaml
ftrvxmtrx has joined #ocaml
chambart has quit [Ping timeout: 246 seconds]
jamii has quit [Ping timeout: 252 seconds]
smondet has quit [Ping timeout: 255 seconds]
ottbot has joined #ocaml
oceanquake has quit [Remote host closed the connection]
chambart has joined #ocaml
Yoric has quit [Ping timeout: 240 seconds]
ctult_ has joined #ocaml
travisbrady has quit [Read error: Connection reset by peer]
travisbrady has joined #ocaml
creichen has quit [Ping timeout: 252 seconds]
ottbot has quit [Ping timeout: 245 seconds]
creichen has joined #ocaml
osa1 has quit [Quit: Konversation terminated!]
Cyanure has quit [Remote host closed the connection]
chambart has quit [Ping timeout: 246 seconds]
tane has quit [Quit: Verlassend]
ctult_ has quit []
fraggle_ has quit [Read error: Connection reset by peer]
tac has quit [Ping timeout: 245 seconds]
travisbrady has quit [Quit: travisbrady]
fraggle_ has joined #ocaml
travisbrady has joined #ocaml
ontologiae has quit [Ping timeout: 240 seconds]
travisbrady has quit [Quit: travisbrady]
trep is now known as sysop_fb
sivoais has quit [Changing host]
sivoais has joined #ocaml
fraggle_ has quit [Remote host closed the connection]