cjeris changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/
joelr1 has joined #ocaml
<joelr1>
good evenin
<joelr1>
g
<joelr1>
what's the way to shorten Hashtable to H when opening?
<joelr1>
module H = Hashtable, yes!
joelr1 has quit [Client Quit]
pedro_soc has quit [Read error: 110 (Connection timed out)]
pedro_soc has joined #ocaml
joelr1 has joined #ocaml
<joelr1>
anyone alive?
<mrvn>
no
<joelr1>
mrvn: good evening
<joelr1>
mrvn: i have an issue with functors, can you help?
<joelr1>
i think it's something very simple
<mrvn>
maybe
<joelr1>
let me find a paste bot...
<joelr1>
darn, no pastebot on this channel?
<joelr1>
mrvn: here
<joelr1>
module P = Easy_parser.Make
<joelr1>
(
<joelr1>
struct
<joelr1>
type t = Symtab.symtab_t
<joelr1>
let symtab = Symtab.symtab
<joelr1>
end
<joelr1>
)
<joelr1>
mrvn: does this look correct to you?
<joelr1>
assuming that there is a type token inside P that has a constructor ABOVE, i can refer to it as P.ABOVE
<joelr1>
mrvn: how do i refer to the symtab function within the module that uses the functor above?
<mrvn>
Easy_parser is your functor?
<joelr1>
yep
<joelr1>
it is
<joelr1>
i instantiate it with Symtab.symtab oh... i think i get it
<joelr1>
i'm stupid. symtab is for use _within_ the functor!!!
<joelr1>
i'm an imbecil
<mrvn>
Then you should have something like module P = Easy_parser(struct type t = Symtab.symtab_t let symtab = Symtab.symtab end )
<joelr1>
mrvn: that's exactly what i pasted, right?
<mrvn>
no
<joelr1>
the issue is that i got confused by symtabs
<joelr1>
mrvn: mea culpa, not the same. what's the difference, though? i think i had a type error when i had the code without Make
<mrvn>
You might even mean module P = Easy_parser(Symtab)
<joelr1>
mrvn: the error referred to the thing not being a functor, i think, and listed Make in there. once I plugged in Make the error went away
<mrvn>
Then the Make is your functor
<joelr1>
ok
<joelr1>
mrvn: thanks a lot
joelr1 has quit []
moconnor has joined #ocaml
<moconnor>
How do you read the entire contents of a file at once? Rather than using input to read in chunks at a time?
<mrvn>
Unix.read
<mrvn>
Or use the Buffer module.
<mrvn>
val add_channel : t -> in_channel -> int -> unit
<mrvn>
add_channel b ic n reads exactly n character from the input channel ic and stores them at the end of buffer b. Raise End_of_file if the channel contains fewer than n characters.
<moconnor>
mrvn: thanks!
postalchris has quit [Read error: 104 (Connection reset by peer)]
shawn_ has joined #ocaml
shawn_ has quit [Connection reset by peer]
shawn_ has joined #ocaml
<rturner>
newbie alert! how do i match on the type of a list? i'm trying to select a function based on the list type passed as argument
<Smerdyakov>
Impossible.
<rturner>
ah :)
<rturner>
ok, I'm completely new to ocaml so am thinking the wrong way
<mrvn>
You can't match type, only structure.
<rturner>
unfortunately i don't know which way to think :)
<rturner>
ok,thanks
<mrvn>
The type get infered from how you use the bindings. e.g. # let add a b = a + b;;
<mrvn>
val add : int -> int -> int = <fun>
<mrvn>
Since + only works on ints a and b must be int so add mut be int -> int -> int. The same works for any other type incluing lists.
<rturner>
yes
<Smerdyakov>
mrvn, are you sure this advice has any bearing on his problem?
<rturner>
i was trying something like this
<rturner>
never mind i don't want to paste in here do i
<Smerdyakov>
You sure don't.
<mrvn>
On the other hand you can match structure: let rec loop = function [] -> () | x::xs -> loop xs
<mrvn>
rturner: you can paste a few lines. If it is longer than use some pastebin.
<rturner>
here come 5 lines then
<rturner>
let array_printer a =
<rturner>
let f = match a with
<rturner>
int -> print_int
<rturner>
|string -> print_endline
<rturner>
in
<rturner>
Array.iter f a;;
<rturner>
i wanted to select the function to use in the iteractor
<rturner>
iterator depending on the type of the array
<mrvn>
That can never work. A function must have one type only
<Smerdyakov>
rturner, all type information is erased at compile time in OCaml.
<rturner>
this is my 10th line of ocaml btw :)
<rturner>
i just started this evening
<Smerdyakov>
rturner, what source are you using to learn OCaml?
<mrvn>
Why don't you just call 'Array.iter print_int a' or 'Array.iter print_string a;;' as needed?
<rturner>
i have 2 or 3 tutorials
<Smerdyakov>
rturner, that's silly. You should pick one and read it through.
<rturner>
well i wanted to know how to select functions i guess
<rturner>
i'm a silly billy
<mrvn>
You can use a variant type: type int_or_string = Int of int | String of string
<Smerdyakov>
Yeah, you are. You don't seem to know much about how to learn a programming language.
<rturner>
i bow humbly to you
<Smerdyakov>
That's a ridiculous response, like a little kid pouting instead of taking advice to heart.
<Smerdyakov>
My advice is that you can't learn a new programming language without reading documents that set out its basic principles systematicaly.
<rturner>
chill, i stated in advance i was a noob
<rturner>
and there;s nothing wrong with a lot of learning materials either, different perspectives
<Smerdyakov>
I have to disagree. It's objectively worse.
<mrvn>
Better to have one good one and follow that then to mix.
<rturner>
sure, can you recommend a good one Smerdyakov
<Smerdyakov>
mbishop, I don't like that link, because it points into one chapter of Part I, not the whole thing.
<rturner>
i have the whole thing
<rturner>
thanks mbishop
<mrvn>
Smerdyakov: it has an "up" link.
<mbishop>
indeed, but there's no link to "Part I"
<mbishop>
even better, it has a next arrow at the bottom, just follow till you get to Part II :)
<rturner>
:) that's what that's for
<rturner>
i'm learning all the time Smerdyakov
z__z has quit [Read error: 110 (Connection timed out)]
Smerdyakov has quit ["Leaving"]
shawn_ has quit ["This computer has gone to sleep"]
rturner has quit ["Ex-Chat"]
dss has joined #ocaml
pstickne has quit [Success]
dss has quit [Remote closed the connection]
pstickne has joined #ocaml
shawn_ has joined #ocaml
dss has joined #ocaml
pedro_soc has quit [Remote closed the connection]
ikaros has joined #ocaml
itai has joined #ocaml
skal has joined #ocaml
swater has joined #ocaml
swater_ has joined #ocaml
ikaros has quit ["segfault"]
swater_ has quit [Client Quit]
shawn_ has quit [Read error: 110 (Connection timed out)]
rickardg has joined #ocaml
rickardg has quit [Remote closed the connection]
Submarine has quit ["Leaving"]
jlouis has quit [Read error: 104 (Connection reset by peer)]
jlouis has joined #ocaml
_JusSx_ has joined #ocaml
Demitar has quit ["Ex-Chat"]
rturner has joined #ocaml
vital303 has quit ["Leaving."]
vital303 has joined #ocaml
Demitar has joined #ocaml
Demitar has quit ["Ex-Chat"]
pango has quit [Remote closed the connection]
pango has joined #ocaml
skal_ has joined #ocaml
skal has quit [Read error: 110 (Connection timed out)]
rickardg has joined #ocaml
as has joined #ocaml
as has quit [Client Quit]
postalchris has joined #ocaml
postalchris has quit [Client Quit]
Smerdyakov has joined #ocaml
slipstream has joined #ocaml
slipstream-- has quit [Read error: 110 (Connection timed out)]
skal_ has quit [Read error: 104 (Connection reset by peer)]
<flux>
hmm.. is there an nntp client library for ocaml?
<flux>
I begun writing a simple rss-nntp-gateway, having first searched "yes, there is an nntp-library", but now not having much success..
<flux>
it's not a big task to do, of course, but ready-made is ready-made :)
dss has quit [Remote closed the connection]
<flux>
this is sort of offtopic, but google isn't giving me much.. how is one supposed to understand an atom-feed entry id such as tag:blogger.com,1999:blog-4200019114620897061.post-6185263052958657766?
<flux>
is it like: tag=.... or tag=blogger.com and value=1999:blog.. or tag=blogger.com,1999 and value=blog-.. ?
<flux>
it doesn't really matter which one I choose, but it would be nice to pick the right one
<flux>
actually 1999 appears to be the year when the domain has been registered, so it's either the first or the last version
vital303 has quit [Success]
swater has quit [Read error: 110 (Connection timed out)]
swater has joined #ocaml
benny_ has joined #ocaml
benny has quit [Read error: 110 (Connection timed out)]
benny_ is now known as benny
rickardg has quit [Remote closed the connection]
swater has quit ["Quat"]
itai has quit [Read error: 110 (Connection timed out)]