mrvn has quit [Read error: 110 (Connection timed out)]
docelic is now known as docelic|sleepo
foxen5 has quit [Read error: 104 (Connection reset by peer)]
foxster has joined #ocaml
Kinners has quit ["leaving"]
rox is now known as rox|geschloff
Torquemada has quit [Remote closed the connection]
Torquemada has joined #ocaml
steele has quit [Remote closed the connection]
lament has joined #ocaml
mattam has joined #ocaml
shapr has quit [leguin.freenode.net irc.freenode.net]
Torquemada has quit [Remote closed the connection]
Torquemada has joined #ocaml
docelic|sleepo is now known as docelic
Torquemada has quit [Remote closed the connection]
rox|geschloff is now known as rox
lament has quit [Remote closed the connection]
Torquemada has joined #ocaml
Torquemada has quit [Remote closed the connection]
karryall has joined #ocaml
Torquemada has joined #ocaml
skylan has quit [Read error: 104 (Connection reset by peer)]
skylan has joined #ocaml
robb has joined #ocaml
<robb>
hi all
<robb>
if i compose 2 functions
<robb>
like
<robb>
let (@@) f g x = f (g x);;
<robb>
i have to write (f @@ g) x;;
<robb>
but if i use let cool f g x = f(g x);;
<robb>
i use it like ool (function x -> x+1) (function x -> x+10) 1 ;;
<robb>
so where is the difference? how does the compiler understands one is infix and the other prefix?
<mrvn_>
one starts with @
<mrvn_>
Look at the gramatik. Certain symbols as first character in a name specify an infix.
<mrvn_>
You can also write (@@) (function x -> x+1) (function x -> x+10) 1 ;;
<mrvn_>
(i think)
<robb>
true :P
<robb>
so it depends on the symbol
<mrvn_>
Thats how the grammatik specifies it
<robb>
in fact let xxx f g x = f (g x);; doesnt work as ((function x -> x+1) xxx (function x -> x+10)) 1 ;;
<robb>
it was not written on my book
<robb>
thanks
<mrvn_>
let (@xxx) ... x @xxx y should work
<robb>
still starts with @ :P
mattam_ has joined #ocaml
mattam has quit [Read error: 110 (Connection timed out)]
esabb has joined #ocaml
smklsmkl is now known as smkl
Dalroth has joined #ocaml
smklsmkl has joined #ocaml
smkl has quit [Read error: 104 (Connection reset by peer)]
smklsmkl is now known as smkl
spip has joined #ocaml
spip has left #ocaml []
Dalroth has quit [leguin.freenode.net irc.freenode.net]
skylan has quit [leguin.freenode.net irc.freenode.net]
robb has quit [leguin.freenode.net irc.freenode.net]
mrvn_ has quit [leguin.freenode.net irc.freenode.net]
asqui has quit [leguin.freenode.net irc.freenode.net]
merriam has quit [leguin.freenode.net irc.freenode.net]
karryall has quit [leguin.freenode.net irc.freenode.net]
smkl has quit [leguin.freenode.net irc.freenode.net]
foxster has quit [leguin.freenode.net irc.freenode.net]
Zadeh has quit [leguin.freenode.net irc.freenode.net]
rox has quit [leguin.freenode.net irc.freenode.net]
iusris_sleep has quit [leguin.freenode.net irc.freenode.net]
gl has quit [leguin.freenode.net irc.freenode.net]
smkl has joined #ocaml
Dalroth has joined #ocaml
robb has joined #ocaml
skylan has joined #ocaml
karryall has joined #ocaml
foxster has joined #ocaml
mrvn_ has joined #ocaml
asqui has joined #ocaml
merriam has joined #ocaml
Zadeh has joined #ocaml
rox has joined #ocaml
iusris_sleep has joined #ocaml
gl has joined #ocaml
asqui has quit [Excess Flood]
asqui has joined #ocaml
steele has joined #ocaml
<steele>
hi
smklsmkl has joined #ocaml
smkl has quit [Read error: 104 (Connection reset by peer)]
xmkl has joined #ocaml
smklsmkl has quit [Read error: 104 (Connection reset by peer)]
<robb>
hi
<robb>
is it possible to work in ocaml without pattern matching withou loss of expressivity?
<steele>
why would you want that?
<robb>
i'd not, it's a question on my book :P
<steele>
i don't think you can. try getting the head of a list
<steele>
hd is defined with pattern matching
<robb>
but since it's OO maybe another way is possible?
<robb>
brb dinner
<robb>
i'll come back in 30 mins or so
<steele>
you can stop using algebraic data types, but i wouldn't call that "without loss of expressivity" ;)
<steele>
cu
xmkl is now known as smkl
skylan has quit [Read error: 54 (Connection reset by peer)]
skylan has joined #ocaml
<robb>
back
<robb>
steele: lol :P
<emu>
you could pretend that you don't know how hd was defined =)
<mrvn_>
How do you work exceptions without pattern matching?
<mrvn_>
You can write a list object that works with Magic or arrays to circumvent List.hd's pattern matching. But with arrays you change the time complexity.
<robb>
emu: heh same thing i was thinking
<robb>
or right and left for a binary tree
<mrvn_>
# let head l = if l = [] then raise Foo else let h::r = l in h;;
<mrvn_>
Warning: this pattern-matching is not exhaustive.
<mrvn_>
Here is an example of a value that is not matched:
<mrvn_>
[]
<mrvn_>
val head : 'a list -> 'a = <fun>
<mrvn_>
Is that using pattern matching?
<robb>
sure --> this pattern-matching is not exhaustive.
<robb>
:P
<mrvn_>
Then it realy comes down to using Magic to make an option datatype without pattern matching.
<robb>
this exception thing didnt come to mind
<robb>
it's a good point :P
<mrvn_>
You could write exceptions without the need for matching. But theres allways an implicit matching there.
<robb>
i agree
<mrvn_>
exception Foo;;
<mrvn_>
class list = object method empty () = true end;;
<mrvn_>
class list_head x_ tail_ = object inherit list
<mrvn_>
val x = (x_:int)
<mrvn_>
val tail = (tail_:list)
<mrvn_>
method empty () = false
<mrvn_>
method get () = x
<mrvn_>
method next () = tail
<mrvn_>
end;;
<mrvn_>
let head l = if l#empty () then raise Foo else (l:>list_head)#get ();;
<mrvn_>
let l = new list_head 1 (new list);;
<mrvn_>
head l;;
<mrvn_>
- : int = 1
<mrvn_>
Theres your list without pattern matching
<mrvn_>
You can do the same for None/Some, exceptions, etc
<robb>
cool :P
<robb>
tnx
<robb>
so i can do lits
<robb>
lists
<mrvn_>
robb: I would say the answere would be: Yes, you can do it without pattern matching, but enumeration types would have to be written more explicitly.
<robb>
mmm
<robb>
let me guess
<robb>
what about backtracking?
<mrvn_>
backtracking?
<robb>
if i use no exceptions
<robb>
i can still use none/some
<mrvn_>
If you have just one type of exception I wouldn't call try ... with e -> ... pattern matching.
<robb>
yes you know, like find a path in a n-tree from root to node 48. dont you use try-with?
<robb>
well i can have one defined by myself
<robb>
but others may occur
<mrvn_>
you can implement exceptions using None/Some. But thats loosing expressionism.
<robb>
yep
<robb>
mrvn_: do you think that it'd be possible to have graphs and n-trees without pattern matching?
<mrvn_>
robb: of cause you have to rewrite some systems Modules so everything uses your one exceptions or inheritances of that.
<mrvn_>
robb: sure, arrays.
<robb>
ah true
<robb>
mmm but then would it still be functional?
<mrvn_>
Once you have None/Some or lists you can do everything else and I showed you lists.
<robb>
:P
<robb>
thanks
<mrvn_>
The cast operator (a:>b) enables you to simulate enumeration types.
<mrvn_>
You could probably write an ocamlp4 syntax that converts normal syntax to such a OO syntax.
<robb>
i am just a rookie :)
<robb>
but sure, that would be nice
<robb>
in ur opinion what are the greatest advantages of using currified (?) forms?
<robb>
i'd say that i can be usefull to apply not all the parameters to a function
<robb>
but besides that
Dalroth has quit [Read error: 54 (Connection reset by peer)]
Dalroth has joined #ocaml
<rox>
~tell robb about enter
<rox>
argh, wrong channel
<rox>
sorry all
<robb>
hahaha
<mrvn_>
robb: saves you keystrokes.
<mrvn_>
robb: let f a b == let f = function a -> function b ->
<robb>
and parenthesis
<robb>
heh
<robb>
(f,a,b)
<robb>
thats one thing i luv in ocaml :P
<mrvn_>
(f,a,b) == f,a,b
<robb>
comas then
<robb>
?
<robb>
told you i am a rookie
<mrvn_>
no, let f (a,b) is different from let f a b
<mrvn_>
In other langugage is let f a b == let f = function (a,b) ->
<robb>
let f (a,b) =?= let f a,b
<mrvn_>
robb: yes. () are for your benefit
<robb>
ah okay
<robb>
lots of learning today :P
<mrvn_>
() for tuples are mostly for readability but they can be important.
<mrvn_>
The great thing about curryfied functions is that you can apply them partially to create new functions.
<mrvn_>
But that works just as well without currying if you type it out with function a -> ...
<robb>
but in that case i'd have to make a new function everytime?
<mrvn_>
no. "let f a b" and "let f = function a -> function b ->" are exactly the same.
<robb>
yes i guess i misunderstool ur last line fefore
<robb>
before
<robb>
:P
<mrvn_>
With currying its just more fun (as in fun a b c -> :)
mrvn_ is now known as mrvn
<robb>
isnt let f = function a -> function b -> a+b;; currified?
<mrvn>
afaik is currying transforming "let f a b =" into "let f = function a -> function b ->"
<robb>
ah
<robb>
i thought (a,b) ==> a b
<robb>
i should reread something
<mrvn>
yeah
<robb>
:P
<mrvn>
or rather "let f = function (a,b) ->" into "let f = function a -> function b ->"
<mrvn>
But you can allways type it yourself.
<robb>
in the end it's real --> <mrvn_> robb: saves you keystrokes.
<robb>
:)
<mrvn>
thats what I would answere.
<robb>
:P
<robb>
you know, they teach ocaml at university
systems has joined #ocaml
<mrvn>
I know, I heard curses about it years ago
<robb>
where?
<mrvn>
Tuebingen
<robb>
.de ?
<mrvn>
yep
<steele>
mrvn: where do they use ocaml? undergraduate, compiler construction?
<robb>
ai, in my uni
<mrvn>
compiler construction and functional programming
<steele>
they do compiler construction with C here *shudder*
systems has quit [Read error: 110 (Connection timed out)]
Dalroth has quit [Read error: 104 (Connection reset by peer)]
rox is now known as tito
tito is now known as sex
sex has left #ocaml []
<robb>
excuse me
<robb>
what the hell is type exn?
<robb>
exn -> exn ntree -> exn = <fun>
<robb>
???
lament has joined #ocaml
rox has joined #ocaml
<smkl>
robb: it's the type of exceptions
<robb>
let find_granpa n t =
<robb>
let rec aux = function
<robb>
x::y::z::[] -> x
<robb>
| w::ws -> aux ws
<robb>
| [] -> Not_Found
<robb>
in aux (find_node n t);;
<robb>
when i added | [] -> Not_Found i got that type??? but i guess it's 'normal', nothing weird, or not?
<robb>
smkl: thanks
<smkl>
you probably want: raise Not_found
<robb>
whoops
<robb>
:P
<robb>
sorry
<robb>
yes
<robb>
thanks
<whee>
oh, god
<whee>
camlp4 development stopped
<whee>
time to wean myself off of ocaml :\
iusris_sleep is now known as iusris
<robb>
whee: what happened?
<whee>
I don't know, guess the ocaml dev team pissed off daniel one last time
<whee>
(the core ocaml team doesn't really want a preprocessor like that)
<whee>
which is a shame, really
<robb>
mmm
<robb>
i still dont have things clear :(
lindril has joined #ocaml
<steele>
whee: i wouldn't say they don't wan't camlp4. They wanted to keep it included in the ocaml distribution and daniel wanted to separate it
<rox>
robb: you can allways make one and
<steele>
that was what they argued the last time
<robb>
lol
<whee>
steele: in any case, it's now sitting there idle
<whee>
and the version in ocaml cvs is currently broken anyway
matkor has joined #ocaml
<whee>
and it probably wont work the next ocaml revision, unless someone picks it up
<whee>
this really sucks :\
lindril has quit ["Client Exiting"]
<robb>
(i am a newbie. what happened? no more preprocessor?)
<steele>
i don't think they will ship a non working version, but this sucks anyways
<steele>
because we wont see any improvements
<whee>
well, daniel was the only one working on the preprocessor, and I highly doubt the core team will want to work on it