[Haskell-cafe] ANN: Patterns 0.0.3
Hi! I am pleased to announce patterns-0.0.3. On Hackage: http://hackage.haskell.org/package/patterns The Patterns package implements communication patterns that are often used in distributed, message-oriented applications. The package implements a set of basic patterns and a device to connect basic patterns through routers, brokers, load balancers, etc. The package is based on the zeromq library, but abstracts from the notion of sockets, on which zeromq is built. Cheers Tobias ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell and Databases
Thanks Greg, both references are very interesting. If I understand correctly, the DSH approach is to convert Haskell programs into SQL and run them inside the database. This seems a good solution when the program objective is to change data in the database according to some business logic or to preprocess relational data to create a non-relational temporary resultset which is later used by an external procedure. The persistent way, from this perspective, appears to be more conventional - data are obtained from the database to be processed by an external program and presented on a website, for instance. Similar to Takusen, the main objective here appears to be compile-time guarantees on database types. Indeed, in a functional program, the string-based embedded SQL is the weakest link in the chain. persistent strengthens this link. On 07/01/2011 08:37 PM, Greg Weber wrote: Hi Tobias, Have you seen DSH [1]? You might also be interested in Persistent [2], but it sounds like it has different goals than what you are after. [1] http://hackage.haskell.org/package/DSH [2] http://www.yesodweb.com/book/persistent ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell and Databases
I am studying Haskell database libraries. In particular I am looking at haskelldb and the Takusen Database.Enumerator library. In haskelldb, there are very good ideas aiming to represent database objects as (typeable) Haskell objects, instead of embedding SQL in plain strings. This is really an interesting approach that overcomes the hiatus between the database there and the processing logic here. Unfortunately, the library cannot deal with some obvious issues related to this concept; conflicts arise, for instance, when Haskell keywords are used as names of attributes or tables or when the same name is used for an attribute and for a table (which is perfectly legal in SQL). Also, haskelldb cannot cope with peculiarities of popular database tables, such as ISAM tables - which are case sensitive. Another, more conceptual issue, is the lack of database cursors. Database programs, usually, do not just issue isolated SQL statements, but implement a processing logic with nested queries and DML statements. A DB library should provide control structures to ease this kind of processing. A library that tackles this issue, is the Takusen Database.Enumerator, again, a library with very strong ideas. Unfortunately, in Takusen there is nothing like the haskelldb DSL. Concerning, cursors, Takusen uses iterators to stream query results. This makes a lot of sense. The iterators, however, cannot be used to implement the nesting of queries. The user has to provide an additional action which is responsible for all the cursor-related logic. The tools provided to deal with cursors resemble very much the instructions found in other database-oriented languages, such as PL/SQL. This leads to verbose code where cursor control is implemented in a quite imperative way. The user, however, should be concerned with getting her queries right, not with the technical details of fetching from cursors. In summary, what I miss is a database library that - integrates haskelldb approach with - a functional-style cursor concept Is anybody working on something like this? Thanks, Tobias ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell and Databases
Sorry for the awful message format in the first try! I am studying Haskell database libraries. In particular I am looking at haskelldb and the Takusen Database.Enumerator library. In haskelldb, there are very good ideas aiming to represent database objects as (typeable) Haskell objects, instead of embedding SQL in plain strings. This is really an interesting approach that overcomes the hiatus between the database there and the processing logic here. Unfortunately, the library cannot deal with some obvious issues related to this concept; conflicts arise, for instance, when Haskell keywords are used as names of attributes or tables or when the same name is used for an attribute and for a table (which is perfectly legal in SQL). Also, haskelldb cannot cope with peculiarities of popular database tables, such as ISAM tables - which are case sensitive. Another, more conceptual issue, is the lack of database cursors. Database programs, usually, do not just issue isolated SQL statements, but implement a processing logic with nested queries and DML statements. A DB library should provide control structures to ease this kind of processing. A library that tackles this issue, is the Takusen Database.Enumerator, again, a library with very strong ideas. Unfortunately, in Takusen there is nothing like the haskelldb DSL. Concerning, cursors, Takusen uses iterators to stream query results. This makes a lot of sense. The iterators, however, cannot be used to implement the nesting of queries. The user has to provide an additional action which is responsible for all the cursor-related logic. The tools provided to deal with cursors resemble very much the instructions found in other database-oriented languages, such as PL/SQL. This leads to verbose code where cursor control is implemented in a quite imperative way. The user, however, should be concerned with getting her queries right, not with the technical details of fetching from cursors. In summary, what I miss is a database library that - integrates haskelldb approach with - a functional-style cursor concept Is anybody working on something like this? Thanks, Tobias ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] warning - Euler problem spoiler enclosed
The problem is lexOrder s@[_] = s where you just give back what you receive, i.e. [Char]. But you claim to give back [[Char]]. Try [s] on the right-hand side. On 05/04/2011 02:41 PM, Barbara Shirtcliff wrote: On May 4, 2011, at 7:21 AM, Ivan Lazar Miljenovic wrote: On 4 May 2011 13:13, Barbara Shirtcliffba...@gmx.com wrote: Hi, In the following solution to problem 24, why is nub ignored? I.e. if you do lexOrder of 0012, you get twice as many permutations as with 012, even though I have used nub. [snip] lexOrder :: [Char] - [[Char]] lexOrder s | length s == 1= [s] | length s == 2= z : [reverse z] | otherwise= concat $ map (\n - h n) [0..((length s) - 1)] where z = sort $ nub s -- why is the nub ignored here? h :: Int - [String] h n = map (z!!n :) $ lexOrder $ filter (\c - lexI c z /= n) z As a guess, I think it's from the usage of length on the right-hand size. Also, note that lexOrder s@[_] = [s] is nicer than lexOrder s | length s == 1 = [s]. I agree that that initial version was a little clumsy, but your suggestion doesn't really seem to work: lexOrder :: [Char] - [[Char]] lexOrder s@[_] = s lexOrder s = concat $ map (\n - h n) [0..((length z) - 1)] where z = sort $ nub s h :: Int - [String] h n = map (z!!n :) $ lexOrder $ filter (\c - lexI c z /= n) z Euler.hs:8:18: Couldn't match expected type `[Char]' with actual type `Char' Expected type: [[Char]] Actual type: [Char] In the expression: s In an equation for `lexOrder': lexOrder s@[_] = s ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] http://www.cs.cornell.edu/icfp/task.htm
Hi Klaus, from your code I cannot tell where exactly you're stuck. A general hint may be to have a look at the parsec library. On 02/25/2011 09:51 AM, Hauschild, Klaus (EXT) wrote: Hi, Currently I'm trying to lern Haskell by doing. After doing some examples I plan to solve an ICFP task (see subject). In short: build an interpreter for a stack based language thata describes a 3D scene. Ray trace this scene in an image. My current source state can be found here: _http://code.google.com/p/hgmltracer/source/browse/_ My first goal is to develop the interpreter of the GML language. My source contains a data GmlToken with various constructors for the different operators, sequences, int, real, string an so on. Some code for the evaluation is also there und working. But the parser converting a string (contained in the program file provided as command line argument) is hard stuff and I'm stuck. Can any one help me with ideas or concepts for this parser? Thanks ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A question about monad laws
Perhaps this might help: I wrote a kind of logger monad that inserted messages with a context. Behind was an algebraic data type, let's say LoggerState. The API provided methods to add a message like this: addError :: String - Logger () addError Fatal error occurred addWarning Some warning etc. There were methods to enter and exit the context: enterContext :: String - Logger () exitContext :: Logger () enterContext System x enterContext SubSystem x.y enterContext Module x.y.z exitContext exitContext exitContext Well, the context was stored in an attribute of LoggerState, let's call it ctx. The add function would pick the current ctx and add it to the message. A message was defined as: ([Context], (State, String)) where State was Ok, Warning, Error. This, however, violates the associativity. In consequence, the context of messages would depend on parentheses, e.g.: someFunction :: Logger () someFunction = do enterContext A addError Some Error callSomeOtherFunction exitContext enterContext B ... produces a different result than: someFunction = enterContext A addError Some Error callSomeOtherFunction exitContext enterContext B ... Imagine: someFunction = enterContext A (addError Some Error callSomeOtherFunction exitContext) enterContext B ... Here, addError and callSomeOtherFunction would operate on a LoggerState without any Context, whereas in the previous example, there is context A. Without the associativity law, it would be very hard to determine the current state of the monad. Since the compiler, on desugaring do-blocks, will insert brackets, there is no guarantee that the results are the same as for the brace-less and sugar-free version of the code. Hope this helps! Tobias On 01/17/2011 04:21 AM, C K Kashyap wrote: Hi, I am trying to get a better understanding of the monad laws - right now, it seems too obvious and pointless. I had similar feelings about identity function when I first saw it but understood its use when I saw it in action. Could someone please help me get a better understanding of the necessity of monads complying with these laws? I think, examples of somethings stop working if the monad does not obey these laws will help me understand it better. Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] getErrorStatus in HXT
Hi Uwe, thanks a lot for the clarification! Indeed, I was a bit confused since all other concepts in HXT are straight forward and easy to grasp. When is the release of hxt-9.1 on hackage expected? On 12/04/2010 05:49 PM, Uwe Schmidt wrote: Hi Tobias, I have some problems with the error processing in HXT. Here is a trivial example: e- runX (transformDoc [] someRules src dst) transformDoc cfg rules src dst = configSysVars cfg readDocument [] src rules -- some transformations writeDocument [] dst getErrStatus I would expect e to contain an error value= c_err for the case where any of the processing steps in transformDoc fails. But it does not, even with an io error on writeDocument. I guess I misunderstand getErrStatus in some way. Any idea? no, you've got it as it should be. This is an error introduced hxt-9.0 when changing the internals of the global hxt state. I've removed that bug in the head of the development version. If there's no time for you to wait until hxt-9.1, the dev. version is available from github at https://github.com/UweSchmidt/hxt;. Sorry for that inconvenience, Uwe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] getErrorStatus in HXT
Hi, I have some problems with the error processing in HXT. Here is a trivial example: e - runX (transformDoc [] someRules src dst) transformDoc cfg rules src dst = configSysVars cfg readDocument [] src rules -- some transformations writeDocument [] dst getErrStatus I would expect e to contain an error value = c_err for the case where any of the processing steps in transformDoc fails. But it does not, even with an io error on writeDocument. I guess I misunderstand getErrStatus in some way. Any idea? Thanks, Tobias ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe