Re: [Haskell-cafe] ANN: Webwire 0.1.0, netwire 1.2.5
I'm also excited to see examples. Even simple ones! Based on my understanding of FRP (which may have little bearing on what webwire actually does, just what I hope it does), what makes it really different is that it is relatively stateless itself - that's kind of the point, that you model your system as a bunch of data sources, and you can change them with pure functions, and when you do that they will be updated anywhere you are using them without any explicit imperative stuff. I'm not sure how that translates to a server-side applications (the only web examples I know of have been javascript-based), or webwire itself so I'm curious to see how this works. On Sep 16, 2011, at 5:24 AM, Ertugrul Soeylemez wrote: Michael Snoyman mich...@snoyman.com wrote: I'm not sure what you mean by runtime-only, could you clarify? The session is inherently bound to its current continuation, and the continuation is a function, i.e. cannot be serialized. This is a generalization, which comes with the price that sessions are lost, as soon as you quit the program. In other words: Applications desiring to save the state need to capture it as something serializable to be able to restore sessions (at least partly) later on. The reason I'm wary of continuation-based frameworks is that (at least from what I've seen) they are purposely non-RESTful. I know REST is a buzzword, but the other way to put it is: you're going to end up working against most of what HTTP is doing. There are good reasons why HTTP is stateless, and that shouldn't be circumvented lightly. Yes, this is indeed a problem with the traditional explicit continuation approach. However, webwire solves this problem mostly, because continuations are implicit and bound to the current resource. You will see the effect of continuations mostly in global or resource-specific stuff like authentication, forms, sessions, etc. In other words: What FRP buys you here is that you can write your applications in a dialog style. Resource URIs need to be managed by the application developer and are not in any way dealt with by webwire. I don't want to go too far on this right now, as I'm not an expert on cont-based frameworks, and I'm certainly not sure how webwire works. But from what I've seen in the past, you end up with ugly URLs and bad caching behavior. I think web developers *should* have to think about the fact that a page request is an inherently stateless operations, and storing state data should be a huge exception[1], not the norm. As noted above, the URI problem is not an issue in webwire. And as for the caching, one really great thing about the FRP approach is that you can actually infer the change rate of a resource to some extent. Greets, Ertugrul -- nightmare = unsafePerformIO (getWrongWife = sex) http://ertes.de/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHCI Feature Request: Last Successful Compilation State Saved
Chris, this is amazing! One question - do you have support for tramping in and running ghci remotely (or would that be easy to add)? I primarily develop inside virtual-machines, so while the source code lives where emacs lives, all the libraries are installed inside the virtual-machine (and the source also lives there, of course). On Aug 30, 2011, at 4:46 AM, Christopher Done wrote: Oh, I didn't reply all. Whoops. On 28 August 2011 13:40, Christopher Done chrisd...@googlemail.com wrote: On 27 August 2011 22:59, aditya siram aditya.si...@gmail.com wrote: I would like for the GHCI interpreter to save its environment before reloading a file and allowed the user to revert back to that state if the compilation was unsuccessful. Many times I've changed files, loaded them, hit a compilation error and needed, for example, the inferred type signature of some function. Even though that function hasn't been changed I have to either fix my code, undo a bunch of changes or comment out the last change I made and reload in order to do a :type on the function. This really breaks the flow of development. This has been bugging me for a long time and it's been on my TODO list for haskell-emacs: https://github.com/chrisdone/haskell-emacs I just implemented it. http://i.imgur.com/A71T5.png I just run two ghci processes, one for compiling, one for merely loading the code in when the former succeeds. It's not a very pleasant hack but in conjunction with :set -fobject-code it is fast and does not consume that much more memory. Considering tibbe's report is 4 years old, I think this solution is better than nothing. Set hs-config-preliminary-load-file to t in hs-config.el and it will do a preliminary load in a separate GHCi process. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHCI Feature Request: Last Successful Compilation State Saved
On Aug 30, 2011, at 1:15 PM, Christopher Done wrote: 1) You put all your source files on the server, too and then run the GHCi process under tramp and access the files via tramp. 2) Sounds like you'd prefer to keep your files local, which, I suppose means you want to send code to the server when you trigger a compile? Could be done, could be done. I'll ponder it. Actually, 1. is what happens, which seems like the easier thing. The folder does exist locally (ie, on the host), but it is shared with the virtualmachine, so it can be edited in either place. The sharing is either done through a a special mechanism provided by the virtualmachine (ie, in virtualbox, shared folders), or with plain old NFS (the latter is faster, for unknown reasons). My normal workflow is to have an editor open that edits the files on the host. Then with a ssh connection to the client (the virtualmachine), I build and/or run ghci through that. I'm not sure if this is how other people do work with virtualmachines, but I would imagine it was relatively common. I'd be pretty excited about that working. As an added benefit, the same strategy could be used to jump into a project on an actually remote host. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHCI Feature Request: Last Successful Compilation State Saved
That doesn't look very promising :( On Aug 27, 2011, at 5:31 PM, Daniel Fischer wrote: On Saturday 27 August 2011, 23:10:17, David Virebayre wrote: 2011/8/27 aditya siram aditya.si...@gmail.com: Hi all, I would like for the GHCI interpreter to save its environment before reloading a file and allowed the user to revert back to that state if the compilation was unsuccessful. That would be awesome. I would like this too. http://hackage.haskell.org/trac/ghc/ticket/1896 ___ 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] Invitation to connect on LinkedIn
lol. I don't know Andrew Smith. How about y'all? On Aug 14, 2011, at 12:32 PM, Andrew Smith B.Sc(Hons),MBA wrote: LinkedIn I'd like to add you to my professional network on LinkedIn. - Andrew Andrew Smith B.Sc(Hons),MBA Founder and CEO at VTRL - Value Technology Research Ltd Edinburgh, United Kingdom Confirm that you know Andrew © 2011, LinkedIn Corporation ___ 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] Haskell syntax highlighting in a public blog
On Aug 8, 2011, at 10:26 PM, Ivan Lazar Miljenovic wrote: On 9 August 2011 12:04, Arlen Cuss cel...@sairyx.org wrote: 9/08/2011 11:54 AM, Oscar Picasso kirjutas: Hi, Is there a public blog that that allow syntax highlighting of Haskell code? Are you talking about a plugin for a blog engine? CodeColourer on WordPress will do it. I think he meant more along the lines of wordpress.com, which as far as I know _doesn't_ support highlighting Haskell. I haven't done this personally, but here is a javascript based solution that should work with any blog that allows you to include custom stylesheets / javascript: http://nix-tips.blogspot.com/2010/09/javascript-highlighter-for-haskell-code.html___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Make Show instance
The documentation for the Show typeclass has this very example: http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#t:Show The summary? you need to define either showPrec or show, the latter of which is simpler, it is just a - String. So: instance Show (Tree Int Int) where show (Tree (Node (k,v)) left right) = ... On Jul 21, 2011, at 10:55 AM, Александр wrote: Hello, thank you for reply. I know that i can derive this. But i want to know how can i make it by hand. Thank you. ___ 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] How to determine minimal dependency of package
Based on the package versioning policy [1], A.B is a major version, so if you know that it works with 1.2, then it is reasonably safe to specify the range = 1.2 1.3, as no major api breaking changes should occur within the 1.2 range (ie, 1.2.1 to 1.2.2, etc) 1. http://www.haskell.org/haskellwiki/Package_versioning_policy#Version_numbers On Jul 15, 2011, at 10:56 AM, Anthony Cowley wrote: On Fri, Jul 15, 2011 at 10:48 AM, yi huang yi.codepla...@gmail.com wrote: I'm writing my first haskell package, how do i determine the minimal dependency of it, for example, it use Data.Data, how do i know which version of base package first introduce Data.Data module, i can't find the answer with google. You should specify the minimum version you have tested with. Anthony ___ 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] Paid work available in functional web programming
I also think it would be really good to have some documentation that explains the type system and how to do neat things with it in terms that a reasonably competent haskell / ML programmer could understand. I played around with Ur/Web about a year ago and was able to make a simple application, and use some C libraries (the C FFI is really easy to use), but realized that I wasn't able to do much of anything beyond mimicking the demos in various ways, mainly because the documentation was so sparse (when I didn't know how to do something, I just tried to do what I would expect it to do if it were haskell, which worked a surprising amount of the time, but wasn't the most enjoyable experience). Looking at, for example, page 19 of the reference manual [1], which is supposed to explain how expressions are typed (which I would assume would give input into how the type system worked), I, probably like Chris, couldn't make much sense of it. Now I don't have a PhD in type theory, or even a masters degree, but if your intended audience includes people like me, the documentation definitely needs work! Now perhaps understanding those tables isn't actually important to using the language, but from looking through the manual / available documentation, there seems to be the really basic cookbook style stuff, that you can copy and paste and modify, as long as you are careful, then the source code itself, from which more can be gleaned, and then this type of type theory. Because of this (or until there is real documentation explaining some of the novel things about this language), I think Ur/Web is going to remain a cool thing that barely anyone can do anything with. Something to be linked in reddit or stack overflow posts, but not actually used! It seems like documentation of the really basic stuff is there, and the really advanced stuff (which is great, don't get me wrong), but the stuff in the middle is missing! Which is too bad, because it seems like it is doing some really exciting things. 1. http://www.impredicative.com/ur/manual.pdf On Jul 13, 2011, at 11:10 AM, Christopher Done wrote: On 13 July 2011 15:28, Adam Chlipala ad...@impredicative.com wrote: I write to mention briefly that I'm looking for people interested in writing Ur/Web programs for pay. Ur/Web is a DSL for building modern web applications, and I believe it is truly a secret weapon for that domain, and one that should appeal to many Haskell fans. I have one customer now for whom I'm leading a project to develop a particular web application, and I'd like to have more. The current project would benefit from more programming help, and I would also like to develop a network of people interested in future projects. More information on Ur/Web can be found here: http://www.impredicative.com/ur/ I would like to see a real application in Ur/Web. There are many simple examples. I don't and wouldn't want to develop like that, writing raw HTML and SQL seems going backwards despite the incredible advances in consistency and correctness that Ur/Web offers. I also find it hard to understand the type system in a non-superficial level because the related paper was very hard to grok. I tried to get it running a while ago and could not get it to compile. I would also like to see how it handles non-web stuff as inevitably IME web applications involve more than merely reading and writing to a database. I like the idea, please keep us posted about it. ___ 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] Call for GUI examples - Functional Reactive Programming
Forgot to cc the list On Jul 8, 2011, at 11:20 AM, Daniel Patterson wrote: On Jul 8, 2011, at 3:51 AM, Heinrich Apfelmus wrote: Jason Dagit wrote: Heinrich Apfelmus wrote: Do you know any *small GUI programs* that you would *like* to see *implemented with Functional Reactive Programming?* I would love to hear your examples, so that I can try to convert them to FRP style and test my library against them! How about a GUI for darcs? This would involve a lot of functionality unrelated to GUIs. Could you break it down to a minimal GUI-only example that still gets the point across? What about something that just showed the list of patches for a given repository, which would update when the repository changed? That is deadly simple, but could still be somewhat useful (ie, have it track a relatively central repo, and running on a screen somewhere in the metaphorical office). It would also be wonderful to start on a GUI for darcs, and I could say it might interest _me_ in taking a stab at improving it :) And it might be an example of the kind of open system that was mentioned earlier Daniel ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Help
so think about the high level design for a second, and let that guide the types. then the types should guide the code. p, which I assume is the top level evaluation, is supposed to take a list of strings, and produce a list of integers (the result of evaluating the expression), right? So it should have type p :: [String] - [Int]. Now the base case is obvious - if you are given an empty list of strings, then you should give back an empty list of results. The recursive case is a little more complicated - the idea with simple recursion is that the recursive case should eventually land you at the base case, which will stop the recursion. With lists, this usually means that each application of the recursive case should call itself on the rest of the list, and somehow process the first element of the list (it doesnt have to be this way, but often is). So in your case, the recursive case should be: evaluate the first element of the list, and then call the whole function on the rest of the list. You can check this mentally by using a couple examples. In the case of a one element list, this means that it will evaluate the first (and only) element of the list, and then call itself on the rest of the list, which is an empty list, which is the bottom case and therefore ends the recursion. On a two element list, this can be checked as well. Now the types should be your best friend. You know that you want: p :: [String] - [Int] That is from the problem statement. So you write the base case first: p [] = [] Now for the recursive case, you know you want to eval the first element, and then call the function on the rest of the list. But since you need to return a list eventually, then you need to return a list in this function. You know that calling the function recursively will result in a list (the type guarantees that), so if you've evaluated the first element of a list, resulting in an Int, and you have a list of Int's that is the rest of the list, how do you combine those? Well, put the element at the beginning of the list! p (x:xs) = (eval p) : (p xs) Now this is a really really common pattern - do the same thing to every element of a list. The first thing in haskell to do if you think that what you are doing might already exist in some generalized form is to try to describe what the function is that you want. So in our case, you want a function that takes another function and applies it to every element in the list. This function would have type: (a - b) - [a] - [b] In your case the (a - b) is String - Int (the function eval), the [a] is [String], [b] is [Int]. Now if you take this and search on Hoogle (a haskell search engine: http://haskell.org/hoogle/?hoogle=%28a+-%3E+b%29+-%3E+%5Ba%5D+-%3E+%5Bb%5D ), the first result is a function called map, which does exactly what you want. So you can actually write your whole p function as: p :: [String] - [Int] p xs = map eval xs Or, if you are okay with partial application, this is equivalent to: p :: [String] - [Int] p = map eval On Jun 25, 2011, at 3:56 PM, Jack Henahan wrote: The error in ghci is Couldn't match expected type `Int' with actual type `[a0]' In the expression: [] In an equation for `p': p [] = [] You've defined p as [String] - Int, but then your base case is p [] = []. [] is not an Int. I changed it to 0 and it'll compile, at least, but I'm not sure if that's the effect you're after. http://hpaste.org/48324 Edited code (really just indentation changes and the change from p [] = [] to p [] = 0) On Jun 25, 2011, at 3:19 PM, Stoyan Peev wrote: First I am using WinHugs. that's the code i made so far but it's still not working: http://hpaste.org/48318 Error: ERROR file:.\kursovazadacha.hs:36 - Type error in explicitly typed binding *** Term : p *** Type : [String] - [a] *** Does not match : [String] - Int I'm still breaking down somewhere ... 2011/6/25 Daniel Patterson lists.hask...@dbp.mm.st: what haskell compiler are you using? And what does the include line do? That does not look like a GHC error message (the only compiler I'm familiar with), but it seems like it is saying that you should not have the extra newlines between the function type signature and declaration. - that's only my guess, based on the assumption that the whitespace is being converted to a syntax with explicit semilcolon line terminations. now, looking at the actual code, the type of the parse function is [a] - [a]. This means that you can parse a list of anything into a list of anything, which doesnt make much sense. This should probably be [String] - [String] (you are parsing a list of strings to a list of strings, yes?). Now the base case of parse (the first case) makes sense, but look at the second case. parse is being given a list of elements (which you have used pattern matching to decompose, but the whole argument, (x:xs
[Haskell-cafe] Fwd: Data.Time
sent from wrong account - message follows: I've found most of the time library to be quite useful, but the parsing to be worthless (I've tried to get someone to prove me wrong already, and would be happy if someone could on this thread!). Specifically, the formatTime function, if it ever strips out padding (by zeros or spaces), results in a time that is unparseable. The fact that formatTime and parseTime are not capable of being inverses of each other seems like a major flaw, when you think that this is not a parseable date: 2011/1/30 (because the month must be padded by zeros). Even though it is very easy to print, and occurs commonly in the world. Because of this, I use formatTime to write my times, and then have a custom parser to parse them back out. Which makes me think that this is a broken library On Jun 27, 2011, at 10:37 AM, bri...@aracnet.com bri...@aracnet.com wrote: On Mon, 27 Jun 2011 11:15:28 +0300 Yitzchak Gale g...@sefer.org wrote: The biggest shortcoming, in my opinion, is that the documentation assumes that the reader is very familiar with the Haskell type system, and with viewing type signatures and instance lists as an integral and central part of the documentation. In particular, Haskell's standard numeric type classes and the conversion functions between them play a central role in the API of Data.Time. But you wouldn't realize that unless you have read the type signatures and instance lists in the Haddocks very carefully, and have thought about it for a while. This is exactly right. Another problem, as Malcolm pointed out, is that because of the sheer size of the library, a quick-start guide for the common cases would be extremely helpful for newcomers. That would be very, very helpful. I had a few working examples things were much better. Finding a starting place, any starting place, proved to be quite elusive. Also the fact that asking for the current time traps you in IO hell, doesn't help, although it's clear that it should be that way. Brian ___ 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] Help
Well, if you are at all familiar with (or wanted to learn about) the Maybe type, I would suggest you use that. A brief synopsis: data Maybe a = Nothing | Just a Which means that a Maybe Int is either Nothing or or Just an int. If you were to got this path, then your p function should have type [String] - [Maybe Int] - which means that either the calculator has a response (Just 22 or Just 6 or Just whatever) or something went wrong (invalid input) and it gave Nothing. So in your case, you'd get: Parsing p [2*34/3,2+3,2*(6 / 2),] [Just 22,Just 5,Just 6,Nothing] Which really clearly demonstrates what you are trying to communicate (and importantly doesn't cause the whole program to stop running when it sees a bad input). Then in the eval function, the error cases would result in Nothing, and the good cases would result in Just n. On Jun 27, 2011, at 12:09 PM, Stoyan Peev wrote: Yeah, that really helped me :)) Finally i got the results i wanted : Main p [2*34/3,2+3,2*(6/2)] [22,5,6] There is only one more question i have about this. I have already written 2 error captures, but they don't really apply to the task i have. Here are my error captures: [(_,out)] - error (неопределено) []- 0 and here is the result Parsing p [2*34/3,2+3,2*(6 / 2),] [22,5,6,0] It's ok for me, but i have to make it, not showing anything if there are blanks. I suggest i had to make some checking in the caller function before calling the eval funcition. Also somehow i have to check the syntax of the string and if it is like =x, the result should be x= previous string Probably i have to user where for the caller function or some if cases :? 2011/6/27 Daniel Patterson lists.hask...@dbp.mm.st: so think about the high level design for a second, and let that guide the types. then the types should guide the code. p, which I assume is the top level evaluation, is supposed to take a list of strings, and produce a list of integers (the result of evaluating the expression), right? So it should have type p :: [String] - [Int]. Now the base case is obvious - if you are given an empty list of strings, then you should give back an empty list of results. The recursive case is a little more complicated - the idea with simple recursion is that the recursive case should eventually land you at the base case, which will stop the recursion. With lists, this usually means that each application of the recursive case should call itself on the rest of the list, and somehow process the first element of the list (it doesnt have to be this way, but often is). So in your case, the recursive case should be: evaluate the first element of the list, and then call the whole function on the rest of the list. You can check this mentally by using a couple examples. In the case of a one element list, this means that it will evaluate the first (and only) element of the list, and then call itself on the rest of the list, which is an empty list, which is the bottom case and therefore ends the recursion. On a two element list, this can be checked as well. Now the types should be your best friend. You know that you want: p :: [String] - [Int] That is from the problem statement. So you write the base case first: p [] = [] Now for the recursive case, you know you want to eval the first element, and then call the function on the rest of the list. But since you need to return a list eventually, then you need to return a list in this function. You know that calling the function recursively will result in a list (the type guarantees that), so if you've evaluated the first element of a list, resulting in an Int, and you have a list of Int's that is the rest of the list, how do you combine those? Well, put the element at the beginning of the list! p (x:xs) = (eval p) : (p xs) Now this is a really really common pattern - do the same thing to every element of a list. The first thing in haskell to do if you think that what you are doing might already exist in some generalized form is to try to describe what the function is that you want. So in our case, you want a function that takes another function and applies it to every element in the list. This function would have type: (a - b) - [a] - [b] In your case the (a - b) is String - Int (the function eval), the [a] is [String], [b] is [Int]. Now if you take this and search on Hoogle (a haskell search engine: http://haskell.org/hoogle/?hoogle=%28a+-%3E+b%29+-%3E+%5Ba%5D+-%3E+%5Bb%5D ), the first result is a function called map, which does exactly what you want. So you can actually write your whole p function as: p :: [String] - [Int] p xs = map eval xs Or, if you are okay with partial application, this is equivalent to: p :: [String] - [Int] p = map eval On Jun 25, 2011, at 3:56
Re: [Haskell-cafe] Help
What have you tried to do in order to make it work for the list, and what error results? What is confusing about the error message? More generally, how could you transform an operation on a single string into one that does the same thing to a list of strings? You've probably talked about higher order functions in your class - would any of the common ones (filter, map, foldr) be helpful here? Would any encapsulate what you are trying to do? If you include these kinds of things, I think you'll find this community to be very helpful; without that (showing what your thought process is, why it isn't working, what seems confusing about what the haskell compiler is telling you, etc), you are not going to get help here. People here are very friendly and willing to help people learn; this is not a place to come to get an assignment finished :) Also, could you put the library you are using (I'm assuming that this is provided by your university) and the code on somewhere like hpaste.org, so that the formatting is not messed up by email, and it is syntax highlighted? On Jun 24, 2011, at 3:57 PM, Stoyan Peev wrote: Hello all, I am experiencing some issues to do my course task in university. I have to write a calculator- function in Haskell. The function argument is a list of strings and also form such list, as each string of the argument made definite action: - If the string has the form of an arithmetic _expression_ - calculate this _expression_. The string result becomes part of the list-result. If the _expression_ contains a variable which is not assigned value, the result is displayed undefined. - If the string has the form- Name = value calculated from the last _expression_ is assigned to the variable with the corresponding name in the list, and in the result list is formed a string with type - If there is not a calculated _expression_ to be assigned to form a string no value. - If the string is non-blank, but there is a species different from the above two case, form the string error. - If the string is empty, incl. when it contains only spaces, in the result there is not form a string. Expressions consist of integers without sign variables, operations + (Addition), - (subtraction), * (multiplication) and / (divide) and parentheses. Where no brackets, the operations are performed from left to right, but * and / precede the + and -. Implementation of any operation gives integer; in the division rejected the fractional part, if any. Variables have names of one letter - from the Latin small letter. In the beginning, end or between the elements of each row can have spaces - they are irrelevant to its correctness. Example: the list-argument [3 +7 / 2 2 + x, = s, 2 * s +4, , 2 + +4 / 5] function should provide a result-list [6, undefined, s = 6, 16, error]. I say another person have the same task, but he didn't do anything. I started doing this task myself but i get stuck in the middle. Then i started searching for something that could help me and find out you :) The code i have written so far uses the library file Parsing.lhs but what i have written is taking those actions that i already described, only for a string. I cannot modify it to work for list of string, and complete the whole task. I'll be glad to finish the task myself, but i am going to need some help. Here is the code i have already written: import Parsing expr :: Parser Int expr = do t - term do symbol + e - expr return (t+e) +++ do symbol - e - expr return (t-e) +++ return t term :: Parser Int term = do f - factor do symbol * t - term return (f * t) +++ do symbol / t - term return (f-t) +++ return f factor:: Parser Int factor= do symbol ( e - expr symbol ) return e +++ natural eval :: String - Int eval xs = case (parse expr xs) of [(n,[])] - n [(_,out)] - error (undefined) []- error error Thanks all in advance :) -- Best Wishes Stoyan Peev
Re: [Haskell-cafe] Help
what haskell compiler are you using? And what does the include line do? That does not look like a GHC error message (the only compiler I'm familiar with), but it seems like it is saying that you should not have the extra newlines between the function type signature and declaration. - that's only my guess, based on the assumption that the whitespace is being converted to a syntax with explicit semilcolon line terminations. now, looking at the actual code, the type of the parse function is [a] - [a]. This means that you can parse a list of anything into a list of anything, which doesnt make much sense. This should probably be [String] - [String] (you are parsing a list of strings to a list of strings, yes?). Now the base case of parse (the first case) makes sense, but look at the second case. parse is being given a list of elements (which you have used pattern matching to decompose, but the whole argument, (x:xs), is a list of elements). You are then passing that, unchanged, to eval. This means that eval must take the same type. Does it? how would you apply eval to each element in that list, instead of just applying it to the whole list? On Jun 24, 2011, at 4:31 PM, Stoyan Peev wrote: I found the library myself, and i already put the code in that site: http://hpaste.org/48277 That's what i have tried to do for making the task by calling the one string function by another one: include kursovazadacha parse :: [a] - [a] parse [] = [] parse (x:xs) = eval (x:xs) The error from the compiler: ERROR file:.\list.hs:3 - Syntax error in declaration (unexpected `;', possibly due to bad layout) On Fri, Jun 24, 2011 at 11:20 PM, Daniel Patterson lists.hask...@dbp.mm.st wrote: What have you tried to do in order to make it work for the list, and what error results? What is confusing about the error message? More generally, how could you transform an operation on a single string into one that does the same thing to a list of strings? You've probably talked about higher order functions in your class - would any of the common ones (filter, map, foldr) be helpful here? Would any encapsulate what you are trying to do? If you include these kinds of things, I think you'll find this community to be very helpful; without that (showing what your thought process is, why it isn't working, what seems confusing about what the haskell compiler is telling you, etc), you are not going to get help here. People here are very friendly and willing to help people learn; this is not a place to come to get an assignment finished :) Also, could you put the library you are using (I'm assuming that this is provided by your university) and the code on somewhere like hpaste.org, so that the formatting is not messed up by email, and it is syntax highlighted? On Jun 24, 2011, at 3:57 PM, Stoyan Peev wrote: Hello all, I am experiencing some issues to do my course task in university. I have to write a calculator- function in Haskell. The function argument is a list of strings and also form such list, as each string of the argument made definite action: - If the string has the form of an arithmetic _expression_ - calculate this _expression_. The string result becomes part of the list-result. If the _expression_ contains a variable which is not assigned value, the result is displayed undefined. - If the string has the form- Name = value calculated from the last _expression_ is assigned to the variable with the corresponding name in the list, and in the result list is formed a string with type - If there is not a calculated _expression_ to be assigned to form a string no value. - If the string is non-blank, but there is a species different from the above two case, form the string error. - If the string is empty, incl. when it contains only spaces, in the result there is not form a string. Expressions consist of integers without sign variables, operations + (Addition), - (subtraction), * (multiplication) and / (divide) and parentheses. Where no brackets, the operations are performed from left to right, but * and / precede the + and -. Implementation of any operation gives integer; in the division rejected the fractional part, if any. Variables have names of one letter - from the Latin small letter. In the beginning, end or between the elements of each row can have spaces - they are irrelevant to its correctness. Example: the list-argument [3 +7 / 2 2 + x, = s, 2 * s +4, , 2 + +4 / 5] function should provide a result-list [6, undefined, s = 6, 16, error]. I say another person have the same task, but he didn't do anything. I started doing this task myself but i get stuck in the middle. Then i started searching for something that could help me and find out you :) The code i have written so far uses the library file Parsing.lhs but what i have written is taking those actions that i already described, only for a string
Re: [Haskell-cafe] toSql and fromSql, for Algebraic Data Type
(forgot to CC the list) On Jun 24, 2011, at 8:27 PM, Daniel Patterson wrote: It looks, from looking at the provided instances (not from having done it myself), that you need to define safeConvert functions to and from your value. Here is a partial list of conversions to and from String. instance Convertible String SqlValue where safeConvert = return . SqlString instance Convertible SqlValue String where safeConvert (SqlString x) = return x safeConvert (SqlByteString x) = return . BUTF8.toString $ x safeConvert (SqlInt32 x) = return . show $ x safeConvert (SqlInt64 x) = return . show $ x safeConvert (SqlWord32 x) = return . show $ x safeConvert (SqlWord64 x) = return . show $ x safeConvert (SqlInteger x) = return . show $ x safeConvert (SqlChar x) = return [x] safeConvert (SqlBool x) = return . show $ x safeConvert (SqlDouble x) = return . show $ x safeConvert (SqlRational x) = return . show $ x On Jun 24, 2011, at 8:02 PM, Tom Murphy wrote: Hi *, The title is self-explanatory. I'd like to store information from an algebraic data type in an SQL database, but the type signature of toSql (toSql :: Data.Convertible.Base.Convertible a SqlValue = a - SqlValue) doesn't make sense to me. How is this done (how do I make an instance of a typeclass like that?) Thanks for your time, Tom ___ 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] Simple CSV parser?
Do any of the ones on hackage work for you? http://hackage.haskell.org/package/csv-0.1.2 http://hackage.haskell.org/package/bytestring-csv http://hackage.haskell.org/package/csv-enumerator (note: hackage supports search via google it works reasonably well) On Jun 16, 2011, at 5:21 PM, Dmitri O.Kondratiev wrote: Hi, This time I am looking for a simple CSV parser that supports commas and quotes. I have no time now to learn Parsec, so I hope to find something simple and easy to use. 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] Simple CSV parser?
That was my (lazy) fault. I saw the name and (faultily) assumed that it provided functionality on top of another CSV parser. On Jun 16, 2011, at 5:33 PM, Henning Thielemann wrote: On Thu, 16 Jun 2011, Daniel Patterson wrote: Do any of the ones on hackage work for you? http://hackage.haskell.org/package/csv-0.1.2 http://hackage.haskell.org/package/bytestring-csv http://hackage.haskell.org/package/csv-enumerator (note: hackage supports search via google it works reasonably well) How could it miss my lovely package named spreadsheet? It provides a lazy parser. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Please help : Data.Time.Format parseTime
As a more general response, be careful with parsing dates, because as far as I can tell, it is easy to print times (with formatTime) that cannot be parsed (with parseTime). Specifically, if you strip the padding (of zeros or spaces) there is no way to parse it back in. So parseTime . formatTime is not an identity for anything that cuts out padding. (it results in Nothing for those cases). Perhaps this is because too much data is lost (doesn't seem like this would necessarily be the case), but it does seems like an outstanding problem with parseTime. If I'm wrong, and, for example, a non-zero padded month (which occurs quite frequently in the world), which can easily be printed with %-m, can be parsed in without pre-parsing and inserting zeros as appropriate first, I would be happy to hear how! On Jun 14, 2011, at 5:32 PM, Dmitri O.Kondratiev wrote: Magnifique, ca marche! Grand merci, Vincent! On Wed, Jun 15, 2011 at 1:16 AM, Vincent Gerard vinc...@xenbox.fr wrote: Hello Dmitri, It seems that your format pattern does not match exactly the format of the input, thus the parser returns Nothing. Try the following format string which seems to work with your date: parseTime defaultTimeLocale %m/%d/%Y %l:%M:%S %p ds :: Maybe UTCTime returns : Just 2009-10-11 19:04:28 UTC The parsings errors in your format could come from . %D expects a 2 char year . %H expects a 0 padded hour (like 07, not 7) Regards, Vincent Gerard On Wed, 15 Jun 2011 00:33:56 +0400 Dmitri O.Kondratiev doko...@gmail.com wrote: I am trying to convert data string to time: import Data.Time import Data.Time.Format import Locale ds = 10/11/2009 7:04:28 PM t = parseTime defaultTimeLocale %D %H:%M:%S %p ds :: Maybe UTCTime and get Nothing. What is wrong? Thanks ! Dmitri. ___ 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] Simple string tokenizer?
Would this work? http://hackage.haskell.org/packages/archive/split/0.1.4/doc/html/Data-List-Split.html On Jun 15, 2011, at 12:21 PM, Dmitri O.Kondratiev wrote: Sorry if this question was asked billions of times already, but I can not find a simple string tokenizer. All I need is to split a line in chunks at specified delimiter such as (,), nothing more. Don't want to write it myself for two reasons: 1) have to write lots of other code in very short time 2) don't want undermine idea of code reuse ) Where to get latest Data.String.Utils library that I saw somewhere on the web and that has a nice and simple 'split' function? 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] Class and Instance
The problem is that [] alone is not a concrete type - that is what the error is saying, that [] needs to be applied to another type to yield a concrete type. IE, you need a list of something, not just the idea of a list. That something can be polymorphic, so the following works (note the [a]): class Containers x y where insert :: y - x y - x y {-remove :: y - x y - x y whatsIn :: x y - [y]-} instance Containers [] [a] where insert x y = x:y On Jun 11, 2011, at 5:49 AM, Patrick Browne wrote: Thanks for the feedback. I have two further questions 1. Why is it that the Containers class signature does not allow instances to be list of list? I suspect it is because x is a constructor. 2. How would I change the Containers class signature to allow instances to be lists of lists. Thanks, Pat -- x is a type constructor, not a type class Containers x y where insert :: y - x y - x y remove :: y - x y - x y whatsIn :: x y - [y] instance Containers [] Char where insert y [] = y:[] insert y m = y:m remove _ [] = [] remove x (y:ys) | x == y= remove x ys | otherwise = y : remove x ys whatsIn = id instance Containers [] Integer where insert y [] = y:[] insert y m = y:m remove _ [] = [] remove x (y:ys) | x == y= remove x ys | otherwise = y : remove x ys whatsIn = id -- cannot have containers of containers. -- instance Containers [] [] where -- container.hs:41:23: --`[]' is not applied to enough type arguments -- Expected kind `*', but `[]' has kind `* - *' -- In the instance declaration for `Containers [] []' -- Failed, modules loaded: none. This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie ___ 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] Input and output of mathematical expressions
(I originally sent this reply from the wrong address, see below) On Jun 9, 2011, at 11:03 AM, Daniel Patterson wrote: Also if you are doing this for web, I haven't used it personally (yet), but http://www.mathjax.org/ looks really good... would allow you to actually just write it in LaTeX (as writing MathML by hand is not something I'd like to subject anyone to). On Jun 9, 2011, at 10:59 AM, Chris Smith wrote: Ae you looking to do this in a web application, or client-side? Since one of your requirements is to display a typeset equation, that makes a bit of difference. In a web-based setting, the best way to do that is probably MathML, whereas a GUI will be a bit harder. On Jun 9, 2011 8:24 AM, Jacek Generowicz jacek.generow...@cern.ch wrote: Greetings Cafe, What would you recommend as a Haskell-based means of interactively reading and writing mathematical formulae? As a toy example, what might I use to write a program which presents the user with Please simplify the expression: \pi x^2 + 3\pi x^2 (Where the TeX-style expression would be presented with a greek pi and superscript twos on the xs.) The user should then have the ability to reply with something that looks like the result of TeXing 5 \pi x^2 Whatever means the user uses to enter this expression, he should be able to preview the typeset version of his input before submitting. Any ideas? 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 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] *GROUP HUG*
On May 24, 2011, at 4:46 AM, Ketil Malde wrote: Replying with a pointer to 'catMaybes' resulted in (most likely) the author going off to finish/improve his program, and some more interesting discussion on alternative ways to do this. What's more, the thread added many other possible implementations, and a discussion why using filter ((/=) Nothing) is a bad thing (even though it seems like a nice and simple check) because it adds an additional Eq constraint an whatever is inside the Maybe. I think THAT, ie, not only accepting and giving useful answers to simple questions, but even expanding upon them and using them as learning tools for more advanced topics, is what makes the haskell community such a fun place to be. Because while I, a medium level haskell noobie, already knew about the catMaybes function and could have built the filters or searched on Hoogle for it, I had not thought about the advantages to using isNothing instead of (== Nothing), or that there was any difference at all.___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] The Lisp Curse
Correct my ignorance as I'm rather new around here, but I'm not sure if I actually think this happens that much. Different approaches are often put forth, which does mean that there are incompatible libraries that fill the same space for a while, but it seems that once it becomes clear what the best approach is, that becomes pretty well accepted. Are there really example of multiple libraries that use the same approach to solve the same problem that are incompatible and actively used? Right now there are a bunch of iteratee/enumerator/whatever term you want to call it libraries, but those are new ideas, and it isn't clear yet what the best approach is. In an open source community, there will always be multiple approaches to common problems. If as soon as one person came up with a solution, all others had to build upon that, there would be no progress, as no one would be able to try out new ideas. What is important is that there is visibility for packages so that people can see what else is out there and can decide if it makes the most sense to: A. use an existing solution B. improve an existing solution C. start from scratch, because of wanting a fundamentally different approach. I think hackage provides that. So what's the problem? Short history, for example, why do we have to have N libraries to read a file? can't we have just one damn good one? The only way to get there is to have many solutions and then decide what the best one is! Just my .02 On May 19, 2011, at 2:56 PM, Gilberto Garcia wrote: I think what Andrew meant is that it's not a good idea to have big pile of different implementations of the same library, and all trying to solve the very same problem. I see this kind of problem in the java community. It seems that developers have a need to create everything from scratch more than making existing ones better. Cheers ___ 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] Server hosting
I've had good experiences with prgmr VPSes; I currently have a 1024MB VPS that I'm paying $16 a month for (the month by month rate is $20, but I'm paying for it yearly). You can also grab a 256MB VPS for $8 month by month or $6.40 yearly, if that'd be enough. In the last year I think there was one significant outage that lasted several hours - it was due to a problem of the data center where the servers were located, and they were good about communicating why that happened, and discounted the hosting as a result. I don't think they are going to be as fast (disk access wise) as Linode (based on benchmarks I've seen, not personal experience), but are much cheaper for the same amount of RAM. At least when I was first doing haskell webdev, the amount of ram required for linking apps built with happstack was astounding, such that on my 256MB slicehost VPS, every recompile meant 20 minutes of swapping, and a completely inaccessible server. So while I didn't need the speed of a larger VPS, I did need the RAM. Since then, Linode has bumped up to 512MB ram, so the difference isn't as sharp as it used to be, but I've also had no problems with performance (I don't have any high traffic sites). Anyhow, just my experience having used them for the past year and a half. More info at prgmr.com On May 6, 2011, at 2:07 PM, Andrew Coppin wrote: OK, so strictly this is unrelated to Haskell as such. However, there's enough people doing webby stuff with Haskell that some of you must have wanted to run your code on a real, Internet-accessible web server. So does anybody have any suggestions on which companies offer the most favourable tools / pricing? I currently have a website, but it supports only CGI *scripts* (i.e., Perl or PHP). It does not support arbitrary CGI *binaries*, which is what I'd want for Haskell. In fact, I don't have control over the web server at all; I just put content on there. The same provider can offer me a virtual server, but at 3x the price I'm currently paying. I simply cannot afford that kind of money just for silly toy projects. What does everybody else use? ___ 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] test driving cabal install... cabal install and normal install (runghc Setup) don't mix... two package.conf files...
I think you need to install HAppS-Data etc globally... I'm not sure why locally installed (ie, only your user) packages wouldn't be picked up by runghc Setup.hs'ing, but if they are install system wide it should definitely work. I think it is cabal --global install foo On Thu, 29 May 2008 18:11:04 -0700 Thomas Hartman [EMAIL PROTECTED] wrote: After a little drama with zlib, I managed to get cabal-install installed. I then attempted to do cabal install HAppS-Server since this is a module with a lot of dependencies, and in rapid development flux, so perenially painful for me to install. The result is that I managed to install everything up to HAppS-State, which I think is the last dependency, but then seemed to hang indefinitely in the middle of installing HAppS-Server at the end. OK, I thought, then perhaps I can do normal runghc Setup.hs after downloading and unzipping the tar from http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HAppS-Server-0.9.2.1 However, this resulted in error [EMAIL PROTECTED]:~/haskellInstalls/smallInstalls/HAppS-Server-0.9.2.1runghc Setup.hs configure ... Setup.hs: At least the following dependencies are missing: HAppS-Data =0.9.2... Strange, because I had just installed that module via cabal-install, and I could load it in ghci with :m +HappS.Data. I then ran ghc-pkg and got this strange result that my packages were broken into two different files. Is this by design? ghc-pkg list /usr/local/lib/ghc-6.8.2/package.conf: Cabal-1.2.3.0, Cabal-1.3.11, Cabal-1.5.2, DeepArrow-0.2, /home/thartman/.ghc/i386-linux-6.8.2/package.conf: HAppS-Data-0.9.2.1, HAppS-IxSet-0.9.2.1, HAppS-State-0.9.2.1, I am curious if anybody else is able to install HAppS-Server using cabal install, and whether they can shed any light on the other isuses I raised. Thomas. ___ 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
[Haskell-cafe] ANN: HSmugMug 0.1 - a haskell wrapper to the photo site smugmug's api
Released May 27th, 2008. I've been working for a little while on a haskell wrapper to the photo hosting site Smugmug's api. As of now, the library is pretty simple - it is 'read-only' - ie, you can't use it to upload to or create galleries, but I still think it is potentially useful to haskell/smugmug users. I created it primarily so I could integrate my photos at smugmug into my website, which you can see in the 'photos' section of my website - a very primitive but proof of concept-esque demonstration. I have deliberately not included much glue between the actual api and the use of it, because I think that is something that can more cleanly evolve out of use - if people find themselves repeating certain patterns when using the api, those would logically become part of the api wrapper. So, let me know what you think! Full release notes, brief tutorial, install instructions, etc, at http://dbpatterson.com/articles/10 . Feedback welcome! (this is the first thing longer than a 5 liner that I've written in haskell, so be gentle) Daniel ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe