<lewis1711>
hmm, I like how you can define arbitrary types
<thelema>
yes, ocaml's typing is nice
<oriba>
no...
<oriba>
...it's amazing :)
<lewis1711>
I think I sort of get it. ocaml does type inference by pattern matching.
<oriba>
Yaron Minsky on types as a practical way to ensure that a lot of errors do not occur (and hence a lot of "unit tests" already are made unnecessary by the typesystem): http://vimeo.com/14313378
<oriba>
a whole bunch (class?) of errors that you have with other languages will not occur with langauges like OCaml, that enforce you to be typlely correct
<oriba>
Minsky explains well, but is a littlebid too verbose for my taste... nevrtheless looking it is fun, if you have some time for it
<oriba>
lewis1711, not type inference by pattern matching, but pattern matching uses type inference for messages that show you, that you maybe missed to match one of the patterns
<oriba>
"messages" -> compiler warnings
<lewis1711>
oh, I am putting the cart before the horse
<oriba>
hehe
<oriba>
maybe sometimes this works... but not here ;)
<oriba>
does ocamlnet or any other lib allow me to read https-pages?
<oriba>
I tried it so far and did not succeed
<Squarism>
is there some nice version of the imperative operator fav "++"
<Squarism>
or is it : i = i + 1
<lewis1711>
nice?
<lewis1711>
as in, no side effects? succ, I think
<lewis1711>
# succ 1;;
<lewis1711>
- : int = 2
<Squarism>
i succ 1
<Squarism>
?
<lewis1711>
hmm, no just succ i
<Squarism>
i didnt get the " - : int = 2 " part
<Squarism>
aha
<Squarism>
ok
<Squarism>
but does not include assignment?
<lewis1711>
# let a = 1;; => val a : int = 1
<lewis1711>
# succ a;; => - : int = 2
<lewis1711>
# a;; =>- : int = 1
<lewis1711>
so a remains unmodified
<lewis1711>
(I'm a noob though, so if someone other than me starts talking listen to them instead)
ikaros has quit [Quit: Leave the magic to Houdini]
mnabil_ has quit [Ping timeout: 265 seconds]
<lewis1711>
http://paste.pocoo.org/show/309504/ this is from "designing applications in ocaml", about recursive types. I am trying to figure out how to use it...how do I declare an int_or_char_list then? [1; 'c'];; doesn't work
<orbitz>
[Int_cons 1; Char_cons 'c']
<orbitz>
rather
<orbitz>
Int_cons (1, (Char_cons 'c', Nil))
<thelema>
[`Int 1; `Char 'c']
<thelema>
ocaml doesn't tag values at runtime with their types, which means the program has to explicitly encode that typing
<lewis1711>
all of the above gave errors
<lewis1711>
"explicitly encode that typing", hmm
<thelema>
lewis1711: note the backquotes
<lewis1711>
agh
<thelema>
`Char 'c' -- one backquote, two single quotes
<orbitz>
lewis1711: what i wrote works fine for me:
<orbitz>
# type foo = Nil | Int_cons of int * foo | Char_cons of char * foo;;
<thelema>
orbitz: yes, the implied type declarations aren't so obvious to a beginner
<lewis1711>
Ah, must've made a typo. that does indeed work
<lewis1711>
now that I know the working syntax, time to figure out what it does ^_^
<thelema>
lewis1711: as a beginner, I recommend doing things orbitz' way
<lewis1711>
with that syntax?
<thelema>
if you want maximal efficiency. A simpler method is to do:
<lewis1711>
don't care about effieciency at this stage. just trying to wrap my heard around recursive types
<thelema>
[type foo = Int of int | Char of char [Int 1; Char 'c']
<thelema>
]
<thelema>
and use the normal list type for the recursion
<orbitz>
lewis1711: what tutorial are you following?
<lewis1711>
Developing applications in Ocaml
<lewis1711>
I very much like it so far. readable while still being concise
<orbitz>
nice
<lewis1711>
why, was there something you'd recommend?
<orbitz>
No, I started with ocaml-tutorial then jumped to just the manual
<lewis1711>
hmm, I may skip over recursive types for now
<orbitz>
do you understand non recursive types
<orbitz>
like
<orbitz>
type int_or_char = Int of int | Char of char ?
<lewis1711>
yeah that makes sense to me
<lewis1711>
int_or_char is going to be one or the other
<lewis1711>
I don't see any use for it aside for using it to specificy the type of a function paramater that for some reason only operates on ints and cars
<lewis1711>
*chars
<orbitz>
the int_or_char type isn't particualrly useful, but ADT's in general ar quite useful
<orbitz>
type connection = Connecting | Connected | Disconnected
<lewis1711>
yeah I started watching a bit of that, but want to do more programming, will watch when I am feeling unproductive
<lewis1711>
perhaps a different example of a recursive type would help. will see what I can google up
<orbitz>
binary tree is commong example
<orbitz>
I think i only find myself using recursive types when it comes to tres
<lewis1711>
"Data of recursive types are usually viewed as directed graphs." hmm
<orbitz>
a tree is a directed graph
<lewis1711>
is it? I thought the definition was that every node was an ithsmus
<lewis1711>
"The various kinds of data structures referred to as trees incomputer science are similar to trees in graph theory, except that computer science trees have directed edges. "
<orbitz>
a narrow stirp o fland?
<lewis1711>
I learnt about trees in maths, haven't taken a compsci course about them
<lewis1711>
but anyway, type ’a btree = Empty | Node of ’a * ’a btree * ’a btree;;
<lewis1711>
found that, makes a bit more sense, will play around with it
<thelema>
bridges are usually edges that if removed, disconnect the graph. In a tree, every edge is a bridge
<Squarism>
:: is prepend... but what is append?
<thelema>
Squarism: can't append to a ocaml list - they're immutable, so you can't modify the tail null to become a pointer to the added node
<orbitz>
Squarism: List.append
<orbitz>
Squarism: and no, :: is cons
<Squarism>
i know they are immutable
<thelema>
you can append one list to another, as orbits points out
<thelema>
*orbitz
<Squarism>
but there is no shorter form than List.append?
<thelema>
yes, @
<orbitz>
ah i always forget its' @
<orbitz>
because Erlang and Haskell are ++
<orbitz>
I think Haskell is ++ at laest
<thelema>
[1;2;3] @ [4;5;6] = [1;2;3;4;5;6]
<Squarism>
is there one for single elements also?
<Squarism>
thanx btw
<thelema>
[1;2;3] @ [4]
<thelema>
really what's happening is that the first list is being prepended to the second. It's not efficient
<lewis1711>
they're linked lists, no?
<orbitz>
yes
<orbitz>
immutableones at that
<lewis1711>
lists, arrays and tuples, oh my:)
roconnor_ has joined #ocaml
roconnor has quit [Ping timeout: 260 seconds]
alexyk has joined #ocaml
<alexyk>
I'm trying to compile oasis, which wants expect.pcre package; that seems to come from ocaml-expect, which wants oasis... circular dep?
<thelema>
alexyk: can you use the precompiled oasis?
<alexyk>
thelema: don't see any for the Mac
<alexyk>
there's however a myocmalbuidl.ml in expect's dir; how do you use ocamlbuild? just say "ocamlbuild"?
<thelema>
ocamlbuild <something>.native
<thelema>
or .byte, if you want to byte-compile
smerz has quit [Quit: Ex-Chat]
boscop has quit [Ping timeout: 240 seconds]
<alexyk>
how do I make it print target list?
<thelema>
'ls'
<thelema>
any .ml file or .itarget is valid
boscop has joined #ocaml
avsm has quit [Ping timeout: 240 seconds]
<alexyk>
thelema: OK, hacked on something... now I have to install expect as a package... How do I call ocamlbuild to do that?
<alexyk>
There's a META in src/
avsm has joined #ocaml
<lewis1711>
orbitz: just saw your connection example in the effective ML video:) most of it is over my head at this stage, but still pretty cool. functors seem interesting.
<oriba>
so we should not help you from now on, because the alarm bell has rung ... time is over :)
<oriba>
... game over ;)
<lewis1711>
lol
<lewis1711>
damn
<oriba>
use bash ;)
<lewis1711>
I am fluent in bash
<lewis1711>
ls, cd, pwd,
<oriba>
oh really?
<lewis1711>
I know all of them
<oriba>
so you can teach me ;)
<oriba>
haha
<lewis1711>
ha
<oriba>
ls, cd, pwd is not bash
<oriba>
ok, cd is bash
alexyk has quit [Read error: Connection reset by peer]
alexyk has joined #ocaml
alexyk has quit [Read error: Connection reset by peer]
<oriba>
gn8... lewis1711
oriba has quit [Quit: Verlassend]
alexyk has joined #ocaml
alexyk has quit [Client Quit]
avsm has quit [Ping timeout: 240 seconds]
avsm has joined #ocaml
kmicinski has joined #ocaml
<Squarism>
how does one set a mutable baseclass variable ?
<Squarism>
when creating a class... (wo passing it along as a parameter to the subclass
mnabil_ has quit [Ping timeout: 255 seconds]
mnabil_ has joined #ocaml
munga has joined #ocaml
lewis1711 has left #ocaml []
roconnor_ has quit [Remote host closed the connection]
lewis1711 has joined #ocaml
munga has quit [Ping timeout: 265 seconds]
<lewis1711>
hmmm, the ocaml <-> C interface looks a tad hairy. I might be lazy and use SWIG (if it has ocaml bindings)
<adrien>
it does, graphviz-ocaml uses it
<adrien>
(bah, can't sleep)
avsm has quit [Ping timeout: 240 seconds]
avsm1 has joined #ocaml
Fullma has joined #ocaml
<julm>
adrien: bed time is now!
<adrien>
I am in bed =P
<julm>
then be smart.
Squarism has quit [Ping timeout: 260 seconds]
kmicinski has quit [Ping timeout: 260 seconds]
lamawithonel_ has joined #ocaml
lamawithonel has quit [Read error: Connection reset by peer]
kmicinski has joined #ocaml
<lewis1711>
can something belong to two types at once? (answer seems to be no by my own experimentation, but i thought I'd check
schmrkc has left #ocaml []
mnabil_ has quit [Ping timeout: 240 seconds]
kmicinski_ has joined #ocaml
kmicinski has quit [Ping timeout: 276 seconds]
mnabil_ has joined #ocaml
kmicinski_ has quit [Ping timeout: 240 seconds]
ikaros has joined #ocaml
<Lajla>
lewis1711, define 'different type'
<Lajla>
I mean, if you make a union type.
<lewis1711>
type functional = Haskell | Scheme | Ocaml;;
<lewis1711>
type imperative = Fortran | Java | Ocaml;;
<lewis1711>
Ocaml is only an imperative language now:(
<mfp>
lewis1711: type functional = [`Haskell | `Scheme | `OCaml] type imperative = [`Fortran | `Java | `OCaml]
<mfp>
`OCaml is : [> `OCaml]
<lewis1711>
ok are those backticks or commas or wha
<lewis1711>
t
emmanuelux has quit [Read error: Connection reset by peer]
mnabil_ has quit [Ping timeout: 240 seconds]
<lewis1711>
I see backticks
<lewis1711>
and then there must be some kind of set trickery at work, to manipulate this
<lewis1711>
but i shall learn it late
mnabil_ has joined #ocaml
ulfdoz has joined #ocaml
ikaros has quit [Quit: Leave the magic to Houdini]
emmanuelux has joined #ocaml
lpereira has joined #ocaml
<adrien>
lewis1711: "polymorphic variants"
<lewis1711>
polymorphic variants
<lewis1711>
hmm
<lewis1711>
add to the list of things to learn
<lewis1711>
the type stuff is really interesting
almaisan-away is now known as al-maisan
lewis1711 has quit [Quit: Leaving.]
jm_ocaml has joined #ocaml
thelema_ has joined #ocaml
thelema has quit [Read error: Connection reset by peer]
mnabil_ has quit [Ping timeout: 255 seconds]
mnabil_ has joined #ocaml
mnabil_ has quit [Remote host closed the connection]
al-maisan is now known as almaisan-away
munga has joined #ocaml
boscop has joined #ocaml
mnabil_ has joined #ocaml
lpereira has quit [Quit: Leaving.]
munga has quit [Quit: Ex-Chat]
mnabil_ has quit [Ping timeout: 240 seconds]
ulfdoz has quit [Quit: brb]
mnabil_ has joined #ocaml
avsm3 has joined #ocaml
avsm1 has quit [Ping timeout: 240 seconds]
ulfdoz has joined #ocaml
Fullma has quit [Quit: Fullma]
opla2 has joined #ocaml
avsm3 has quit [Ping timeout: 240 seconds]
avsm has joined #ocaml
smerz has joined #ocaml
kmicinski_ has joined #ocaml
opla2 has quit [Ping timeout: 255 seconds]
kmicinski_ is now known as kmicinski
cods has quit [Changing host]
cods has joined #ocaml
init1 has joined #ocaml
Smerdyakov has joined #ocaml
WonTu has joined #ocaml
WonTu has left #ocaml []
myu2 has joined #ocaml
Lajla has quit [Ping timeout: 250 seconds]
opla2 has joined #ocaml
almaisan-away is now known as al-maisan
init1 has quit [Quit: Quitte]
raichoo has joined #ocaml
ygrek has joined #ocaml
<gildor>
thelema_: if alexyk comes back (and I am not here), there should be no deps between distributed (tarball) ocaml-expect and oasis, i.e. no circular build depends
<gildor>
(BTW, ocaml-data-notation and ocamlify use also oasis, but oasis generate a self-contained setup.ml that prevents extra build deps)
opla2 has quit [Ping timeout: 276 seconds]
kmicinski has quit [Ping timeout: 255 seconds]
oriba has joined #ocaml
mnabil_ has quit [Ping timeout: 260 seconds]
al-maisan is now known as almaisan-away
<oriba>
who has used libcurl here? I want to read a ebpage to a string and don' tknwo which function to use
<flux>
you need to define your own write function
<flux>
which would probably use Buffer to accumulate the data
<flux>
(be aware that atleast some older versions of libcurl for ocaml have had some memory management issues)
ulfdoz has quit [Ping timeout: 276 seconds]
<oriba>
ok
<oriba>
I also got an examle via mailinglist.
<oriba>
another question, this time regarding OOP-style
<oriba>
I seldom used OOP in OCaml
<oriba>
when I have a method that performs a unit->unit, I saw also method definitions which only have type unit
<oriba>
in some examples I tried both ways, and sometimes the simple unit-typed method failed
<flux>
some people, like me, like to have unit -> unit when a method has a side effect
<oriba>
so should I better write correct unit -> unit typed methods?
<flux>
otherwise I might just use unit
<oriba>
so you also prefer something like method foo () = () instead of method bar = () ?
Lajla has joined #ocaml
<oriba>
it means to have additional () when calling, but looks more consitent to me
<flux>
it also means you can use currying, which can be nice
<oriba>
ah, ok
<oriba>
I thought currying is used for other types only
<oriba>
currying on unit-typed values...
<oriba>
when will that make sense?
<flux>
you cannot curry unit-typed methods
<oriba>
is this like CPS ?
<oriba>
ok
<flux>
currying is sometimes used in CPS, but I don't think it is related in this case
<oriba>
but why did you mention it here?
<flux>
you can pass a method as a higher-order function easily into another function if you have an () argument in it
<flux>
otherwise you need to write a specific anonymous function like (fun () -> x#foo)
<oriba>
you mean a worker function with type (unit->unit) as argument?
<flux>
I suppose in this case it could be called just passing a function instead of currying, because we give no arguments to it :)
<flux>
yes
<oriba>
but something like (string->unit) would make sense, but that's not where we started from...
Smerdyakov has quit [Quit: Leaving]
jm_ocaml has quit [Quit: Konversation terminated!]
jm_ocaml has joined #ocaml
ygrek has quit [Ping timeout: 240 seconds]
jonafan has joined #ocaml
mnabil_ has joined #ocaml
jm_ocaml has quit [Remote host closed the connection]
lewis1711 has joined #ocaml
zhengli has joined #ocaml
zzz_ has quit [Quit: Bye]
zzz_ has joined #ocaml
zhengli has quit [Client Quit]
mjsor has joined #ocaml
mjsor has quit [Remote host closed the connection]