benmachine has quit [Remote host closed the connection]
sw2wolf has joined #ocaml
djcoin has quit [Quit: WeeChat 0.3.9.2]
milosn_ has joined #ocaml
milosn has quit [Ping timeout: 248 seconds]
lolcathost has quit [Ping timeout: 255 seconds]
mattrepl has joined #ocaml
mattrepl has quit [Client Quit]
lolcathost has joined #ocaml
doomrobo has joined #ocaml
<doomrobo>
hey, there
madroach has quit [Ping timeout: 248 seconds]
madroach has joined #ocaml
mattrepl has joined #ocaml
mattrepl has quit [Client Quit]
cdidd has quit [Ping timeout: 248 seconds]
weie has joined #ocaml
cdidd has joined #ocaml
doomrobo is now known as doomrobo|away
lolcathost is now known as Automorphism
sw2wolf is now known as sw2wolf{away}
Automorphism has quit [Ping timeout: 260 seconds]
lolcathost has joined #ocaml
doomrobo|away has quit [Quit: Leaving]
cdidd has quit [Read error: Connection reset by peer]
cdidd has joined #ocaml
Submarine has quit [Ping timeout: 264 seconds]
loy has joined #ocaml
lolcathost is now known as Automorphism
loy has quit [Remote host closed the connection]
sw2wolf{away} is now known as sw2wolf
cdidd has quit [Read error: Connection reset by peer]
weie has quit [Quit: Leaving...]
Yoric has joined #ocaml
sw2wolf is now known as sw2wolf{away}
adotbrown has quit [Ping timeout: 265 seconds]
ttamttam has joined #ocaml
Yoric has quit [Ping timeout: 246 seconds]
thomasga has joined #ocaml
Automorphism has quit [Ping timeout: 276 seconds]
Demitar has quit [Ping timeout: 276 seconds]
lolcathost has joined #ocaml
ftrvxmtrx_ has joined #ocaml
adrien_o1w has joined #ocaml
adrien_oww has quit [Ping timeout: 265 seconds]
thomasga has quit [Quit: Leaving.]
chambart has joined #ocaml
hkBst has joined #ocaml
hkBst has quit [Changing host]
hkBst has joined #ocaml
weie has joined #ocaml
Yoric has joined #ocaml
mika1 has joined #ocaml
adotbrown has joined #ocaml
cago has joined #ocaml
Tobu has quit [Ping timeout: 260 seconds]
djcoin has joined #ocaml
thomasga has joined #ocaml
adrien_o1w is now known as adrien_oww
mye has joined #ocaml
gour has joined #ocaml
ontologiae has joined #ocaml
RagingDave has joined #ocaml
fusillia has joined #ocaml
adotbrown has quit [Ping timeout: 264 seconds]
adotbrown has joined #ocaml
Yoric has quit [Ping timeout: 252 seconds]
myx has joined #ocaml
gour has quit [Disconnected by services]
gour_ has joined #ocaml
sw2wolf{away} has quit [Remote host closed the connection]
adotbrown has quit [Ping timeout: 260 seconds]
_andre has joined #ocaml
adotbrown has joined #ocaml
adotbrown has quit [Ping timeout: 264 seconds]
Kakadu has joined #ocaml
Kakadu has quit [Client Quit]
Kakadu has joined #ocaml
mika1 has quit [Quit: Leaving.]
mika1 has joined #ocaml
mika1 has quit [Client Quit]
hkBst has quit [Read error: Connection reset by peer]
hkBst has joined #ocaml
hkBst has quit [Changing host]
hkBst has joined #ocaml
dwmw2_gone is now known as dwmw2
weie has quit [Quit: Leaving...]
thizanne has quit [Ping timeout: 264 seconds]
fusillia has quit [Read error: Connection reset by peer]
cago has quit [Ping timeout: 252 seconds]
invariant has joined #ocaml
cago has joined #ocaml
<invariant>
How can I execute a command for every file in a directory? Is there a library which doesn't require me to write a loop is mostly what I want to know.
<asmanur>
Array.map (fun s -> ...) (Sys.readdir "directory")
<xavierm02>
so I want to use the set representations of automata
<xavierm02>
is there any way I could do a type
<xavierm02>
type ('state, 'letter) automaton
<xavierm02>
?
<flux>
sounds the way it would normally be done?
<xavierm02>
yeah
<xavierm02>
well
<flux>
ah, so you're asking if you can have Set based on a polymorphic type
<xavierm02>
the things I saw were using functions
<xavierm02>
yes
<xavierm02>
and apparently I can't :(
<xavierm02>
aide from doing my own unefficient set structure
<xavierm02>
aside*
<xavierm02>
oh wait
<xavierm02>
I have to use a functor
<xavierm02>
right?
<flux>
I think it's possible to use the Set here, thanks to the newish type binding feature
<flux>
yes, and you use functor on that
<xavierm02>
what "newish type binding feature"?
<flux>
I think it was introduced in 3.12.1, it works like:
<flux>
let foo (type a) a = let module S = Set.Make(struct type t = a let compare = compare) in S.singleton a
<flux>
or something
<flux>
figured that it wouldn't work (besides the missing 'end') due to type escape issue
<flux>
but you can do everything else but return values of type S.t
<flux>
so what you do is that you have a record of operations and you return such a record from that function
<flux>
xavierm02, but maybe a better approach is to functorize your state machine as well
<flux>
xavierm02, I mean, what if I want to use custom records for state and input?
<xavierm02>
you lost me
tane has joined #ocaml
<xavierm02>
I'll just try doing it with functions
<flux>
where did I lose you?
<xavierm02>
and show you and you tell me what I did wrong
<xavierm02>
last 3 posts
<djcoin>
flux: is S.singleton part of some std lib ? and also what does let foo (type a) a is supposed to mean ? (i'm sorry I don't use ocaml frequently and I often missed some features)
<flux>
djcoin, Set.S.singleton is part of std lib, so it becomes part of the local S module as well
<flux>
djcoin, (type a) means somewhere there is a type called 'a' that is the same during the definition of that function
<flux>
in this case the variable 'a' gets bound to that type 'a'. maybe I shouldn't have used the same name :)
<flux>
untested: let mk_set (type a) () = let module S = Set.Make(struct type t = a let compare = compare) in let s = ref S.empty in let add x = s := S.add x !s in let mem x = S.mem x !s in (add, mem)
<flux>
I'm uncertain how to make that functional, though. ideas?
teamon has left #ocaml []
<flux>
(and again I missed 'end' in "compare)")
<djcoin>
It is like extracting/factorizing a type constraint on top of the function ?
<flux>
djcoin, sort of. it's giving a name to a type. you could write: let foo (type a) (x : a) = ..
<djcoin>
like a let definition but for a type in a sense ?
<flux>
and when you have a name to the type, you can then create modules referring to that name
<flux>
and you could use those modules with functors
<djcoin>
Ok, thanks for the explanation didn't know this feature
<djcoin>
:)
<xavierm02>
oh
<flux>
I imagine many people have tried this but failed, before that feature was implemented: let foo (a : 'a) = let module M = struct type t = 'a ..; but that of course fails due to 'a not being anymore in the scope
<flux>
so it sort of is an enlargened scope for type variables (with name)
<xavierm02>
any idea where I could find ORDERED_SET
<xavierm02>
module type ORDERED_TYPE =
<xavierm02>
sig
<xavierm02>
type t
<xavierm02>
val compare: t -> t -> comparison
<xavierm02>
end;;
<xavierm02>
?
zorun has joined #ocaml
<xavierm02>
because I need to use the one used by Set
<xavierm02>
right?
<flux>
xavierm02, I created those in my examples :)
<xavierm02>
I can't just redefine a new one
<flux>
the struct-part
<flux>
why not?
<xavierm02>
O_O
<xavierm02>
Well... Last time I defined the exact same type in two different modules I get very strange errors
<flux>
try this: module S = Set.Make(struct type t = int let compare = Pervasives.compare end);;
<xavierm02>
so I thought I had to reference it somehow
<flux>
you can give it a name if you want..
<flux>
batteries comes with modules Int etc that are compatible with that signature
mgodshall has joined #ocaml
<xavierm02>
ok
mye has joined #ocaml
<zorun>
hi
<xavierm02>
ty
<zorun>
I have a collection of modules, all with the same signatures
<zorun>
I'd like to bind a module name to point to one of them, depending on some condition
<flux>
you can use first class module support for that
<zorun>
I haven't found any way to do that, since you can't really manipulate modules
<zorun>
oh, right
<zorun>
oh, that was the new feature from ocaml 3.12 \o/
<xavierm02>
open Set;;
<xavierm02>
module Automaton =
<xavierm02>
functor (Elt: ORDERED_TYPE) ->
<xavierm02>
struct
<xavierm02>
type q = int
<xavierm02>
end
<xavierm02>
;;
<xavierm02>
ORDERED_TYPE
<xavierm02>
Error: Unbound module type ORDERED_TYPE
<xavierm02>
do I really just add the definition and it works?
<zorun>
do you want to define a functor, or to simply use an existing one?
<flux>
the module type is actually OrderedType.. it's only called ORDERED_TYPE when it's the parameter..
<xavierm02>
well
<flux>
where did you pick that ORDERED_TYPE?
<xavierm02>
I'll have my Automaton functor use the Set functor
<xavierm02>
and the Set functor needs modules of type ORDERED_TYPE
<xavierm02>
so it must be defined somewhere in Set :/
<flux>
according to what reference?
<xavierm02>
ok don't mind me
<xavierm02>
I'm stupid
<xavierm02>
it's OrderedType
<xavierm02>
I just had
<xavierm02>
an old page apparently
<xavierm02>
>_<
wossname has joined #ocaml
<xavierm02>
open Set;;
<xavierm02>
module Automaton =
<xavierm02>
functor (Elt: OrderedType) ->
<xavierm02>
struct
<xavierm02>
type q = Set.Make(Elt)
<xavierm02>
end
<xavierm02>
;;
<xavierm02>
How do I do that?
<flux>
you know, you could just compress those to oneliners or use a paste site.. ;)
<flux>
type q = Set.Make(Elt) is the problem, right?
<xavierm02>
yes
<xavierm02>
Syntax error
<flux>
I think you probably want to do
<flux>
module MySet = Set.Make(Elt) instead
<flux>
and possibly type q = MySet.t
<flux>
unless you intend to use the first class module support
<thelema>
xavierm02: ah, the hdoc/ folder is for 1.x
<thelema>
oh yeah, you're using 1.x
<thelema>
hmm, I wonder when that was last updated...
<thelema>
It's probably not up to date for 1.5...
<xavierm02>
I have 1.4.3
<xavierm02>
T.T
<thelema>
xavierm02: any chance of upgrading?
<xavierm02>
well
<xavierm02>
I'm kind of a noob
<xavierm02>
so I don't like installing things without the package manager
<xavierm02>
i'll check testing and sid
<xavierm02>
see if there are newer versions
<thelema>
2.0 is very unlikely to be available there.
<thelema>
is there an ocaml-batteries-doc package? that doc should be up to date.
<xavierm02>
but the Ord thing
<xavierm02>
didn't come in 2.0, did it?
<thelema>
may have.
<xavierm02>
:/
<thelema>
it's not difficult to write your own compare function for a 3-tuple
mye has joined #ocaml
<xavierm02>
yeah
<xavierm02>
I was doing this
<xavierm02>
when I found out tuple things existed
<thelema>
it sounds like you'll have to go back to that.
<xavierm02>
same version in sid :(
mattrepl has quit [Quit: mattrepl]
mye has quit [Ping timeout: 276 seconds]
thomasga has quit [Quit: Leaving.]
jamii has joined #ocaml
<xavierm02>
here is the current code: http://pastebin.com/DAky0UVt please let me know if I did anything stupid :)
<thelema>
"local"?
<thelema>
hmm, odd. I got a totally different paste somehow...
<thelema>
anyway, found your paste
<thelema>
that'll work. I hope you're not being graded on speed
<thelema>
also, you'll need a Set.find for the use of Set to work.
<thelema>
batteries doesn't have this, and the stdlib only just added this
<thelema>
(which means batteries will have to add this in 2.1)
<xavierm02>
O_O
<xavierm02>
I assumed there was a find function
<thelema>
nope, just mem.
<thelema>
which returns a boolean saying whether the given element is in the set
<xavierm02>
okay
<xavierm02>
so I need the alphabet too
<thelema>
you want a Map for this anyway
<xavierm02>
for this thing to work
<xavierm02>
why?
<thelema>
because automaton is (q, sigma) -> {q}
<xavierm02>
no
<xavierm02>
that's deterministic
<thelema>
{q} - set of states
<xavierm02>
ah
<xavierm02>
didn't think of it that way :o
<xavierm02>
I'll do that
<xavierm02>
ty :)
<thelema>
n/p
* thelema
goes back to his automata theory research
<xavierm02>
when you said you hoped I wasn't graded on speed, was it because I used a set to represent transitions?
<thelema>
yes
<xavierm02>
k
Demitar has quit [Ping timeout: 255 seconds]
<thelema>
fastest is to use array for transition table
<thelema>
this takes up lots of ram for large automata
<xavierm02>
"this" = Map?
<thelema>
array
<xavierm02>
:o
<xavierm02>
oh
<xavierm02>
2D array?
<thelema>
yes
myx has quit [Ping timeout: 248 seconds]
mye has joined #ocaml
smondet has joined #ocaml
<xavierm02>
but that implies having states and letters as ints
milosn has joined #ocaml
<thelema>
true. states as ints is generally pretty easy, and letters all have ascii codes
<thelema>
the trick is knowing the number of states before constructing the array
milosn_ has quit [Ping timeout: 248 seconds]
<xavierm02>
type automaton = {
<xavierm02>
number_of_states: int;
<xavierm02>
transitions: IntSet.t array array;
<xavierm02>
start_states: IntSet.t;
<xavierm02>
end_set: IntSet.t
<xavierm02>
}
<xavierm02>
so this is the efficient implementation?
tane has left #ocaml []
<thelema>
yes, although hard to build directly; you'll need a flexible number of states to build the automaton, but this is more efficient for parsing speed than before
<thelema>
I shouldn't have distracted you with efficiency; go back to StateSet.t and StateSet.t StateLetterMap.t
<thelema>
it'll make your life easier; after you have everything else working you can optimize.
<xavierm02>
I haven't removed it
<xavierm02>
now I have math_automaton
<xavierm02>
and fast_automaton :)
<thelema>
ok
<xavierm02>
so I'll do reduction etc. on math_automaton
<xavierm02>
and then go to fast_automaton to check if works are recognized
<xavierm02>
words*
<thelema>
ok, have fun
mye has quit [Ping timeout: 255 seconds]
<thelema>
btw, you may not notice any difference in parsing speed depending on how long the text you're matching is.
pango_ has joined #ocaml
pango has quit [Ping timeout: 264 seconds]
jamii has quit [Read error: No route to host]
pango_ is now known as pango
thomasga has joined #ocaml
mye has joined #ocaml
weie has quit [Quit: Leaving...]
mye_ has joined #ocaml
Yoric has joined #ocaml
mye has quit [Ping timeout: 276 seconds]
mye_ has quit [Ping timeout: 265 seconds]
ontologiae has quit [Ping timeout: 252 seconds]
<xavierm02>
Error: The record field label transitions belongs to the type fast_automaton
<xavierm02>
but is mixed here with labels of type math_automaton
<xavierm02>
O_O
<thelema>
can't use the same record field labels
<xavierm02>
oh wait
<thelema>
at least not in the same module
<xavierm02>
I wrote end_states
<xavierm02>
instead of final_states
<xavierm02>
still doesnt work
<xavierm02>
hm
<xavierm02>
so
<xavierm02>
ok ty, I'll change the names :)
ski has quit [Quit: leaving]
mye has joined #ocaml
ski has joined #ocaml
jbrown has quit [Quit: Client exiting]
mye has quit [Ping timeout: 276 seconds]
<xavierm02>
type 'a t = {
<xavierm02>
b: 'a
<xavierm02>
} contraint 'a = int;;
<xavierm02>
how do I put a constraint on a sum type?
<xavierm02>
just after the } or just before it both fail
<xavierm02>
:/
<adrien>
which one would you do?
<xavierm02>
I don't understand your question
<xavierm02>
type 'a t = {
<xavierm02>
b: 'a
<xavierm02>
} contraint 'a = int;;
<xavierm02>
fails
<xavierm02>
type 'a t = {
<xavierm02>
b: 'a contraint 'a = int
<xavierm02>
};;
<xavierm02>
fails too
<xavierm02>
so I have no idea how to do it
<adrien>
which type would you want?
<adrien>
I'd personally write that : type t = { b : int }
<adrien>
so...
<xavierm02>
-.-
<xavierm02>
it's an oversimplified example
<xavierm02>
I have two sum types
<xavierm02>
that are quite close
<adrien>
I don't think I've ever seen constraints on records (but that doesn't mean they don't exist)
hongboz has joined #ocaml
<xavierm02>
in fact they only have one type that is different
<xavierm02>
so instead of having to change all my labels
<xavierm02>
I wanted to regroup both sum types into one
<xavierm02>
and put that one type that changes as a parameter
<adrien>
type math_automaton = { automaton : automaton; field1: int; field2: int }
<adrien>
these aren't sum types, they are records
<xavierm02>
ok
<xavierm02>
records
<adrien>
can you show them?
<xavierm02>
type math_automaton = {
<xavierm02>
number_of_states: int;
<xavierm02>
transitions: transition_set;
<xavierm02>
start_states_m: state_set;
<xavierm02>
final_states_m: state_set
<xavierm02>
};;
<xavierm02>
type fast_automaton = {
<xavierm02>
number_of_states: int;
<xavierm02>
transitions: state_set array array;
<xavierm02>
start_states_f: state_set;
<xavierm02>
final_set_f: state_set
<xavierm02>
};;
<xavierm02>
without the _m and _f
<hongboz>
xavierm02: you can paste the code in some website, and post a link here :-)
<xavierm02>
so I wanted
<adrien>
type automaton = { number_of_states: int; transitions: state set array array; start_states: state_set }
<adrien>
type fast_automaton = { automaton: automaton; final_set: state_set }
<xavierm02>
yeah
<xavierm02>
but if I do that
<adrien>
and then use v.automaton.number_of_states?
<xavierm02>
I can't have a function
<xavierm02>
get_states
<xavierm02>
that works for both
<xavierm02>
etc.
<xavierm02>
or
<xavierm02>
can I?
<adrien>
actually both have a field named "automaton" too :-)
* adrien
is a bit tired
<adrien>
that would work if you have two namespaces and pass the "automaton" field instead
<adrien>
but I'm sorry, I'm way too tired to think about type design
RagingDave has quit [Quit: Ex-Chat]
<xavierm02>
ok, ty :)
mye has joined #ocaml
Anarchos has joined #ocaml
mye has quit [Ping timeout: 255 seconds]
<xavierm02>
I know I can just use \r\n
<xavierm02>
but our of curiosity, is there some way to know what the current system uses to represent newlines?
<xavierm02>
out*
chambart has quit [Ping timeout: 264 seconds]
answer_42 has quit [Ping timeout: 276 seconds]
ontologiae has joined #ocaml
<Anarchos>
xavierm02 compare the output of print_endline() ?
<xavierm02>
but how do I do that from inside ocaml?
<xavierm02>
because if it gets printed, I can't get it in a string
<adrien>
well actually you should just use "\n"
<adrien>
simply avoid "\r\n"
<xavierm02>
:o
<xavierm02>
I thought \r\n was better
<xavierm02>
doesn't \n fail on Mac/Windows?
_andre has quit [Quit: leaving]
mye has joined #ocaml
hongboz has quit [Ping timeout: 264 seconds]
<adrien>
mac os used \r
<adrien>
that was mac os, not mac os x
<adrien>
as for windows if you open the file in so-called "text mode", \n will be translated to \r\n when you write
<adrien>
and \r\n will be translated to \n when you read
<adrien>
but you should simply not care about it since basically all applications handle \n
mye has quit [Ping timeout: 264 seconds]
ontologiae has quit [Ping timeout: 244 seconds]
Demitar has joined #ocaml
mye has joined #ocaml
metasyntax has quit [Quit: Leaving]
<xavierm02>
ok, ty :)
mye has quit [Ping timeout: 244 seconds]
chambart has joined #ocaml
Snark has quit [Quit: Quitte]
gnuvince_ has quit [Quit: reboot]
<gour_>
ocamldoc is not meant to serve as reST/Sphinx where one can annotate source code as well as write general documentation like user manual in the same markup?
gour_ is now known as gour
Cyanure has joined #ocaml
mye has joined #ocaml
<thelema>
gour: you can annotate source code, but the usual way to use it is to annotate the .mli file that has the public interface; when used this way, code isn't kept in the output.
<gour>
thelema: ok..but still means ocamldoc is used for documenting e.g. API and not writing general docs like manuals, right?
<thelema>
It could be used for general docs like manuals; although I always see it for documenting API.
<gour>
i wonder what kind of markup is available for writin general docs
gnuvince has joined #ocaml
ulfdoz has joined #ocaml
mye_ has joined #ocaml
mye has quit [Ping timeout: 260 seconds]
mye_ is now known as mye
nimred has quit [Quit: Lost terminal]
gour has quit [Quit: WeeChat 0.3.8]
fraggle_ has quit [Ping timeout: 264 seconds]
fraggle_ has joined #ocaml
lolcathost is now known as lolcathots
Yoric has quit [Ping timeout: 246 seconds]
lolcathots is now known as Automorphism
Reventlov has quit [Quit: leaving]
nimred has joined #ocaml
nimred has quit [Quit: Lost terminal]
wossname has quit [Ping timeout: 240 seconds]
gnuvince has quit [Quit: Remember when men were men and regular expressions recognized regular languages?]
gnuvince has joined #ocaml
sad0ur has quit [Ping timeout: 244 seconds]
Automorphism has quit [Quit: When I come back, please tell me in what new ways you have decided to be completely wrong.]
sad0ur has joined #ocaml
Playground has joined #ocaml
mye has quit [Ping timeout: 248 seconds]
nimred has joined #ocaml
Cyanure has quit [Remote host closed the connection]
xavierm02 has quit [Quit: Leaving]
jbrown has joined #ocaml
ontologiae has joined #ocaml
ontologiae has quit [Ping timeout: 264 seconds]
Playground has quit [Quit: When I come back, please tell me in what new ways you have decided to be completely wrong.]
lolcathost has joined #ocaml
pkrnj has joined #ocaml
lolcathost has quit [Client Quit]
Playground has joined #ocaml
Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]