gildor changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | OCaml 3.12.0 http://bit.ly/aNZBUp
sepp2k has joined #ocaml
joewilliams_away is now known as joewilliams
Fullma has joined #ocaml
RyanRN has quit [Read error: Connection reset by peer]
RyanRN has joined #ocaml
tony_ has quit [Ping timeout: 240 seconds]
lopex has quit []
enthymeme has joined #ocaml
myu2 has quit [Remote host closed the connection]
joewilliams is now known as joewilliams_away
Amorphous has quit [Ping timeout: 272 seconds]
arubin has quit [Quit: arubin]
Amorphous has joined #ocaml
philtor has joined #ocaml
myu2 has joined #ocaml
eye-scuzzy has quit [Ping timeout: 272 seconds]
eye-scuzzy has joined #ocaml
eye-scuzzy has quit [Ping timeout: 240 seconds]
eye-scuzzy has joined #ocaml
joewilliams_away is now known as joewilliams
kaustuv has joined #ocaml
myu2 has quit [Remote host closed the connection]
eye-scuzzy has quit [Ping timeout: 272 seconds]
eye-scuzzy has joined #ocaml
tnguyen has joined #ocaml
joewilliams is now known as joewilliams_away
mnabil has quit [Read error: Operation timed out]
Yoric has joined #ocaml
ygrek has joined #ocaml
yezariaely has joined #ocaml
yezariaely has left #ocaml []
yezariaely has joined #ocaml
edwin has joined #ocaml
ftrvxmtrx has quit [Quit: Leaving]
cyanure has joined #ocaml
ttamttam has joined #ocaml
ymasory has quit [Ping timeout: 240 seconds]
ymasory has joined #ocaml
tnguyen has quit [Remote host closed the connection]
Fullma has quit [Quit: Fullma]
Yoric has quit [Quit: Yoric]
ikaros has joined #ocaml
mnabil has joined #ocaml
munga has joined #ocaml
ygrek has quit [Remote host closed the connection]
enthymeme has quit [Quit: G'night!]
Yoric has joined #ocaml
_andre has joined #ocaml
munga has quit [Ping timeout: 272 seconds]
avsm has joined #ocaml
ftrvxmtrx has joined #ocaml
mfp has quit [Quit: Leaving]
mfp has joined #ocaml
seafood has joined #ocaml
sepp2k has quit [Quit: Leaving.]
tony_ has joined #ocaml
tony_ has quit [Client Quit]
tony_ has joined #ocaml
tony_ is now known as aweset
aweset is now known as awest
ygrek has joined #ocaml
seafood has quit [Quit: seafood]
lopex has joined #ocaml
avsm has quit [Quit: Leaving.]
awest has quit [Ping timeout: 272 seconds]
Yoric has quit [Read error: Connection reset by peer]
Yoric has joined #ocaml
Yoric has quit [Client Quit]
Yoric has joined #ocaml
ygrek has quit [Remote host closed the connection]
RyanRN has quit [Quit: Leaving.]
rien has quit [Quit: Computer has gone to sleep]
myu2 has joined #ocaml
awest has joined #ocaml
myu2 has quit [Remote host closed the connection]
RyanRN has joined #ocaml
RyanRN has quit [Client Quit]
hto has quit [Quit: Lost terminal]
hto has joined #ocaml
hto_ has joined #ocaml
hto__ has joined #ocaml
hto has quit [Client Quit]
hto_ has quit [Client Quit]
hto__ has quit [Client Quit]
hto has joined #ocaml
awest has quit [Quit: Ex-Chat]
amaw has joined #ocaml
<thelema> hmm, I'm trying to write a (stateful) flip-flop function of type ['a -> bool] which returns true for the first 'a passed to it and returns true until the latest value is not equal to that first value, when it switches to returning false
<thelema> it would stay at false for the same input value until the input changes again, and then it returns true
<thelema> http://pastebin.com/1Dq4gyQw <- This isn't hard, but I want to get rid of the first "'a ->"
cthuluh has quit [Ping timeout: 272 seconds]
<mrvn> thelema: make it an option
<thelema> I could deal with () -> 'a -> bool
<thelema> I guess I'll have to deal with options, then.
<thelema> this code is so much cleaner w/o options
<mrvn> yes
Yoric has quit [Read error: Connection reset by peer]
Yoric has joined #ocaml
cthuluh has joined #ocaml
<thelema> http://pastebin.com/jQKwURGr <- v2.0 (what I really wanted)
<mrvn> It is more like an edge trigger than a flip-flop.
<thelema> let edge_trigger f = ...?
<mrvn> or change_trigger
<mrvn> change_flop?
<thelema> change_flip?
<thelema> it doesn't flop the output on change, it flips it
<mrvn> right
boscop has joined #ocaml
<thelema> This function is needed/useful for Enum.group
<thelema> now how can I document this clearly?
amaw has quit [Ping timeout: 240 seconds]
lamawithonel has joined #ocaml
yezariaely has left #ocaml []
ttamttam has left #ocaml []
<gildor> mfp: ping
<gildor> mfp: how do I add parametrized filter to sqlexpr
<mfp> what do you mean?
<gildor> e.g. I have a "SELECT * FROM log" and would like to generate "SELECT * FROM log WHERE pkg = %s"
<gildor> but the where part is defined at runtime
<gildor> because it is parametrized by user settings
<mfp> the 'pkg' column itself?
<gildor> (e.g. SELECT * FROM log WHERE pkg = 'foo' OR pkg ='bar'
<gildor> )
<gildor> is it possible to "append" the conditions ?
<mfp> do you want to change the column at runtime, or just ensure the value belongs to some set?
philtor has quit [Ping timeout: 240 seconds]
<mfp> gildor: i.e. is the general pattern you're after (not valid ->) select * from log where %s = %s or select * from log where %s in %(SET)
<mfp> sorry, I meant select * from log where somecol in %(set) for the latter
joewilliams_away is now known as joewilliams
<mfp> if it's the former, you have to generate a SQL string and unsafe_execute it
<mfp> if it's the latter, the trick is to attach a DB in mem, then create a table inside that will hold the values of the set,
<mfp> and rewrite the query as select * from log where somecol in (SELECT v FROM db.temp_tbl);
<mfp> this needs to be done inside a Lwt_mutex: you add the values to memdb.temp_tbl, then run the above, then delete * from memdb.temp_tbl; also, if you're using Sqlexpr_sqlite_lwt, you have to use borrow_worker (so that the stmt that inserts into the in-mem table and the rest are executed in the same thread, i.e. against the same sqlite3 handle)
<mfp> gildor: does that help?
<gildor> mfp: yes and no
<gildor> mfp: I don't like to trick sqlexpr
<gildor> I will probably go for the SET thing
<mfp> which case are you referring to, the unsafe_execute part, or the way to "bind an array parameter" for "where X IN ..." ?
<gildor> the unsafe_execute
<thelema> mfp: many ORMs have the ability to add WHERE clauses to a query: http://search.cpan.org/~abraxxa/DBIx-Class-0.08127/lib/DBIx/Class/ResultSet.pm#search
<thelema> I think gildor wants something like this
<mfp> thelema: I know, but do they guarantee they are valid at compile-time or early runtime?
<gildor> mfp: I am not criticizing sqlexpr, just try to find a good solution
<thelema> that one, early runtime.
<mfp> early runtime, how?
<thelema> because there's a schema object representing the database structure
myu2 has joined #ocaml
<mfp> that'll do yes --- that resembles the stuff I did with relational in the past (except it was fully compile-time with lots of type trickery)
<thelema> :) I don't think I'd like to see ocaml types representing a whole database
<mfp> I found in practice that the lesser expressive power was a greater loss than the ability to compose queries
<thelema> even a single table (name * type) set would be ugly to encode as a type, I think
<mfp> the type magic sure was ugly :-|
<gildor> mfp: for now, I'll filter the query using OCaml (i.e. retrieve everything from the DB)
<gildor> mfp: but if you can think of a way to add conditions to sqlexpr >= 0.5.0, it would be great
<mfp> sqlexpr suffers from the same pb as PG'OCaml regarding queries built at runtime --- you end up having to build SQL strings by hand
<mfp> in order to avoid them, you'd have to go the traditional ORM route (which neither PG'OCaml nor Sqlexpr are --- they just return tuples)
<mfp> which means it'd be a completely orthogonal system
<gildor> mfp: but WHERE clause don't change type of the return, adding a ORDER BY, OFFSET, LIMIT or WHERE should be ok ?
<mfp> hmm maybe some restricted run-time SQL building would do
<mfp> ideally, you'd want to have the expression given to order by and there WHERE predicate checked statically too
* mfp thinking out loud
<gildor> the ideal function would be : let query = sql"SELECT * FROM log"
<flux> some macro system could help pgocaml
<flux> you could build queries from fragments, which still would be checked at compile time
<flux> (of course, you couldn't build just any dynamic expression)
<gildor> and let query' = add_where query sql"pkg = %s" mypackage
<mfp> this could do -> select sql"SELECT ... FROM xxx WHERE %(foo = %s)" -> becomes string option -> ...
<thelema> the fragments would have to be associated with a particular query, so it knows what column names are allowed
<flux> thelema, no, i was thinking only the end result would be evaluated
<mfp> if you give it None, the predicate becomes 'true'
<mfp> if Some s, it behaves as WHERE foo = s
<thelema> flux: but for it to typecheck early...
<mfp> this way all the predicates can be checked easily
<flux> so things like LET A = "SELECT" let q = PGOCaml.exec (EXPR A ^ " * from bar") would work
<flux> it would only check the version that is finally passed to pgocaml
<thelema> flux: that would be runtime checking, the database can do that without any PGOCaml
<flux> thelema, my intention was that that would be compile time checked
<flux> thelema, as the string that is passed to the db would be constructed at compile time
<mfp> flux: I'm trying to keep everything as compile-time as possible. You'd need lots of type/camlp4 magic to ensure the fragments are combined into a meaningful SQL query.
<flux> mfp, the thing is I don't mind that the fragments are invalid sql query. only the end result matters.
<thelema> flux: except the end result might depend on runtime values
<flux> thelema, obviously macros have their limitations
<mfp> flux: I mean, if you're to check at compile time the result...
<flux> I'm proposing almost exactly the same as what would happen if you used the preprocessor and used #define PARTIAL_QUERY "SELECT a, b, c"
<thelema> flux: It seems to me that the original request was for sql queries that depend on runtime values
<flux> with such queries it is relatively easy to write multiple paths of code that create the whole query in subtly different ways
<mfp> flux: what happens when you have PGOCaml.exec (EXPR OtherModule.foo ^^^ " * from bar") ...
<flux> such as: match condition with None -> P.exec (PARTIAL_QUERY) | condition -> P.exec (PARTIAL_QUERY "where a=$condition")
<thelema> and to inspect all possible codepaths in camlp4 and verify that the resulting string is correct? I don't think so...
<flux> mfp, obviously it cannot work
<flux> mfp, fortunately I dare to claim most often db interaction is limited to one module, that handles all db interaction
<flux> thelema, finally PGOcaml sees PGOCaml.exec ("string") as usual, and that it can check at compile time
<flux> no matter how many such strings appear :)
<thelema> flux: I don't think compile-time macros will solve gildor's problem
<flux> I think it would. #define LOG_QUERY "SELECT * FROM log" let basic_query = PGOCaml.exec LOG_QUERY let advanced_query pkg = PGOCaml.exec (LOG_QUERY " WHERE pkg=$pkg")
<mfp> gildor: would something like this seem reasonable/usable to you? let get_xxx = select sqlc"select ... from xxx where %(x < %d) AND %(foo = %s) %(LIMIT %L)" is : int option -> string option -> Int64.t option -> xxx list
amaw has joined #ocaml
<thelema> I guess the program could be structured in that way, and it would work for the desired effect. I can't see it being so friendly
<mfp> None being bound to a %(...) subexpression means the predicate becomes true
<gildor> mfp: it can solve part of the problem
<flux> mfp, I don't think that's a global solution
<flux> mfp, sometimes you might have an OR query and then you want false instead
<gildor> mfp: I talked with a guy that consider we should limit the number of queries/per page
<gildor> mfp: the solution you propose, help to limit a bit the number of queries per page, but ideally we should be able to move the whole filter to the SQL query
<gildor> (this is an ideal solution, and we are just talking, I know that everything is not possible)
ftrvxmtrx has quit [Quit: Leaving]
_andre has quit [Read error: Connection reset by peer]
myu2 has quit [Remote host closed the connection]
_andre has joined #ocaml
<flux> mfp, or how about NULL, which could be handles by the query with COALESCE :)
<gildor> (but the " WHERE " should be composable)
<thelema> gildor: I'd accumulate the where clauses as a list and attach them to the query only at execute time, otherwise you can't easily add two where's
<gildor> thelema: well in fact you should also be able to compose OR and AND
<gildor> (composing the function with assert)
<thelema> okay, then not a list, a list of lists (to represent CNF or DNF, your choice)
<gildor> thelema: indeed
myu2 has joined #ocaml
<thelema> probably DNF, as and clauses are probably more common
<thelema> although generating the desired query might get complex with just [when_and] and [when_or] functions
ccasin has joined #ocaml
avsm has joined #ocaml
kaustuv has left #ocaml []
philtor has joined #ocaml
sepp2k has joined #ocaml
myu2_ has joined #ocaml
myu2 has quit [Ping timeout: 260 seconds]
joewilliams is now known as joewilliams_away
joewilliams_away is now known as joewilliams
lopex has quit []
lopex has joined #ocaml
ulfdoz has joined #ocaml
ttamttam has joined #ocaml
sepp2k has quit [Quit: Leaving.]
ttamttam has left #ocaml []
Yoric has quit [Quit: Yoric]
Snark has joined #ocaml
avsm has quit [Quit: Leaving.]
elehack has joined #ocaml
<elehack> Is there a way to tell GODI to do builds in some other directory (e.g. under /tmp) rather than in the work/ directory in the package's build directory?
<elehack> nvm, figured it out - the BUILD_DIR variable.
_andre has quit [Quit: leaving]
Yoric has joined #ocaml
boscop has quit [Ping timeout: 240 seconds]
boscop has joined #ocaml
arubin has joined #ocaml
avsm has joined #ocaml
mnabil has quit [Ping timeout: 245 seconds]
enthymeme has joined #ocaml
avsm has quit [Quit: Leaving.]
yezariaely1 has joined #ocaml
yezariaely1 has left #ocaml []
amaw has quit [Ping timeout: 240 seconds]
yezariaely1 has joined #ocaml
Snark has quit [Quit: Ex-Chat]
yezariaely1 has quit [Ping timeout: 246 seconds]
yezariaely1 has joined #ocaml
ulfdoz has quit [Ping timeout: 265 seconds]
ymasory_ has joined #ocaml
amaw has joined #ocaml
amaw is now known as tony_
yezariaely1 has quit [Ping timeout: 240 seconds]
tony_ is now known as amaw
robthebob has joined #ocaml
robthebob has quit [Client Quit]
mnabil has joined #ocaml
philtor has quit [Ping timeout: 245 seconds]
philtor has joined #ocaml
ccasin has quit [Quit: Leaving]
edwin has quit [Remote host closed the connection]
enthymeme has quit [Quit: errands]
cyanure has quit [Remote host closed the connection]
robthebob has joined #ocaml
Associat0r has joined #ocaml
Edward has joined #ocaml
mnabil has quit [Ping timeout: 255 seconds]
ftrvxmtrx has joined #ocaml
Associat0r has quit [Quit: Associat0r]
willb1 has quit [Ping timeout: 240 seconds]
drunK has joined #ocaml
willb1 has joined #ocaml
Yoric has quit [Quit: Yoric]
boscop has quit [Ping timeout: 240 seconds]
elehack has quit [Quit: Headed out, possibly to home]
drunK has quit [Remote host closed the connection]
eelte has joined #ocaml
coucou747 has quit [Ping timeout: 246 seconds]
ikaros has quit [Quit: Leave the magic to Houdini]
robthebob has quit [Quit: Leaving]
amaw is now known as tauntaun
arubin has quit []
ymasory_ has quit [Read error: Operation timed out]
diml has quit [Read error: Operation timed out]
diml has joined #ocaml
rien has joined #ocaml