Re: [Haskell-cafe] Database written in Haskell?
HAppS' IxSet library gives relational operations but does not have a SQL interface. Am thinking of changing the name to RelSet to make the functionality clear. You can use HAppS.State to give ACID properties to operations on this data structure. -Alex- On 8/1/09 12:15 AM, Günther Schmidt wrote: Hi, is there an SQL database written in Haskell like HSQLDB which is written in Java? Günther ___ 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] Haskell Job Opportunity
HAppS LLC has part-time and full-time positions open for haskell programmers to: * improve the open source haskell codebase at HAppS.org * implement infrastructure to make it work well in Amazon S3/EC2 environments * make http://pass.net reliable enough to be used by live apps * build the mass market apps we want to run on top of the HAppS/Pass.net platform We are looking for people who: * have substantial experience programming Haskell * have experience building Internet apps (not necessarily in Haskell but would be good), and * live in any of these places: * the Internet (with comfort working entirely over email,skype,tightVNC etc.) * New York * San Francisco * Los Angeles If you qualify and are interested, please send an email with your cv/resume to me or to opportunity AT happs.org. -Alex- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: [web-devel] A light-weight web framework
DrIFT is a preproxessor so it makes the build process more complex. I'd like to find a pure-haskell solution or a TH solution that doesn't require more build complexity. -Alex- On Tue, 10 Apr 2007, Marc Weber wrote: Right now, you can largely do the same thing, but you have to write the XML representations of your data structures manually. -Alex- I'm not sure but doesn't use HAppS kind of stripped down HaXml ? DrIft can derive HaXml instances automatically. Where is the problem doing using DrIft? Marc ___ 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] Re: [web-devel] A light-weight web framework
That is why I prefer JSON and XSLT as template languages. The client side developer can't use them to do business logic and they are both idiomatically closer to the world in which the client side developer lives. Once we get the auto-conversion to XML/JSON working in HAppS, life gets really simple. The server app functions produce haskell datastructures. The framework auto-converts them into XML with a an XSLT PI or JSON with a script source. Then the clientside devloper gets to manipulate the data in very standard client languages. Right now, you can largely do the same thing, but you have to write the XML representations of your data structures manually. -Alex- On Thu, 5 Apr 2007, Ricardo Herrmann wrote: The maintenance nightmare happens when someone uses the embedded language to specify business logic, and that's entirely the web-{developer,designer}'s fault. Thus, the problem is not that these languages shouldn't be powerful enough. IMHO, a safe approach would be simply not allowing I/O inside templates (hey, sounds familiar ;-) On 4/5/07, Maurice Codik [EMAIL PROTECTED] wrote: A few things, some of which I sort of mentioned in my previous email: - If I'm already going to commit some time to learn a templating language, why dont I just spend that same amount of time learning the little bit of haskell I need to make the template work? If thats too much to ask, I can just spit out HTML, and have the programmer put in the dynamic parts for me. Both of these scenarios seem to be a more efficient use of time. - Who is the target audience? If its a big organization where there are multiple designers and multiple devs, then your approach may work just fine. If its the single developer, then something like what David suggested would work even better. If its a small team (which may or may not include a full-time designer), then something like what I suggested would work best. For a web framework for haskell, I would guess that the latter two are much more likely. - Embedding a real programming language in a template already gives you power to do what ever you need to do. What if you need to implement some logic that the template language doesnt support? In those cases, you're usually out of luck and have to move that logic into a controller, where it doesnt really belong (assuming its actual display logic, not business logic). - It's really just a matter of taste. Any web framework thats worth using should be flexible in its support of view technologies, but come with one thats a sensible default. Maurice On 4/5/07, Joel Reymont [EMAIL PROTECTED] wrote: Do you see anything wrong with the approach I suggested, though? On Apr 5, 2007, at 6:16 PM, Maurice Codik wrote: That's not necesarily true. Templates where there is mostly markup, but let you embed code into them using special tags (ex, % code % ) are extremely popular and work fairly well. They also keep the template language simple because there is already a full-powered programming language thats embedded into it. Good examples of this method are ERB templates in Rails, JSPs, Perl Mason templates, etc. -- http://wagerlabs.com/ -- http://blog.mauricecodik.com ___ web-devel mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/web-devel -- Ricardo Guimar?es Herrmann Any sufficiently complicated C or Fortran program contains an ad hoc, informally specified, bug-ridden, slow implementation of half of Common Lisp Any sufficiently complicated Lisp or Ruby program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Haskell ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Hs-Generics] FW: [Haskell-cafe] SYB vs HList (again)
Not sure the proposal helps me with my other issues. The appealing thing about hlists is that labels are first class which means obvious ways of parsing URLEncoded Strings and obvious ways to render them in XML. In particular HLists are actually a different type from positional data declarations and that is good. -Alex- On Wed, 21 Mar 2007, Jules Bean wrote: S. Alexander Jacobson wrote: Conceptually, I think what I really want is the data structure equivalent of type inference. Just as I don't want to be forced to declare my function types, I don't want to be forced to declare my data types. The field labels I use should be enough to define the shape of my type. The reason this is really important is that if hlists contain hlists, the type declarations can get really really messy Separately, I would really like hrecords not to have order dependency. It seems strange to me that (Foo .*. Bar .*. HNil) is a different type from (Bar .*. Foo .*. HNil). These particular two issues : type inference based on record 'shape' and records without order dependency, (ignoring the SYB part of the problem for the moment) are both addressed in the following haskell records proposal (and, undoubtedly, others) http://research.microsoft.com/~simonpj/Haskell/records.html Jules ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Hs-Generics] FW: [Haskell-cafe] SYB vs HList (again)
Oleg, data Name = Name String String deriving Show newtype Salary = S Float deriving Show data Dept = D String Int deriving Show I like the idea of these simpler label declarations, but I think the cost is that it is harder to write generic code for e.g. parsing urlencoded data or generating XML. If I understand your concept here correctly, you need to write not only the label declaration but also dedicated code for parsing/generating with each label type. For example, how do you extract a Name above from a urlencoded string? Yes the hlist label declaraions I am using are very verbose, but they are easy to tighten with template haskell (even if I think template haskell is ugly). It would be really nice if there was some way to tell Haskell that HLists have no more fields than the ones you happen to be getting and setting in your code. Effectively that would mean you get data structure inference not just function type inference which would be really cool! I'm not sure I follow. Could you outline an example of the code you wish work? Incidentally, a lot of the library depends on the record types being members of some specific classes. One can define I'd like be able to do something like this: $(label Salary Int) -- template haskell to define salary label main = do person - readFile blah = return . read print $ person # salary In this case, haskell would assume that person has only one label, salary. The read function would ignore all the other labels. If I changed the code to this: $(label Salary Int) -- template haskell to define salary label $(label Name String) main = do person - readFile blah = return . read print $ person # salary print $ show (person::Name .*. Salary) Then the code would assume that a person has both a name and a salary. Conceptually, I think what I really want is the data structure equivalent of type inference. Just as I don't want to be forced to declare my function types, I don't want to be forced to declare my data types. The field labels I use should be enough to define the shape of my type. The reason this is really important is that if hlists contain hlists, the type declarations can get really really messy Separately, I would really like hrecords not to have order dependency. It seems strange to me that (Foo .*. Bar .*. HNil) is a different type from (Bar .*. Foo .*. HNil). If there is no way to get the type system to do this, I think I will probably use template haskell to declare the types of HList records. I assume I can make template haskell always sort the labels before generating the type code. -Alex- On Thu, 15 Mar 2007, [EMAIL PROTECTED] wrote: [Please follow-up to [EMAIL PROTECTED] S. Alexander Jacobson wrote: HLists require you to define Labels and basically only use label values that are themselves either scalar or HLists. ... With SYB you create field labels using newtype (or data) declarations e.g. data Salary = S {salary::Float} With HList, label declarations are really verbose e.g. data SalaryLabel deriving(Typeable) type Salary = Field (Proxy SalaryLabel) Int salary = proxy :: Proxy FooLabel Actually there is no requirement that HList record names must be scalar `labels', must be Proxies and require such a complex declaration. From HList's high point of view, any collection can be a record provided the type of each item is unique and there is some way to extract the value associated with that type. The HList library provides two implementations of Records (and there was one more, obsolete now). There could be more. For example, I have just committed a yet another implementation, http://darcs.haskell.org/HList/src/RecordD.hs Here a record is a list of things that have a type and a value and provide a way to extract that value. The example from the end of this file seems worth quoting: data Name = Name String String deriving Show newtype Salary = S Float deriving Show data Dept = D String Int deriving Show person = (Name Joe Doe) .*. (S 1000) .*. (D CIO 123) .*. emptyRecord -- could be derived automatically, like Typeable... instance Fieldish Name (String,String) where fromField (Name s1 s2) = (s1,s2) instance Fieldish Salary Float where fromField (S n) = n instance Fieldish Dept (String,Int) where fromField (D s n) = (s,n) test1 = show person -- When a field acts as a label, only its type matters, not the contents test2 = person .!. (Name undefined undefined) test3 = person .!. (undefined::Salary) test5 = person .!. (D xxx 111) I don't know exactly how HList handles default values but I assume you can restrict use of those values to explicit deserialization contexts. Is that correct? I'm not sure what you mean about the restriction of default values to deserialization contexts. Anyway, HList provides a left-biased union of two records: hLeftUnion r1 r2 is the record r1
Re: [Haskell-cafe] Haskell and a new web developement mailinglist?
There is currently a happs mailing list. I see no reason not to broaden the subject matter to haskell web development in general. The URL for the list is http://groups.google.com/group/happs -Alex- On Tue, 20 Mar 2007, David House wrote: On 20/03/07, Marc Weber [EMAIL PROTECTED] wrote: I've been talking to Chris Eidhof the last days and we'd like to suggest adding another specialized haskell mailinglist: Haskell and web developement. I'd love to contribute here. You should be able to find an appropriate email to ask for this mailing list on the haskell.org site. -- -David House, [EMAIL PROTECTED] ___ 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] SYB vs HList (again)
Right now I am looking at using either SYB (Scrap Your Boilerplate) or HList Records to eliminate boilerplate for: * parsing URLEncoded strings into application data structures * generating XML/JSON from application data structures * handling adding new fields to serialized data structures * creating indexed collections of application data structures I am looking for insights from people here on which approach they think is better and why. Here are my current thoughts on the issue == Both HList and SYB require data structures redesign == HLists require you to define Labels and basically only use label values that are themselves either scalar or HLists. SYB basically requires the same thing except that you use data/newtype to define labels instead of HLists more cumbersome label constructions. == Defaults: HList gives you compile time errors, SYB only runtime errors == SYB does not seem to provide a way of having the compiler tell you that you are accessing a field that is unavailable in the type. HList will give you a type error if you do that. I don't know exactly how HList handles default values but I assume you can restrict use of those values to explicit deserialization contexts. Is that correct? == HList allows more informality == With HList you can specify the type of a record ad hoc using obj::(Record Foo .*. Bar .*.Baz). SYB requires that you define data structures in separate data declarations. It would be really nice if there was some way to tell Haskell that HLists have no more fields than the ones you happen to be getting and setting in your code. Effectively that would mean you get data structure inference not just function type inference which would be really cool! That is probably not possible but it couldn't hurt to ask (Oleg?). == SYB doesn't require template haskell to make it usable == With SYB you create field labels using newtype (or data) declarations e.g. data Salary = S {salary::Float} With HList, label declarations are really verbose e.g. data SalaryLabel deriving(Typeable) type Salary = Field (Proxy SalaryLabel) Int salary = proxy :: Proxy FooLabel You can make this more concise using TemplateHaskell but TH looks alien and adds fear to the use of any code. == Performance issues == SYB requires a linear traversal of all field elements using dynamic to get or transform a value. HList traverses an HCons list. I don't how bad this is as compared with traditional data structure access using pattern matching or field labels. My current bias is towards using HList because if we are going to force a conversion to a new data structure convention I'd rather have the typesystem on my side. With SYB it is too easy to let haskell field labels creep in to your data definitions and end up with subtle errors to correct. Any opinions on these issues would be very appreciated. -Alex- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] SYB and/or HList for XML, deserialization and collections
Having just done a major refactor of the HAppS HTTP API to make it much much easier to use, I am now thinking about simplifying the current boilerplate associated with XML serialization and state deserialization. In the case of XML, Currently the developer must manually write ToElement for every type he/she wants to output. HAppS provides functions that makes doing this a lot easier if the types are Haskell records with field labels of the form: data Animal = Animal {key::Int, name:: String, breed::Breed, price::Float} Looking at the XML example from the SYB site, a shift to SYB means shifting from Record types with field labels to identifying fields by their types so e.g. data Animal = Animal Key Name Breed Price type Key = Int type Name = String type Species = Cow | Sheep type Price = Float This model seems ok, but adds some verbosity. It also entails a learning curve because either you also have field labels or you end up with non-standard extra code to access fields. In this context, HList provides good record functionality and a little template haskell makes it easy to code so we end up with e.g. $(hList_labels Animal key name breed price) type Breed = Cow | Sheep This seems superior from a programming perspective because we have good record functionality (and implicitly support for XML namespaces!), but we lose something on the XML side. In particular, we end up with two new problems: 1. We no longer have type names, so we can't automatically generate an XML element name from an default HList record. The solution may be to define something like this: typeName name item = typeLabel .=. name .*. item animal = typeName animal myAnimal = animal .*. breed .=. Cow And since update and extension are different functions, if we hide typeLabel from the apps then this gets very safe (or we expose it and get a form of typesafe coerce). 2. We don't know how to deal with non-atomic field values e.g. animalbreedCow/breed/animal makes sense, but we probably don't want read/show for product types. Perhaps it is possible to use overlapping instances to do something like: instance ToElement HCons a b where ... instance ToElement a where toElement = show But perhaps we can use SYB to allow us to distinguish between atomic and non-atomic types and handle appropriately. I have to say I don't think I undersand the SYB papers well enough to give an example. Note: I can't find an actual example of generating XML from HLists in any of the HList docs so it may be that it is not actually as easy as it looks. All of this may be an open issue in theory as well as practice. == Deserialization == HAppS periodically checkpoints application state to disk. Developers may want to add or remove fields from their state types for from data types used by their state types. The current solution is to have the developer assign a version number to state. If state changes then the developer provides dispatch to a deserialization function based on that version number. It is not at all clear from either the SYB or the HList papers how to deserialize generally. That being said, the HList library provides a way to call functions with optional keyword arguments that looks like it would also generalize to schema transitions. Anyone who has some experience with this issue in the context of HList or SYB? == Haskell Collections == Currently HAppS developers use e.g. Data.Set or Data.Map as collection types for their application. If we push devlopers to use HList for eveything then they are going to need a way of handling collections of Hlist items. My sense is that HList style data structures can't be stored by Data.Map or Data.Set because they are not heterogenous collection types (and will break simply from varying the order of field names). If we use HList as the assumed record type, then I think we need to recode Data.Map and Data.Set for them. Has anyone implemented more interesting collection types for HList objects? -Alex- PS Obviously people can continue to use regular haskell types and implement stuff manually. My goal here is to support people who want more automation and are willing to learn HList or SYB in order to get it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] GADTs vs arrows/typeclasses
I don't think I'm the only one confused here. Henrik Nilson in his paper on adding GADTs to Yampa comments that: However, the recent addition of Generalized Algebraic Data Types (GADTs) [26] to the list of Haskell extensions supported by the Glasgow Haskell Compiler (GHC) gives programmers a lot more freedom. GADTs are a limited form of dependent types, offering a considerably enlarged scope for capturing and thus en- forcing important code and data invariants statically. In particular, GADTs are just what is needed to address the problem discussed above since the key idea is to allow constructors that have more spe- cific types than usual, and to take that extra type information into account in individual case branches. GADTs would no doubt also offer an interesting alternative to the methods described by Baars and Swierstra [1] and Hughes [19]. [1] and [19] are papers about Arrows. I guess I'm also not sure what belongs in a GADT and what belongs in a typeclass e.g. here is an Arrow GADT data Arrow b c where Arr::(b-c) - Arrow b c Compose::Arrow b c - Arrow c d - Arrow b d First::Arrow a b - Arrow (a,c) (b,c) When Arrow is defined like this, rather than write instances you just various evaluation functions for the Arrow GADT. -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Tue, 5 Dec 2006, Neil Mitchell wrote: Hi It seems like Haskell has two emerging idioms for parsing and fsms: GADTs and Arrows. What about something else? If you limit yourself to the two things that look new and cool (where emerging is another word for new, and idiom seems to be the current Haskell word for cool), you miss out on all the tried and tested stuff. I am thinking about using one of these idioms to represent server structure in a future version of HAppS but I'm not sure where to start. Why would one choose one or the other? I would pick Arrows (over GADTs) because Arrows are Haskell, and are supported by multiple Haskell compilers. Other than that (as far as I was aware) these two things are massively different, so I wouldn't have thought it was a one or the other choice usually. Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] GADT vs Arrows for parsers/FSMs/etc.
It seems like Haskell has two emerging idioms for parsing and fsms: GADTs and Arrows. I am thinking about using one of these idioms to represent server structure in a future version of HAppS but I'm not sure where to start. Why would one choose one or the other? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] why are implicit types different? (cleanup)
I ended up solving it by using a typeclass. My general experience of implicit types has been that they end up being a lot less useful than they appear. Getting the types right ends up being difficult and it is usually better just to be in a monad or as in this case to use typeclasses. I've begun to think of use of implicit types as a sign a bad smell in the code and if I have used one somewhere, I try to eliminate it because doing so usually results in better code overall. -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Tue, 28 Nov 2006, Simon Peyton-Jones wrote: | So I guess the real question is, how do I pass a polytype* wpn? and the answer is: | On Mon, 27 Nov 2006, Simon Peyton-Jones wrote: | | Implicit parameters have monotypes, not polytypes. So an implicit parameter never has a polymorphic type. You can get around this, as Ben suggested I think, by using a newtype to wrap it up: newtype WPN = WPN (forall a. Ev PassNet ev a - Ev State ev a) Simon So ?f in g gets | type (Char-Char). I rather doubt that something more general | (implicit parameters get polytypes) would work, given the implicit | improvement rules that implicit parameters require. | | Simon | | | -Original Message- | | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of | S. | | Alexander Jacobson | | Sent: 21 November 2006 19:28 | | To: haskell-cafe@haskell.org | | Subject: [Haskell-cafe] why are implicit types different? (cleanup) | | | | | | | | Why do g and g' have different types? | | | |g x y = let ?f = \x- x in ?f x ++ (show (?f y)) | |g :: [Char] - [Char] - [Char] | | | |g' :: (Show t) = [Char] - t - [Char] | |g' x y = let f = \x- x in f x ++ (show (f y)) | | | | Is there a way I can use implicit types and let g be as general as g'? | | | | -Alex- | | | | | | __ | | S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com | | ___ | | 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] why are implicit types different? (cleanup)
Ok, I'm not sure I understand the answer here, but how about a workaround. My current code looks like this: tt = let ?withPassNet=wpn ?withPassNet'=wpn ?withPassNet''=wpn in passNet passnet [user] regImpl b The type of wpn is: wpn :: Ev PassNet ev a - Ev State ev a The individual implicit parameters end up arriving with concrete values for a. If I pass wpn to passNet explicitly, it also appears to get converted to a monotype on arrival at the inside of passNet. So I guess the real question is, how do I pass a polytype* wpn? -Alex- * I would have thought the word was polymorphic, but you obvoiusly know. __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Mon, 27 Nov 2006, Simon Peyton-Jones wrote: Implicit parameters have monotypes, not polytypes. So ?f in g gets type (Char-Char). I rather doubt that something more general (implicit parameters get polytypes) would work, given the implicit improvement rules that implicit parameters require. Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of S. | Alexander Jacobson | Sent: 21 November 2006 19:28 | To: haskell-cafe@haskell.org | Subject: [Haskell-cafe] why are implicit types different? (cleanup) | | | | Why do g and g' have different types? | |g x y = let ?f = \x- x in ?f x ++ (show (?f y)) |g :: [Char] - [Char] - [Char] | |g' :: (Show t) = [Char] - t - [Char] |g' x y = let f = \x- x in f x ++ (show (f y)) | | Is there a way I can use implicit types and let g be as general as g'? | | -Alex- | | | __ | S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com | ___ | 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] Re: Debugging partial functions by the rules
As long as we are doing this, perhaps we should also discourage the use of (head list)? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Fri, 17 Nov 2006, Donald Bruce Stewart wrote: dons: dmhouse: On 16/11/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: And if we are absolutely positive that the value is (Just x), we can always write maybe (assert False undefined) id v It should be pointed out that Data.Maybe does export a less well-known function, fromMaybe: fromMaybe z = maybe z id This can be used to make the 'maybe X id' case a bit tidier (although technically it's not a save on characters). How controversial would a proposal to {-# DEPRECATE fromJust #-} be, in favour of: Just _ = x -- which will give you the precise line number maybe (assert False) maybe id fromMaybe It seems to me this is one cause of mysterious newbie errors we could easily discourage, with little harm. Btw, I'm not seriously suggesting removing it ;) It could be discouraged ever so slightly in the haddocks though. I'd encourage those worried about fromJust not to use it though, and perhaps try: import Debug.Trace.Location fromMaybe (failure assert my just was nothing) (Nothing :: Maybe ()) $ ./a.out *** Exception: A.hs:5:34-39: my just was nothing instead of: fromJust (Nothing :: Maybe ()) $ ./a.out *** Exception: Maybe.fromJust: Nothing While Dana and Neil work on more tools for spotting these for us. -- Don ___ 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] Packages and modules
Simon, We covered this extensively in the Cabal vs Haskell thread starting here: http://www.haskell.org//pipermail/libraries/2005-April/003607.html You concluded it by saying on April 22: And this observation points towards a simpler solution: rather than invisibly pre-pend the package name, just get the programmer to do so. So package P exposes a module called P.M and package Q exposes Q.M. All P's internal modules are called P.something, and similarly for Q. (We rely on some social mechanism for allocating new package names, as now.) Now of course you can import P.M and Q.M in a single module. That would be simple. It might be pretty inconvenient to say 'import Base.Data.List' rather than just 'import Data.List'. But nothing forces you to do this -- and indeed we don't do it for the current 'base' package. The point is that it's an easy way for a package author to ensure their package won't conflict with others. If they choose not to avail themselves of it, it's more likely that their package will be unusable because of accidental name conflicts. Bottom line: the current story is pretty defensible. I'm not sure that keeping names unique by implicitly using package-ids is worth the bother. http://www.haskell.org//pipermail/libraries/2005-April/003672.html It seems like you are changing your position with this proposal? Any reason for doing so? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Mon, 26 Jun 2006, Simon Peyton-Jones wrote: Simon and I have been thinking about fixing this, and we think we might actually do so for GHC 6.6. Your message provoked us to write up the design. It's here http://hackage.haskell.org/trac/ghc/wiki/GhcPackages Feedback welcome It's worth reading the old threads; for example http://www.haskell.org//pipermail/libraries/2005-August/004281.html But there are many others! Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Brian | Hulley | Sent: 25 June 2006 10:16 | To: Haskell-cafe | Subject: [Haskell-cafe] Packages and modules | | Hi - | At the moment there is a problem in that two packages P and Q could contain | the same hierarchical module eg Data.Foo, and the only way for user code to | ensure the right Data.Foo is used is to ensure that packages P and Q are | searched in the right order. | However suppose P and Q also contain another module with the same name, eg | Data.Bar. | And suppose a user module wants to use Data.Foo from P but Data.Bar from | Q!!! ___ 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] SMTP, HTTP, Telnet
HAppS and HaskellNet both have SMTP clients. HAppS focuses more on providing a reliable delivery agent (acting as a relay). I think HaskellNet focuses more on rich client functionality. -Alex- On Fri, 16 Jun 2006, Lyle Kopnicky wrote: Hi all, Anybody know of some good Haskell libraries providing: * an SMTP client, * an HTTP client, * or a Telnet client? There's a significant amount to these protocols, over and above the socket layer. Thanks, Lyle Kopnicky __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HAppS in production?
I am using it on http://pass.net which is live in production but not yet high volume. I hope to have some other projects live soon, but they are currently works in progress. -Alex- On Tue, 6 Jun 2006, Joel Reymont wrote: Folks, Is anyone using HAppS in production right now? It seems to be the most advanced Haskell web development platform right now but I would like to hear about others as well. Production (heavy) use is what I'm looking for. Thanks, Joel -- http://wagerlabs.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HAppS in production?
On Wed, 7 Jun 2006, Joel Reymont wrote: What type of machine are you running this on? What type of memory usage are you seeing? Under what kind of load? How much memory per connection? darcs get http://pass.net/s/repo; and you can experiment for yourself. If you have SearchPath installed http://searchpath.org you just run sh build.sh in the Pass.net root directory. FYI, I do development on a windows machine and deployment is on an old 1and1 web server. Are you running the naked HAppS web server? I have multiple HAppS applications running on different internal ports on the default 1and1 machine. Some of them are only handling http. Others are handling inbound email as well. So for http, I am using Apache as a secure server side caching proxy that dispatches http(s)://pass.net to localhost:9000 and I am using sendmail to SMTP relay mail for certain domains to e.g. localhost:2525 But, if this was the only app on the machine, I probably would run HAppS naked. Have you done any time of performance testing? Our internal benchmark tests had simple HAppS apps performing faster than Apache. But these sorts of tests are very application dependent so you will have to test your own apps. FYI, we have achieved this level of performance without doing much in the way of optimization. If you truly have a need for speed, the nice thing about HAppS is that the MACID monad architecture gives you orders of magnitude headroom for certain sorts of applications. In particular, currently HAppS works as an integrated binary that aggregates events from the network into a totally ordered stream that is then processed sequentially by your application code. But it would not be all that hard to separate the code into processes that creates streams, proceses that merge/distribute streams, and one process that runs your app on the merged stream. In this sort of architecture all of the work of HTTP and TCP gets offloaded onto stream creators running slave machines and your app effectively operates as a process that simply reads a binary parsed stream from stdin and writes one to stdout. To see why this gives you so much performance headroom, think about operating a sequential number service. A sequential number service is a service that produces numbers in order with no gaps. Notice that this is a really really simple service. But also notice that the standard web site architecture will cap your performance at around 10k requests per second and you won't be able to improve performance much by buying new machines! In contrast by patitioning your HAppS application as I described you max out at 1m requests per second. Note: I don't know what the cap is, but reading binary from stdin is orders of magnitude simpler than prcessing HTTP and TCP so getting a 100x improvement should not be that hard. Does this make sense? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HAppS in production?
On Thu, 8 Jun 2006, Joel Reymont wrote: On Jun 7, 2006, at 10:20 PM, S. Alexander Jacobson wrote: Does this make sense? Makes sense but almost sounds too good. :-) To be clear, the separation via binary streams has not yet been implemented. I plan to do so only if I need it. If you get to that scale first, then you get to do it :-/. FYI, I am currently funding a modification to HAppS back end logging/persistence system to allow the user to switch easily between disk and Amazon S3. For my apps, I'm willing to add 1.5x S3 latency in exchange for not having to worry about maintainin a reliable RAID disk subsystem with hardware failover and managing off-site backup. Not sure whether this feature is useful for your intended apps. What package would you recommend I use with HAppS to merge HTML templates with application data? My apps including Pass.net use XSLT. For HTTP, HAppS looks at the user-agent and if the browser does XSLT then it serves out XML with an XSLT PI at the top. If the browser doesn't support XSLT then it run xsltproc on the server. I don't think any MUA implements XSLT so the XML mail sending agent runs all outbound mail through xsltproc on the server. Note: the implementation of browser xslt detection here is very warty. I'd love it if someone else wanted to take some time to clean it up. -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell RPC
Given that we have no easy way to serialize thunks, the whole RPC approach just seems wrong for Haskell. RPC in general is pretty old school. REST seems to have worked better in practice (e.g. HTTP GET/POST!). For a general description of REST see http://webservices.xml.com/pub/a/ws/2002/02/06/rest.html For a summary of the REST vs RPC issue see e.g. http://www.tbray.org/ongoing/When/200x/2003/05/12/SoapAgain Note that Amazon exposed both sorts of interfaces and found the REST style interface much more popular! That being said, I am actually looking or a good Haskell SOAP client lib to talk to paypal so YMMV. -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Thu, 25 May 2006, Joel Reymont wrote: Folks, I'm curious about how the following bit of Lisp code would translate to Haskell. This is my implementation of Lisp RPC and it basically sends strings around, printed readably and read on the other end by the Lisp reader. If I have a list '(1 2) it prints as (1 2) and becomes '(1 2) again when read on the other end. I'm wrote a couple of macros to make the job of defining the RPC easier. def-remote-class defines the main (server) class as well as the client (proxy) class. def-remote-method creates the server method as well as a proxy method that sends data over and possibly waits for results and returns them (depending on the :async or :sync qualifier). My Lisp RPC code runs on top of UDP, looks good and works well. I have a soft spot for Haskell in my heart, though, so I wonder how I would go about implementing the same architecture in Haskell. This is an example from my test harness: (define-test remote-basic (def-remote-class remote (server) ()) (def-remote-method sum :sync ((self remote) (a fixnum) (b integer)) (declare (ignorable ip port)) (+ a b seqnum)) (let* ((port (+ 1000 (random 5))) (server (make-instance 'remote :port port)) (client (make-instance 'remote-proxy :host (host-address) :port port))) (assert-equal '(6) (sum client 1 2 :seqnum 3)) (stop server) (stop client) )) I think I can send Haskell code over the wire to be read on the other side just like I do with Lisp. The part that baffles me is being able to provide an interface that lets one easily define remote classes and methods. I totally hate Template Haskell because I find it incomprehensible and I'm not going to compare it to Lisp macros. Is there a way to do it without TH? Also, it seems to me that the only way to deal with variable numbers of differently typed arguments is to use the HList approach which is quite heavy machinery, IMO. Any suggestions? Thanks, Joel P.S. The Haskell Cafe has been a bit quiet lately so I do mean to stir it up some. I think this example shows the advantage of dynamically-typed languages. I'm also genuinely interested in possible Haskell solutions. -- http://wagerlabs.com/ ___ 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 DB and XML libs: one user's experience
It sort of depends on whether you are a client, a server, or an intermediary. HAppS has a wrapper around HaXML designed to make it really easy to generate XML. My HAppS apps use it to generate XML and then rely on external XSLT processors to transform that XML to HTML or MIME as needed. You can check out the http://pass.net source code for an example of how that works (darcs get http://pass.net/s/repo). Client side XML is the big mystery for me right now. In particular, I am looking for a nice way to talk to SOAP servers (in particular PayPal) and am looking at using HAIFA for that, but have not had the time to explore enough to make a recommendation. Note: HAIFA is intended to operate SOAP servers so this is an area for exploration. -ALex- On Tue, 16 May 2006, Robert Dockins wrote: Hello all, I recently found myself needing to do some data manipulation; I needed to take some data from a database and generate a series of XML files from it. In the past I've done most of this sort of work in Java, but this time I decided I'd take the opportunity to explore the state of the art of Haskell DB and XML libraries. As to DB, I tried using HDBC first. I was actually a little surprised how straightforward it was. My database (PostgreSQL) is directly supported, and the compile/install went smoothly. My first test connection program that typechecked worked as expected (!) and I was soon executing queries doing useful work with the results. I'd just like to take a moment to congratulate John Goerzen for creating a product with a low barrier of entry for using databases in Haskell. As I didn't really do anything beyond simple queries, can't comment on more advanced features. For XML, I wavered between HaXml and HXT (the Haskell XML Tookbox). I initially decided to use HXT because it has support for xml namespaces, which I was going to need, and because it just seems to be the most complete and advanced package available. The HXT install suffers a little bit from transitive-closureitis, but, overall wasn't too bad. However, I had a really hard time using it! The API is _really_ intimidating, and I couldn't find any basic tutorial-style documentation. The API docs are a little hard to use because related definitions are spread out over a bunch of modules, and the links don't always work. Also, the theses are nice, but they read like theses ;-) That's not what I want when I have a job to complete. Long story made short; I couldn't figure out how to create and XML document and serialize it to disk. I was reasonably motivated and I'm a pretty experienced Haskell programmer, but I had to call it quits after about 3 hours of struggling with it. Most of my programs would mysteriously fail to produce output OR errors! It was really frustrating. I ended up using HaXml instead and shoehorning in the namespaces by using attributes named xmlns:xyz etc. on the document root element (which is OK, but not ideal). The HaXml API was also tough to work with but was less mystifying than HXT's, and I eventually got it to work. I was a little disappointed by the results, because the pretty printer does some fairly bizarre things to ensure that it doesn't introduce extra whitespace into the DOM. I also had to do some futzing to make HaXml correctly escape literal text. Finally, the using the HaXml API to generate XML results in verbose code that's hard to read. I was hoping that I'd get results comparable to using xmlenc (http://xmlenc.sourceforge.net/) in Java, but I was disappointed by fairly low signal-to-noise ratio (although in all fairness, its probably comparable to using the DOM or SAX Java APIs). Overall, HaXml works, but feels a bit awkward, at least for this use case. Now taking a slightly closer look at HXML, I see that it may be the best choice for what I was attempting to do (although it also doesn't support namespaces). The simplified representation looks particularly nice for building XML from scratch. I may try rewriting with HXML and see how that goes. So that's it. I don't have any deep conclusions, but I thought I'd share my experiences in the hopes that they will be helpful to somebody. Rob Dockins Speak softly and drive a Sherman tank. Laugh hard; it's a long way to the bank. -- TMBG ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] web servers
I'd also be interested in a system that handled overlapped asynchronous requests in a fashion not dissimilar to Twisted [5]. I see you just saw the HAppS announcement. You'll appreciate that HAppS was actually inspired by Twisted (and Prevayler). over time. It seems to me that the sequencing of asynchronous operations is very much like threading computations in a monad, and that the higher-order functions on monads could also be used for composition of asynchronous operations. Yup you got it. The two big issues are ACID semantics (for any server) and handling of side effects. HAppS does write ahead logging and checkpointing to give you the ACID stuff and provides infrastructure so you can guarantee at-least-once execution of side effects. As for web dispatching, the application model in HAppS is to help you separate state, application logic, wire formats, protocols, and presentation layer: * State State is just a haskell data type you define. ACID Consistency enforced by Haskell's type system. ACID Durability is handled by MACID write-ahead logging and checkpointing. * Application Incoming events are gathered in individual haskell threads and then pushed onto a single application queue for processing. The queue model gives you ACID Atomicity and Isolation and lets your app be simply a set of functions with types like: SomeInputType - MACID SomeOutputType The MACID monad lets you update your state and *schedule* side-effects. To be clear, MACID is not in the IO monad so you cannot execute sideeffects, you can only schedule them. The framework takes care of making sure they are executed at-least-once (if they can be completed by a deadline you specify). * Wire Formats Since your app consists of a set of functions with various haskell input and output types, somewhere you need a place to convert between those internal haskell types and external protocol event types; e.g. from URLEncoded HTTP requests to SomeInputType and from SomeOutputType to XML encoded HTTP responses. * Protocols HAppS currently provides support for HTTP Requests/Responses and SMTP Envelopes. To be clear HApps provides ACID Atomicity at the protocol event level. So if you write a protocol with SMTP envelopes being the arriving event type then your app will have atomicity in processing incoming SMTP envelopes. If you write a protocol with SMTP commands being the arriving event type, then your app will have atomicity at the level of individual smtp commands. * Presentation If your application outputs XML as its wire format, HAppS provides a lot of support for using XSLT to transform it for presentation purposes. For example, you can send XML mail and HAppS will take care of applying the relevant XSLT stylesheet before it is delivered. If you output XML HTTP responses, HAppS takes care of applying the XSLT stylesheet server side for user-agents that don't support doing so on the client. The value here is that you can have designer types who know XSLT modify presentation stuff without touching your application code. -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Wed, 12 Apr 2006, Graham Klyne wrote: I'm interested, but I don't have the time to look right now (or in the next couple of months, as far as I can see). What would really interest me is a system that can provide the functionality of the Python packages I currently use (TurboGears [1], of which the web server/controller component is CherryPy [2]). There's also some interesting recent CherryPy-related discussion about web dispatching that I think could translate very well to Haskell [3][4]. ... I'd also be interested in a system that handled overlapped asynchronous requests in a fashion not dissimilar to Twisted [5]. I've very recently been playing with Twisted as a way to deal with large numbers of overlapping lightweight requests without having large numbers of active threads. Twisted requires one to string together asynchronous callbacks to assemble a process that completes over time. It seems to me that the sequencing of asynchronous operations is very much like threading computations in a monad, and that the higher-order functions on monads could also be used for composition of asynchronous operations. I just implemented a sequence function for Twisted operations whose implementation started to feel very like foldr. This can't be new, and I'm wondering if there is any interesting work out there on using monads for multiple asynchronous I/O operations. (And, much as I'd love to use Haskell for this, is there work that would translate cleanly to Python?) #g -- [1] http://www.turbogears.com/ [2] http://www.cherrypy.org/ [3] http://pythonpaste.org/do-it-yourself-framework.html
[Haskell-cafe] ANN: pass.net is live in haskell!
I just launched http://pass.net. Pass.net lets website use the user's email domains to authenticate. The default implementation is in Haskell and is now live. -Alex- PS I am at ETech right now and will be at SXSW next week. If you are here, please say hi. __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Credit Card Authorization code
I am looking for Haskell code that does credit card authorization? e.g. paypal website pro does not supply a Haskell lib. Does anyone know where to find something like this? -ALex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell XSLT interpreter?
Has anyone written a pure haskell xslt interpreter? If not, how difficult would it be to do so? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Joels Time Leak
Joel, In most cases, it just doesn't make sense to run 1000 threads simultaneously that are all bottlenecked on the same resource (e.g. CPU/memory) See e.g. http://www.eecs.harvard.edu/~mdw/proj/seda/ You should be grouping incoming events into queues by expected workload/event. Then you can give the client fairly reliable information about how long it will have to wait based on the size of the queue on which event is waiting. And if you have no way to differentiate between event workloads a priori then you really can't be giving clients response guarantees and need to rethink your business logic. FYI: I actually created a Haskell application server based on this logic called HAppS (see http://happs.org) and am in the process of getting binaryIO added to it. -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Tue, 3 Jan 2006, Joel Reymont wrote: Simon, I don't think CPU usage is the issue. An individual thread will take a fraction of a second to deserialize a large packet. The issue is that, as you pointed out, you can get alerts even with 50 threads. Those fractions of a second add up in a certain way that's detrimental to the performance of the app. The timeleak code uses Ptr Word8 to pickle which should be very efficient. I believe the delay comes from the way 'sequ' is compiled by GHC. I'll take the liberty of quoting Andrew Kennedy (your colleague from MS Research) who wrote the picklers: -- My original pickler implementation was for SML. It was used in the MLj compiler, and is still used in the SML.NET compiler, and has acceptable performance (few ms pickling/unpickling for typical intermediate language object files). I must admit that I've not used the Haskell variant in anger. Apart from the inherent slowdown associated with laziness, is there a particular reason for poor performance? -- 'sequ' by itself does not seem like a big deal but when used to model records it builds a large nested lambda-list and I don't think that list is being compiled efficiently. I would appreciate if you could look at that and issue a verdict now that Andrew cofirms using the picklers in a real-life environment and w/o major problems. Suppose I chose a different implementation of binary IO and disposed of pickler combinators. Suppose I gained a 2x speed-up by doing so. I would now be getting alerts with 100 threads instead of 50, no? That's still far from ideal. Joel On Jan 3, 2006, at 4:43 PM, Simon Marlow wrote: The reason things are the way they are is that a large number of *running* threads is not a workload we've optimised for. In fact, Joel's program is the first one I've seen with a lot of running threads, apart from our testsuite. And I suspect that when Joel uses a better binary I/O implementation a lot of that CPU usage will disappear. -- http://wagerlabs.com/ ___ 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] killing a running thread interactively
Ok, I didn't think Haskell had mutable global variables. How would this work? -ALex- On Thu, 22 Sep 2005, Simon Marlow wrote: There's no getAllThreadIds or similar right now. You have to save the ThreadIds yourself, perhaps in a global variable. Writing to a file doesn't work because there's no instance Read ThreadId. Cheers, Simon On 21 September 2005 21:14, S. Alexander Jacobson wrote: More particularly, is there a getAllThreadIds function somewhere? -Ale- On Wed, 21 Sep 2005, S. Alexander Jacobson wrote: Is the general pattern to write all threadIds to a file, and then have a separate function that takes the file and kills them? Or is there something more clever? -Alex- On Wed, 21 Sep 2005, Simon Marlow wrote: On 16 September 2005 20:42, S. Alexander Jacobson wrote: If I am running a server interactively. (using ghci). Is there any way to kill its running threads without terminating the interpreter? If you can get ThreadIds for the threads, yes. GHCi doesn't (currently) create a new thread for each expression evaluation, so attempting to kill that thread might kill your GHCi session (it shouldn't but that's another story). Cheers, Simon ** CRM114 Whitelisted by: [EMAIL PROTECTED] ** __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ** CRM114 Whitelisted by: [EMAIL PROTECTED] ** __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] killing a running thread interactively
Is the general pattern to write all threadIds to a file, and then have a separate function that takes the file and kills them? Or is there something more clever? -Alex- On Wed, 21 Sep 2005, Simon Marlow wrote: On 16 September 2005 20:42, S. Alexander Jacobson wrote: If I am running a server interactively. (using ghci). Is there any way to kill its running threads without terminating the interpreter? If you can get ThreadIds for the threads, yes. GHCi doesn't (currently) create a new thread for each expression evaluation, so attempting to kill that thread might kill your GHCi session (it shouldn't but that's another story). Cheers, Simon ** CRM114 Whitelisted by: [EMAIL PROTECTED] ** __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] killing a running thread interactively
If I am running a server interactively. (using ghci). Is there any way to kill its running threads without terminating the interpreter? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Where to start about writing web/HTTP apps ?
I will be launching (beta) a new commercial chat site written using Haskell and AJAX in the next month. The server is written on top of the HAppS library I made available at http://HappS.org. My general pattern for writing an application in this framework is write the server based on a wire-level spec where the server takes in XML/x-www-form-encoded/multipart-form-data and returns XML. Client side XSLT stylesheets then handle conversion of the XML to HTML. Here are the details if you are interested: 1. Write a web service spec as a reference for both client and server development. I use an informal language for this that relies on a mix of the reader understanding HTTP semantics and RelaxNG XML specs. POST /login ? {username {text},password{text},url{URL},captcha(text}} 200 session {attribute userId{text},attribute href {rel-URL}} Some text here describing other details that don't fit into the syntactic model described above. Server is assumed to handle any of application/x-www-form-urlencoded, multipart/form-data, or application/xml. Client is assumed to receive application/xml. Browser is assumed to handle XSL stylesheet PIs. (All conversion from XML to HTML is handled client side or on proxy using XSLT template) 2. Define Server State and state model data State = State {users::UserData} ...definition of user data... startState = State mzero addStateUser state user = 3. Define serialization for server state instance Show State where ... instance Read State where --- 4. Define exposed business logic addUser appCtx regInfo = if regGood then actionOk newState [] newUserInfo else qOk badRegInfo ... 5. define required wire formats for types --convert internal data type to XML instance ToElement NewUserInfo where toElement n = ... --convert posted data to internal data type instance FromMessage RegInfo where fromMessage msg = ... 6. define how busines logic maps to URLs ... a POST _ [u] = doXML addUser a GET myapp.com (s:path) = fileServe mimeTypes static path myApp appCtx = let ?style=XSL /s/style.xsl in simpleHTTP a appCtx 7. define the app to execute run path host = do app - startApp $ simpleConfig path startState confro serve host app return () main = run appdir localhost:80 8. put client side stuff (including style.xsl) in the static directory 9. install searchpath (see http://searchpath.org) 10 run it! $ searchPath ghc -o MyApp --internet http://searchpath.org/default.map src/MyApp.hs $ MyApp HAppS and the chat applications are still works in progress, but I have this running successfully internally already! -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Mon, 12 Sep 2005, Sam Mason wrote: gary ng wrote: I want to write apps for WEB and have briefly read WASH. I'm thinking of doing the same. The approach taken by WASH seems very cool and I'd love to use it. I've only started looking at it, but WASH seems to require that JavaScript be enabled on the user's web browser, even for the simplest forms. e.g. from the authors web page: http://nakalele.informatik.uni-freiburg.de/cgi/WASH/Counter.cgi Also, the error checking doesn't seem to work as I'd expect: if you submit a page without a required field it will complain the first time, then make something up the second time around -- even if you haven't entered anything in the field. Sam ___ 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] Where to start about writing web/HTTP apps ?
On Mon, 12 Sep 2005, Joel Reymont wrote: Why not XML-RPC? REST is more appropriate for the applications on which I work. See http://webservices.xml.com/pub/a/ws/2002/02/20/rest.html -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Sep 12, 2005, at 9:54 PM, S. Alexander Jacobson wrote: 6. define how busines logic maps to URLs ... a POST _ [u] = doXML addUser a GET myapp.com (s:path) = fileServe mimeTypes static path myApp appCtx = let ?style=XSL /s/style.xsl in simpleHTTP a appCtx ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Where to start about writing web/HTTP apps ?
a better example http://www.intertwingly.net/blog/2005/07/22/REST-vs-API On Mon, 12 Sep 2005, S. Alexander Jacobson wrote: On Mon, 12 Sep 2005, Joel Reymont wrote: Why not XML-RPC? REST is more appropriate for the applications on which I work. See http://webservices.xml.com/pub/a/ws/2002/02/20/rest.html -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Sep 12, 2005, at 9:54 PM, S. Alexander Jacobson wrote: 6. define how busines logic maps to URLs ... a POST _ [u] = doXML addUser a GET myapp.com (s:path) = fileServe mimeTypes static path myApp appCtx = let ?style=XSL /s/style.xsl in simpleHTTP a appCtx __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] concatMap generalizes to msumMap?
What is the name of the monadic generalization of concatMap? In which lib is it located? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] concatMap generalizes to msumMap?
I don't think that is right. concatMap has definition concatMap :: (a - [b]) - [a] - [b] concatMap f xs = concat $ map f xs Therefore: msumMap :: (MonadPlus m) = (a1 - m a) - [a1] - m a msumMap f list = msum $ fmap f list In contrast = has type (=) :: (Monad m) = (a - m b) - m a - m b -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Mon, 16 May 2005, Tomasz Zielonka wrote: On Mon, May 16, 2005 at 02:57:42PM -0400, S. Alexander Jacobson wrote: What is the name of the monadic generalization of concatMap? (=) or simply (=) if you don't care about argument order. Probably not what you are after? In which lib is it located? The former is in module Monad, the latter in Prelude. Best regards Tomasz ** CRM114 Whitelisted by: [EMAIL PROTECTED] ** ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] subRegex bug?
Am I misunderstanding the regex docs? *MyMod subRegex (mkRegex \\. ) foo.bar blah foo*** Exception: Text.Regex.Posix.regcomp: error in pattern -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Linux device drivers
Would it be harder/easier better/worse to use Linux device drivers from hOp/House as opposed to writing new disk I/O stuff in Haskell? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Tue, 22 Mar 2005, Keean Schupke wrote: I don't think I said anything controversial. I guess I was just over-simplifying things by only considering PC IDE hardware - but then again that must get you running on 90% of the systems people are likely to have lying around to play with a developmental OS on. On the other hand the average network driver seems to be about 2,000 lines of code, whereas if you add all the parts of the generic ide driver together you get about 20,000 lines of code. I guess that answers my question - storage is an order of magnitude harder than networking, even before including SCSI. Regards, Keean. Simon Marlow wrote: Keean, you should be aware that Lennart is something of a device driver guru. He knows what he's talking about :-) Go grep for Augustsson in the NetBSD kernel sometime. Cheers, Simon ___ 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] implicit parameters THANK YOU!
I just discovered implicit parameters. To everyone involved with making them, THANK YOU. They are blazingly useful/powerful for server handler style libraries where you want to make a veriety of local environment information available to the handlers without burdening the handlers with a big dictionary object to carry around. FANTASTIC. That being said, they so powerful they are proabably easy to abuse. Could those experienced with this feature provide warnings about possible problems with overuse? I see so many places I think I could make HAppS code nicer using this feature that I am concerned about making mistakes. -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Linux device drivers
Wow! Did you also implement tcp in Haskell? Does hOp or House also have the ability to write to disk? (With HAppS, I've gotten rid of the AMP part of LAMP, it would be really cool to get rid of the L as well!) -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Mon, 21 Mar 2005, Donald Bruce Stewart wrote: mark: I was wondering about the possibility of using Haskell for developing device drivers that would be kernel modules for Linux. If nothing else, it would be quite an educational experience for me, as I've not yet experimented with either the Linux kernel or Haskell FFI, nor have I had to learn how to squeeze much performance out of my Haskell code. Clearly, this application demands special things from the compiler and the runtime. But, I'm not exactly sure what, nor how to achieve such given current compilers. Does anyone have any thoughts? Well, it would be tricky, but fun! We've got a few drivers written in Haskell already (but not for Linux, as far as I know). For example check out the House network stack and drivers: http://cvs.haskell.org/cgi-bin/cvsweb.cgi/programatica/hOp/ and http://cvs.haskell.org/cgi-bin/cvsweb.cgi/programatica/hOp/kernel/Kernel/Driver/NE2000/ So there's heavy use of Data.Bits and Word# types - but nothing that isn't fairly well established in GHC Haskell, anyway. Then (for GHC, anyway) you'd have to link the kernel against libHSrts.a, much as we do when calling Haskell from other kinds of C apps, which involves compiling the C app with all the magic flags ghc normally sets up (ghc -v9 main.c is helpful). Something like: ;) egcc -v -o a.out -DDONT_WANT_WIN32_DLL_SUPPORT main.o -L/home/dons/lib/ghc-6.4 -lHStemplate-haskell -lHSCabal -lHSposix -lHSposix_cbits -lHSlang -lHSmtl -lHShaskell-src -lHSunix -lHSunix_cbits -lHShi -lHShaskell98 -lHSaltdata -lHSbase -lHSbase_cbits -lHSrts -lm -lgmp -u GHCziBase_Izh_static_info -u GHCziBase_Czh_static_info -u GHCziFloat_Fzh_static_info ... Then, having the kernel start up the Haskell rts (at boot would be good): hs_init(argc, argv); .. do something in Haskell or C land ... hs_exit(); Then you'd could dyn load (via GHC's rts) your Haskell driver into the C app, and use it, as long as you've got a nice ffi interface to pass values back and forward. I'm sure the fun part is in the details ;) Cheers, Don ___ 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] Linux device drivers
Very very cool. Has anyone written any storage drivers? If there is already TCP, has someone written an iscsi (RFC3720) driver? -Alex- On Mon, 21 Mar 2005, Donald Bruce Stewart wrote: dons: alex: Wow! Did you also implement tcp in Haskell? On this topic, the following House code looks relevant: http://cvs.haskell.org/cgi-bin/cvsweb.cgi/programatica/hOp/kernel/Net/ There's something satsifying about seeing 'instance Functor Packet' in IPv4.hs ;) Does hOp or House also have the ability to write to disk? (With HAppS, I've gotten rid of the AMP part of LAMP, it would be really cool to get rid of the L as well!) Sorry! By We've got a few drivers written in Haskell, I meant the Haskell community, not me personally :} You have the hOp and House developers to thank for this stuff. On Mon, 21 Mar 2005, Donald Bruce Stewart wrote: mark: I was wondering about the possibility of using Haskell for developing device drivers that would be kernel modules for Linux. If nothing else, it would be quite an educational experience for me, as I've not yet experimented with either the Linux kernel or Haskell FFI, nor have I had to learn how to squeeze much performance out of my Haskell code. Clearly, this application demands special things from the compiler and the runtime. But, I'm not exactly sure what, nor how to achieve such given current compilers. Does anyone have any thoughts? Well, it would be tricky, but fun! We've got a few drivers written in Haskell already (but not for Linux, as far as I know). For example check out the House network stack and drivers: http://cvs.haskell.org/cgi-bin/cvsweb.cgi/programatica/hOp/ and http://cvs.haskell.org/cgi-bin/cvsweb.cgi/programatica/hOp/kernel/Kernel/Driver/NE2000/ So there's heavy use of Data.Bits and Word# types - but nothing that isn't fairly well established in GHC Haskell, anyway. Then (for GHC, anyway) you'd have to link the kernel against libHSrts.a, much as we do when calling Haskell from other kinds of C apps, which involves compiling the C app with all the magic flags ghc normally sets up (ghc -v9 main.c is helpful). Something like: ;) egcc -v -o a.out -DDONT_WANT_WIN32_DLL_SUPPORT main.o -L/home/dons/lib/ghc-6.4 -lHStemplate-haskell -lHSCabal -lHSposix -lHSposix_cbits -lHSlang -lHSmtl -lHShaskell-src -lHSunix -lHSunix_cbits -lHShi -lHShaskell98 -lHSaltdata -lHSbase -lHSbase_cbits -lHSrts -lm -lgmp -u GHCziBase_Izh_static_info -u GHCziBase_Czh_static_info -u GHCziFloat_Fzh_static_info ... Then, having the kernel start up the Haskell rts (at boot would be good): hs_init(argc, argv); .. do something in Haskell or C land ... hs_exit(); Then you'd could dyn load (via GHC's rts) your Haskell driver into the C app, and use it, as long as you've got a nice ffi interface to pass values back and forward. I'm sure the fun part is in the details ;) Cheers, Don ___ 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 __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] hFileSize vs length
I am using GHC 6.2 on windows and am finding that when I open a file and use hFileSize I get a different number than I get from reading in the file and calculating the length. I assume this is not a bug, but I don't know why its happening. Also, why isn't there getFileSize function in System.Directory? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: HAppS -- Haskell Application Server v 0.3
HAppS is a Haskell library for building Internet applications, featuring: * HAppS.ACID: Guarantee application integrity in the face of unplanned outages using this module's integrated write-ahead logging and checkpointing framework. * HAppS.DBMS: Do relational operations in Haskell (rather than SQL) on Haskell sets (outside the IO Monad). Define custom indices for your Haskell datatypes (e.g. geographic/geometric types). Use in combination with ACID for a robust relational DBMS customized for your application. * HAppS.Protocols: Expose your application using as an HTTP server and/or by recieving and sending SMTP. Changes since 0.2: HAppS Changes * Much cleaner interface for ACID transaction handlers * DBMS operators that look more like HaskellDB operators * SMTP send errors are exposed for use in future reliable deliver implementation * ACID callbacks disabled. Framework in place for total order on callbacks. * SideEffect queues are now algrebraic types rather than strings. * Parametrized HTTP using XML ToElement and HTTP ToMessage FromMessage and ToURI classes (you write transaction handlers in terms of Haskell types and the system takes care of exposing them for HTTP) * Parametrized HTTP response now has type (ToURL url,ToMessage msg)=Response url message Framework takes care of automatically translating relative URLs to absolute URLs. Answers to questions a few people have asked: * Compare HAppS.DBMS with HaskellDB HaskellDB is really optimal if you want to talk to external databases. HAppS.DBMS is really good if you want to do relational operations on Haskell Sets without going to the IO monad. * Compare HAppS.ACID to STM Use STM if all your IO operations have a two-phase-commit interface. Use HAppS.ACID if your IO interfaces are not transactional. Instead HAppS.ACID gives you multi-queue, at-least-once execution of side-effects, and a total order on their callbacks. There is no rollback semantic because you can't unsend email. * Compare HAppS.Protocols.SMTP to Peter Simon's Postmaster Postmaster is trying to be a full fledged MTA. SMTP is trying simply to give you SMTP receive/send functionality in your applications. Neither yet has a queuehandler. We both hope to merge lessons learned soon. * Compare HAppS.Protocols.HTTP to Warrick Gray's Network.HTTP module Network.HTTP is more oriented towards building HTTP clients. HAppS..HTTP is more oriented towards building HTTP servers. Network.HTTP enforces a stronger separation between headers and body. HAppS..HTTP delivers a MIME message back to the app. With infrastructure to enable transparent conversion to and from application datatypes. -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] haskell DNS resolver w/o using FFI
Peter Simons told me that someone has written a DNS resolver in Haskell that doesn't rely on an FFI call. I'd love to look at it if it is available... -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] how do I avoid excessive constructor application?
My point was that this code seems excessively complex: fun::(a-a1)-(Either a b)-Either a1 b fun f (Left x) = Left (f x) fun _ r@(Right x)= Right x I'd like to avoid the destruction and construction in the third line by replacing the right hand side with r. However, the typechecker then claims my type is wrong. How do I fix that? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Wed, 2 Mar 2005, Henning Thielemann wrote: On Wed, 2 Mar 2005, Ben Lippmeier wrote: You can play games with the type checker to force them to have the same type without changing the meaning of your function. fun1' f (Left x)= if True then Left (f x) else Left x Left (f x) `asTypeOf` Left x ? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] how do I avoid excessive constructor application?
I'd like to do this sort of thing with types other than Either. Is there a generic safe coerce function? -Alex- On Wed, 2 Mar 2005, Stefan Holdermans wrote: Lemmih, And you can fix it with some unsafeCoerce# magic. (: Actually, as I pointed out, the required coercion in perfectly safe, though not implicit: coerceRight :: Either a b - Either c b coerceRight (Right b) = Right b Regards, Stefan __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] how do I avoid excessive constructor application?
For some reason, these two functions have different types. fun1 f (Left x)= Left (f x) fun1 _ r@(Right x) = Right x fun2 f (Left x) = Left (f x) fun2 _ r = r Is there a way to rewrite fun2 so that f has type (a-b)? In the general case, it seems wasteful to have to destruct and construct values just for type checking reasons, especially if your type has many more constructors than (Either a b). -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] how to avoid overlapping instance error?
If you are not using them to prevent overlapping instances, then why require instance decls at all? For example, why does GHC require an instance decl here: instance (Ord x)=ToSet [] x where toSet = Set.fromList But not here: listToSet x = Set.fromList x Or I suppose, one could rephrase this question as why not simplify instance declarations to be: instance ToSet where toSet = Set.fromList And let the typechecker take care of figuring out what instance is being specified here? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Mon, 28 Feb 2005, Simon Peyton-Jones wrote: Unfortunately, the context of an instance decl is not taken into account when matching instance decls. Yes, it would make sense to do so, but it'd make the system yet more complicated. So Show (table item) overlaps with Show ([] item) Overlap is checked lazily, so if you look for Show (MyTable t) you won't get overlap. Only if you ask for Show (table item), where the type checker still doesn't know what type 'table' is going to be, do you get a problem. Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of S. | Alexander Jacobson | Sent: 25 February 2005 17:09 | To: haskell-cafe@haskell.org | Subject: [Haskell-cafe] how to avoid overlapping instance error? | | | Currently, the HAppS.DBMS lib requires the user to provide a Show | instance for their table types. An example might be: | | instance (Show item) = Show (MyTable item) where | showsPrec d table = showsPrec d $ Set.toList $ myTableSet table | | But the Table class itself defines a toSet function so I think I | should be able to do this once for all Table instances: | | instance (Show item,Ord item, Table table item p) = Show (table item) where | showsPrec d table = showsPrec d $ Set.toList $ toSet table | | But I get an error telling me I am overlapping with Show [a]. | | Since [] is not an instance of Table, I don't see why there should be | an overlap. | | -Alex- | | __ | S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com | ___ | 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] how to avoid overlapping instance error?
Currently, the HAppS.DBMS lib requires the user to provide a Show instance for their table types. An example might be: instance (Show item) = Show (MyTable item) where showsPrec d table = showsPrec d $ Set.toList $ myTableSet table But the Table class itself defines a toSet function so I think I should be able to do this once for all Table instances: instance (Show item,Ord item, Table table item p) = Show (table item) where showsPrec d table = showsPrec d $ Set.toList $ toSet table But I get an error telling me I am overlapping with Show [a]. Since [] is not an instance of Table, I don't see why there should be an overlap. -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: HAppS -- Haskell Application Server v 0.2
HAppS is a Haskell library for building Internet applications, featuring: * HAppS.ACID: Guarantee application integrity in the face of unplanned outages using this module's integrated write-ahead logging and checkpointing framework. * HAppS.DBMS: Do relational operations in Haskell (rather than SQL) on Haskell sets (outside the IO Monad). Define custom indices for your Haskell datatypes (e.g. geographic/geometric types). Use in combination with ACID for a robust relational DBMS customized for your application. * HAppS.Protocols: Expose your application using as an HTTP server and/or by recieving and sending SMTP. - License HAppS is released by HAppS.org under the terms of the GNU General Public License Version 2, a copy of which is enclosed with this package. - How do I get HAppS? More information is available at http://HAppS.org A tarball of HAppS is available at http://HAppS.org/HAppS/happs.tar.gz. HAppS is also available via darcs: darcs get http://happs.org/HAppS __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] how to name third party libraries?
Is there documentation somewhere about how to name third party libraries? For example, if I have HTTP and SMTP libraries, what should I call them? -alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] wierd type errros with MPTCs
This code gives me a Kind error because IVal isn't applied to enough type arguments. import qualified Set class Table table indexVal | indexVal-table where --insertIndex::item-indexVal item - table item -table item union::table item - table item - table item --union t1 t2 = t1 data DBTable item = DBTable data IVal item = Name item instance Table DBTable (IVal ) where Weirdly, when I uncomment the insertIndex function, things work. But, if I then uncomment the default implementation of union, I get: No instance for (Table DBTable indexVal) arising from use of `Main.$dmunion' at example.hs:13 In the definition of `union': union = Main.$dmunion In the definition for method `union' In the instance declaration for `Table DBTable IVal' I don't know what this error even means. But it goes away if I put the union implementation in the instance rather than in the class. Bot these error messages seem unreasonable. Can someone clarify? Note: I am using GHC 6.2.2 -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] field record update syntax
I have a lot of code of the form foo {bar = fn $ bar foo} Is there a more concise syntax? I am thinking the record equivalent of C's foo+=5... I imagine there is some operator that does this e.g. foo {bar =* fn} But I don't know what it is... -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] using Map rather than FiniteMap
On Tue, 25 Jan 2005, David Menendez wrote: Does having 'zipped' at the top level mean that the program is keeping the entire 100,000-element list in memory? I don't know, but I tested with zipped at the top, in the where, and it appears to make no performance or memory difference. Also, would performance improve if you used Map.fromList? How about Map.fromAscList? HUGE IMPROVEMENT. The old code had maximum residency of 11Mb and running time of 41s. The code using Map.fromList has max. residency of 6.4Mb and running time of 5.2s! I guess foldlStrict is HUGELY more efficient than than foldr. (Why isn't it in the prelude?) But even using foldrStrict (fromList), we are still using 60 bytes per item and have ~30 bytes unaccounted for. Any hints? import qualified Map main = print $ length $ Map.keys theMap where zipped =zip [1..] [1..10]::[(Int,Int)] theMap = Map.fromList zipped -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com S. Alexander Jacobson writes: After actually running the correct test, I am still getting semi-ridiculous space behavior (6k/pair)! import qualified Map zipped =zip [1..] [1..10]::[(Int,Int)] untup f (x,y) = f x y produce = foldr (untup Map.insert) Map.empty zipped fm = length $ Map.keys produce main = print $ fm Two questions I'm currently too lazy to investigate myself: -- David Menendez [EMAIL PROTECTED] | In this house, we obey the laws http://www.eyrie.org/~zednenem |of thermodynamics! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] using Map rather than FiniteMap
Ah, ok. So I ran the code with 10 items, 5 items, and 25000 items and got total memory in use of 28Mb, 15Mb, and 8Mb respectively. That comes to 260-280 bytes per record which is still an order of magnitude higher than the 20-30 bytes per record we would expect. On the other hand, I found 10mb, 5mb, and 2.5mb maximum residency, but that is still ~100 bytes per record. Lastly, I tried example +RTS -p -K5M -hc and then looked at the resulting graph (attachment #2) and it shows a total of 1.6Mb heap allocated and if that data is correct, it does correspond roughly to our 20-30 bytes per record estimate. Regarding stack, I tried example +RTS -p -K5M -xt -hc and then ran hp2ps and looked at the resulting graph (attachment #1) SYSTEM appears to use 4mb of stack at the very beginning (presumably to create zipped), but I don't know why it would. Then this stack is consumed by the rest of the program. Can you provide some guidance on interpreting this data? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Wed, 26 Jan 2005, Simon Marlow wrote: On 25 January 2005 23:27, S. Alexander Jacobson wrote: Oops. It pays to check your checking code before making posts like this. After actually running the correct test, I am still getting semi-ridiculous space behavior (6k/pair)! import qualified Map zipped =zip [1..] [1..10]::[(Int,Int)] untup f (x,y) = f x y produce = foldr (untup Map.insert) Map.empty zipped fm = length $ Map.keys produce main = print $ fm Has this profile: example +RTS -p -K5M -RTS total time =5.10 secs (255 ticks @ 20 ms) total alloc = 612,534,236 bytes (excludes profiling overheads) COST CENTREMODULE %time %alloc balanceMap 71.8 72.8 insert Map 12.2 10.8 size Map9.09.7 binMap2.42.2 rotateRMap1.60.3 zipped Main 0.81.9 Notice the 612Mb for storing a mapping from Int to Int!! Notice that's 612Mb *allocation* to create the finite map and deconstruct it into a list. Not 612Mb of live heap to store the finite map. If you make sure everything is evaluated, and examine the heap profile I'm sure you'll find that the finite map is taking a reasonable amount of space (perhaps 20-30 bytes per node for storing integers, I guess). To get a rough idea of the total live heap without profiling, you can run the program with +RTS -sstderr and look at the memory in use figure. Cheers, Simon example.ps Description: PostScript document example2.ps Description: PostScript document ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what is a stack overflow?
Also, how do I get the profiler to tell me whether I am consuming heap or stack? -Alex- On Mon, 24 Jan 2005, Iavor Diatchki wrote: hi, it may happen for different reasons, but a common one is when you have a foldl pattern (programming with an accumulator), for example like this: sumList1 [] accum = accum sumList1 (x:xs) accum = sumList1 xs (x + accum) this adds a list of numbers with an accumulator. because haskell is lazy however, the additions (the accumulator) are not evaluated, instead the compiler builds a big expression, that is to be evaluated later. for example: sumList1 [1,2,3] 0 = sumList1 [2,3] (1 + 0) = sumList1 [3] (2 + (1 + 0)) = sumList1 [] (3 + (2 + (1 + 0)) = 3 + (2 + (1 + 0) notice that the accumlator is not evaluated as you go along. now the way this expression is evaluated (roughly) is: start pushing... (stack on the rhs) 3 + (2 + (1 + 0) [] 2 + (1 + 0)[3] 1 + 0[2,3] 0 [1,2,3] now poping... 1 [2,3] 3 [3] 6 [] and the result is 6. if the list is very long, you will need to push very many things on the stack to evaluate the expression, and so you might run out of stack. the way to avoid this problem is to not create the big expression, by forcing the accumulator to be evaluated as you go along rather then once at the end. this can be done like this: sumList2 [] accum = accum sumList2 (x:xs) accum = sumList2 xs $! (x + accum) ($!) is like ($) except that it forces the evaluation of its arguments. now the expression is likely to be evaluated using very little stack (if the compiler notices that we have a tail recursive call, and it should) hope this helped -iavor On Mon, 24 Jan 2005 19:19:09 -0500 (Eastern Standard Time), S. Alexander Jacobson [EMAIL PROTECTED] wrote: Thank you iavor. But the -K option doesn't appear to work with ghci. And I guess the bigger question is what sort of code causes a stack overflow. If 5M is enough stack for most programs then I obviously have some basic coding error which is causing a stack overflow... What sort of code causes that? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Mon, 24 Jan 2005, Iavor Diatchki wrote: hi, programs compile with GHC have a bunch of command line switches. you can see them by typing: myProg +RTS -help one of them enables you to specify stack space, e.g. myPorg +RTS -K5M (very briefly) the stack is a part of memory used by the compiler to pass around arguments to functions, and for temporary computations. -iavor On Mon, 24 Jan 2005 17:16:08 -0500 (Eastern Standard Time), S. Alexander Jacobson [EMAIL PROTECTED] wrote: GHC assumes the user knows the difference between the heap and the stack. I don't. No matter how much heap I specify on the GHCi command line, I get a stack overflow exception. I have no idea what that means or how to remedy it. Hints? Note: My program is basically creating a few 100k item FiniteMaps. I don't think that should exceed the memory on my laptop -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ 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 __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] using Map rather than FiniteMap
Just did a search after my last post and learned that FiniteMap is bad. Discoverd that Data.Map is the intended replacement. Downloaded it and modified it to work with 6.2. Blazingly fast! Yay. Please ignore the prior message. -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] using Map rather than FiniteMap
I didn't find any such information. I just decided to look at the FiniteMap source code in CVS and discovered in the comments that it was deprecated in favor of Data.Map. So I downloaded the new Data.Map and Data.Set and ran the code I posted before. I executed basically instantly and used minimal memory. I think Map picked up a lot of speed because it doesn't spaceleak, but am not sure. -Alex- On Tue, 25 Jan 2005, Ketil Malde wrote: S. Alexander Jacobson [EMAIL PROTECTED] writes: Just did a search after my last post and learned that FiniteMap is bad. Discoverd that Data.Map is the intended replacement. Downloaded it and modified it to work with 6.2. Blazingly fast! Oh? I was aware that Data.Map was supposed to be better, but not that FiniteMap was particularly bad. Is there any information about when, why and by how much Data.Map is better? -kzm -- If I haven't seen further, it is by standing in the footprints of giants __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] using Map rather than FiniteMap
Oops. It pays to check your checking code before making posts like this. After actually running the correct test, I am still getting semi-ridiculous space behavior (6k/pair)! import qualified Map zipped =zip [1..] [1..10]::[(Int,Int)] untup f (x,y) = f x y produce = foldr (untup Map.insert) Map.empty zipped fm = length $ Map.keys produce main = print $ fm Has this profile: example +RTS -p -K5M -RTS total time =5.10 secs (255 ticks @ 20 ms) total alloc = 612,534,236 bytes (excludes profiling overheads) COST CENTREMODULE %time %alloc balanceMap 71.8 72.8 insert Map 12.2 10.8 size Map9.09.7 binMap2.42.2 rotateRMap1.60.3 zipped Main 0.81.9 Notice the 612Mb for storing a mapping from Int to Int!! Also 5M of stack is required to make this work. Can anyone help? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Tue, 25 Jan 2005, Jorge Adriano Aires wrote: Just did a search after my last post and learned that FiniteMap is bad. Discoverd that Data.Map is the intended replacement. Downloaded it and modified it to work with 6.2. Blazingly fast! Yay. Hi, just curious, How much trouble was getting it to work with ghc 6.2 and adapting your program to use the API of Data.Map instead of Data.FiniteMap? J.A. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] what is a stack overflow?
GHC assumes the user knows the difference between the heap and the stack. I don't. No matter how much heap I specify on the GHCi command line, I get a stack overflow exception. I have no idea what that means or how to remedy it. Hints? Note: My program is basically creating a few 100k item FiniteMaps. I don't think that should exceed the memory on my laptop -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what is a stack overflow?
Thank you iavor. But the -K option doesn't appear to work with ghci. And I guess the bigger question is what sort of code causes a stack overflow. If 5M is enough stack for most programs then I obviously have some basic coding error which is causing a stack overflow... What sort of code causes that? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com On Mon, 24 Jan 2005, Iavor Diatchki wrote: hi, programs compile with GHC have a bunch of command line switches. you can see them by typing: myProg +RTS -help one of them enables you to specify stack space, e.g. myPorg +RTS -K5M (very briefly) the stack is a part of memory used by the compiler to pass around arguments to functions, and for temporary computations. -iavor On Mon, 24 Jan 2005 17:16:08 -0500 (Eastern Standard Time), S. Alexander Jacobson [EMAIL PROTECTED] wrote: GHC assumes the user knows the difference between the heap and the stack. I don't. No matter how much heap I specify on the GHCi command line, I get a stack overflow exception. I have no idea what that means or how to remedy it. Hints? Note: My program is basically creating a few 100k item FiniteMaps. I don't think that should exceed the memory on my laptop -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ 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] what is inverse of mzero and return?
I assume there is a standard name for this class/function: instance Foo [] where foo [] = mzero foo (x:_) = return x instance Foo (Maybe x) where foo Nothing = mzero foo Just x = return x -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] FiniteMapFiniteMap
I would like to read a large finitemap off of a disk faster than the time it takes to read the entire list of pairs. My solution is to save it as a bunch of smaller lists of pairs covering various key intervals (or recency intervals). I then can readfile all of these lists back into a bunch of finitemaps. Because readfile is lazy my program can start very quickly without waiting to read the contents of all of these files. To make this solution work, I need some datastructure that looks like a finitemap but operates on a bunch of them organized either in parallel (key interval model) or series (time interval model). Is there some pre-existing data structure that does this or do I need to roll my own? Or is there a better way to (de-)serialize FiniteMaps? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] memory leak in Random.randoms or makeList?
Using ghci, I am getting this error message: *Main timeOp $ print $ sizeFM bigFM' GHC's heap exhausted: current limit is 268435456 bytes; From this code: makeList x = map ((\x-x `mod` range).abs) $ Random.randoms (Random.mkStdGen x)::[Int] range=10 fmRecords' n = listToFM $ take n $ zip (makeList 100) (makeList 200) fmRecords n = listToFM $ take n $ zip [range..] [range..] fmSize=10^6 bigFM = fmRecords fmSize bigFM' = fmRecords' fmSize bigFM works fine so the leak is obviously within makeList. I just don't understand how makeList could produce this error... -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Text.XML.HaXML.HaskellToXml DRIFT example
Does someone have an example of how to use DRIFT to convert a Haskell type into XML? The documentation appears rather sparse... -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Text.XML.HaXML.HaskellToXml DRIFT example
Oops, I just found the examples directory. So the next question is: Is there a way to use DRift directly from GHCI? If I have to hmake regularly, that will get annoying fast. -Alex- On Wed, 27 Oct 2004, S. Alexander Jacobson wrote: Does someone have an example of how to use DRIFT to convert a Haskell type into XML? The documentation appears rather sparse... -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Modifying Running Programs
eBay modifies 30k lines of code per week while maintaining 99.92% uptime. Is there a way to force ghc (or some other Haskell implementation) to load new implementations of functions without restarting the program? Alternatively, is there a way of restarting a program with new code without having to reconstruct all its in memory state? -Alex- __ S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Haskell and concurrency
On Fri, 25 Jun 2004, Simon Marlow wrote: Concurrent Haskell is designed to provide exactly the kind of lightweight concurrency you're after. It won't be as quick as a custom application-specific threading model in the way you describe, but it's a *lot* faster than using one OS-thread for each thread in your system. And if you find it to be still too slow for your application, we know of several ways to speed it up... That's exciting. I am currently working on a web-appserver framework that relies on concurent Haskell (hence all my postings to the list about concurrent haskell issues). My theory is, given that you were able to achieve ~1000 requests/second in 2000, I should be able to serve 10k HTTP requests per second on a regular modern beige box. (~5m unique users at 1 visit/day 10 clicks per visit 10 request per click). If I need less than 5k of server state per visitor then I can operate a fairly substantial web site on e.g. a 32GB Dell PowerEdge for under $50k ($.01/user)! http://configure.us.dell.com/dellstore/config.aspx?c=uscs=555l=enoc=PE7250PADs=biz I currently have working: * ACID semantics on an abstract serializable state Constraints: * each request must encapsulate the entire transaction * requests and state must be instances of Read/Show * state must fit in memory (though this is looser than it appears) * in order execution of all sideeffects * multiple sideeffect queues * at least once execution of all sideeffects * very basic HTTP serving framework for these apps (SMTP framework coming soon) * a basic relational database (not yet serializable) that will eventually be used as a concrete state implementation I am now working on an application to run on the framework and use these features. I'll post when the design is more proven and its time to reach those performance levels. -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] readEitherChan
On Fri, 25 Jun 2004, Simon Marlow wrote: There's no fundamental difficulty that I'm aware of. The lack of these functions is probably down to historical reasons: tryTakeMVar and tryPutMVar are recent additions to the old MVar interface. Ok. Then will take a look in the library and try to understand the concrete implementations. It seems to me that with MVars you can implement pretty much any abstraction you need, including choice, and it's not clear that there would be any advantage to providing any more primitives. That's based on my experience so far, anyway - I know there are people out there that have made rather more heavy use of MVars than I have (eg. George Russell). Well we appear to be having a problem implementing a takeEitherMVar or readEitherChan without adding a new abstraction Also, you wouldn't need these functions if Haskell's concurency model was defined to be non-preemptive. How come forkIO was not specifically defined to be non-preemptive (with forkOS dependent on the local OS native threading model)? So threads forked by forkIO would be non-preemptive with respect to what? Other threads forked by forkIO, or forkOS? All forkIO'ed threads would run in the same OS thread and only lose control when they block. I now realize that this model is incompatible with distributing execution onto multiple CPUs so I am wrong here? Though, in practice, does GHC actually does take advantage of multiple CPUs when they are available? Or do need GPH? forkOS is a very recent addition, BTW. Its primary purpose is to make a bound thread, to give the programmer a handle on which OS thread is used to make foreign calls. See this paper we submitted to the Haskell Workshop this year: http://www.haskell.org/~simonmar/papers/conc-ffi.ps.gz Hope that sheds some light. Ah. Very interesting. Thank you. -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
atomic MVar overwrite (was RE: [Haskell-cafe] How to use QSem?)
Ah, that worked. Thank you. The MVar documentation is also very brief. I would also like to overwrite the contents of an MVar atomically regardless of whether it is full or empty. I am current using. overWrite mvar val = tryTakeMVar mvar putMVar mvar val But it is not atomic :-( The lib functions (modifyMVar and tryPutMVar) are atomic but seem to require that you know in advance the MVar's state. Is there a solution to this or do I have to refactor? -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com On Wed, 23 Jun 2004, Simon Marlow wrote: On 22 June 2004 21:44, S. Alexander Jacobson wrote: The GHC documentation on QSem is very sparse. I would like to give a thread exclusive access to a resource. My *guess* based on the documentation is that I can create an exclusive lock using: logSem - newQSem 1 If the maximum value of your QSem is 1, then an MVar will do. That is, an MVar can be used as a simple semaphore, and a QSem is necessary if you need a quantity semaphore (there are 1 units of the resource). And then any thread that wants to lock the resource uses: withLogSem x = do waitQSem logSem; y - x; signalQSem logSem; return y as follows: withLogSem $ rotate curLogPos import Control.Concurrent, create the semaphore like this: m - newMVar () and use it like this: withMVar m $ \_ - ... critical section ... If you are using the semaphore to protect a mutable variable, then you can handily merge the two ideas into an MVar, which behaves like a thread-safe mutable variable. Cheers, Simon ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: atomic MVar overwrite (was RE: [Haskell-cafe] How to use QSem?)
Basically, what I want is a tryReadSampleVar function. Or, if we stick with MVars, I don't want another thread to operate between the tryTakeMVar and the putMVar. In particular, I don't want another thread to believe (mistakenly) that the mvar is empty when it is simply being updated. I suppose I could define a new abstraction where I have a second mvar that acts as an exclusive lock on the the first MVar. e.g. data XMVar a = XMVar (MVar ()) MVar a overWriteXMVar (XMVar lock mvar) val = withMVar lock (\_-tryTakeMVar mvar putMVar mvar val) tryTakeXMVar (XMVar lock mvar) val = withMVar lock (\_-tryTakeMVar mvar) But, I think it would be more sane simply to have a tryReadSampleVar somewhere. -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com On Wed, 23 Jun 2004, Simon Marlow wrote: On 23 June 2004 17:13, S. Alexander Jacobson wrote: Ah, that worked. Thank you. The MVar documentation is also very brief. I would also like to overwrite the contents of an MVar atomically regardless of whether it is full or empty. I am current using. overWrite mvar val = tryTakeMVar mvar putMVar mvar val But it is not atomic :-( The lib functions (modifyMVar and tryPutMVar) are atomic but seem to require that you know in advance the MVar's state. The question to ask here is atomic with respect to what?. modifyMVar is atomic only with respect to other threads performing modifyMVar-type operations on the MVar (i.e. take followed by put). If another thread is doing repeated puts into the MVar, then modifyMVar's atomicity is defeated. There isn't really a problem here, you just need to be sure that you use your MVars in a consistent way - you can always define a new abstraction that doesn't permit operations to be performed in the wrong order. So in order to tell you how to write your overWrite function, we need to know what other operations are being concurrently performed on the MVar, and what invariants you expect to hold. Cheers, Simon ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] How to use QSem?
The GHC documentation on QSem is very sparse. I would like to give a thread exclusive access to a resource. My *guess* based on the documentation is that I can create an exclusive lock using: logSem - newQSem 1 And then any thread that wants to lock the resource uses: withLogSem x = do waitQSem logSem; y - x; signalQSem logSem; return y as follows: withLogSem $ rotate curLogPos Am I misunderstanding QSem? -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] readEitherChan
I'd like a function that blocks until data is available on one of two channels and then returns that data wrapped in an Either. Here is my naive implementation: readEitherChan::Chan a - Chan b - Either a b readEitherChan a b = do var - newEmptyMVar forkIO (readChan a = putMVar var . Left) forkIO (readChan b = putMVar var . Right) val - readMVar return val eitherChan a b left right = readEitherChan a b = either left right But creating an MVar and starting two threads feels like a lot of overhead for a simple operation. Is there a better way or is forkIO so efficient that I shouldn't care? -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] forkIO preemption
When you forkIO and one of the threads blocks (e.g. on a socket or a readchan), do execution automatically resume on other threads and does the blocked thread consume timeslices while it is blocked? In other words, is there any performance penalty in setting timeslices very large in a server app (where all I care about is throughput)? -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Is it possible to read existential types?
I don't think this works. I just tried it with: main = print $ lookupRead 1 [(1,(Integer,100))] How would Haskell know that typ actually does equal typeOf? -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com On Wed, 28 Apr 2004, Chung-chieh Shan wrote: On 2004-04-28T15:12:03-0400, S. Alexander Jacobson wrote: Ok, but it sounds like you need to know the list of possible types in advance. Is it possible to have a lib take a filepath and type name as an arbitrary string, and read the instance in? I don't think you need to know the list of possible types in advance. Here is some (only slightly tested) code: import Data.Dynamic import Maybe import Monad lookupRead :: (Eq key, Read val, Typeable val) = key - [(key, (String, String))] - Maybe val lookupRead key list = ret where ret = case lookup key list of Just (typ, val) - if typ == show (typeOf (fromJust ret)) then case reads val of [(v,)] - Just v _- Nothing else Nothing _ - Nothing The question is how to get the result of lookupRead memoized, so that the call to reads happens at most once for each entry in the list. -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig BBC News: Universities face week of protest http://news.bbc.co.uk/1/hi/education/3508209.stm ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Is it possible to read existential types?
But isn't the point of this code that you don't need that type signature? If I knew in advance that it was an Integer then I wouldn't need to passs Integer in the list. -Alex- On Thu, 29 Apr 2004, Chung-chieh Shan wrote: On 2004-04-28T23:33:31-0400, S. Alexander Jacobson wrote: I don't think this works. I just tried it with: main = print $ lookupRead 1 [(1,(Integer,100))] This fails for the same reason print $ read 100 fails. You need to give a type signature to avoid type-class instance ambiguity: main = print $ (lookupRead 1 [(1,(Integer,100))] :: Maybe Integer) On GHCi 6.2.1, the above yields Just 100 for me. -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig Be it declared and enacted by this present Parliament / That the People of England / are / a Commonwealth and free State / without any King or House of Lords.-- An Act declaring England to be a Commonwealth 1649-05-19 | 355 years | 2004-05-19http://tinyurl.com/2dqnh _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Dynamics/Read and Existential types (was: Is it possible to read existential types?)
So let me ask this question a different way. Is it possible to use Read/Show or Typeable with Existential types. Given MyClass and MyType as follows: class (Read a,Show a,Typeable)=MyClass a where foo::a type MyType = forall a. MyClass a= [a] Is there a way to persist MyType? My suspicion is that there isn't because Haskell knows how to say that a string can't be parsed into a particular type but it does not know how to say that a string can't be parsed into any type that is an instance of a particular class. So, assuming you can't I amn curious to know know if this is an in-principle problem or just an in-fact problem. -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Is it possible to read existential types?
Ok, but it sounds like you need to know the list of possible types in advance. Is it possible to have a lib take a filepath and type name as an arbitrary string, and read the instance in? The context here is that I'm writing an App Server (tentative name: HAppS) that given an instance of: class (Eq state, Read state,Show state ,Eq request, Read request, Show request) = App state request response where startState::state execRequest::state- CallBack state - Chan a - ReqContext request - Result state response takes an arbitrary state, does write-ahead logging of any requests that change that state, and periodically saves the state to disk. If the computer dies or is shutdown for any reason, the last saved state is read-back from disk and the log is replayed until state is current, at which point, new requests may be processed. (Think Prevayler, but with side-effects and state saving handled properly -- thanks to Haskell's type system!) To use this lib, you do: main = (serveApp requestProducer filepaths)::YourAppInstance serveApp then attempts to read in the state from the filepaths and calls startState otherwise. The explicit type here coerces serveApp to read or startState the proper type (serveApp returns the state eventually). The problem is that the type of requestProducer is sort of complex (simplifying): type ReqProd=(((Respond, request) - IO ()) - IO t) type Respond response = response - IO () It is a function that takes a function that writes (respond,request) pairs to a channel and when run, calls that function periodically to interact with state. I find this is a bit hard to understand (and I just wrote the code!). I'd really like serveApp to return the writeChannel function and then have the client code call it. Then calling serveApp would look like: main = do queueReuest - serveApp filePaths YourAppInstance Even better, I'd love to have the same app be able to handle multiple request types (via existential types), but right now, thats not possible because I need to be able to (read) them. -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com On Mon, 26 Apr 2004, Chung-chieh Shan wrote: S. Alexander Jacobson [EMAIL PROTECTED] wrote in article [EMAIL PROTECTED] in gmane.comp.lang.haskell.cafe: Is is possible to read/show an existentially typed list? Would it be possible if, instead of using read/show, I defined some variant that relies on the typeof/typeable infrastructure? Is there a way to read in a typename for use in coercing a read? Dylan Thurston and I encountered this problem a while ago. Show is easy: just use a type like exists a. Show a = Read is hard, because one needs to get the Read dictionary from somewhere, and the dynamic typing facility in Haskell does not include type-class constraint reduction at runtime. The best solution we came up with was to replace the existentially typed list with a list of string-string pairs, where the first string names the type and the second string names the value. The call to read is only done at lookup time, not at file-reading time. -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig Be it declared and enacted by this present Parliament / That the People of England / are / a Commonwealth and free State / without any King or House of Lords.-- An Act declaring England to be a Commonwealth 1649-05-19 | 355 years | 2004-05-19http://tinyurl.com/2dqnh ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: sizeFM type
On Tue, 27 Apr 2004, Tomasz Zielonka wrote: On Mon, Apr 26, 2004 at 08:43:44PM -0400, [EMAIL PROTECTED] wrote: I would note, in addition, that they don't have that many pages indexed on a single machine. Almost nobody has a database with that many records on a single machine, even those who have clusters of 64 bit machines. It seems I qualify as almost nobody, cause I've had a database with more than 2^34 records on a single IA32 machine. However, I wouldn't ever think of loading the entire database to RAM. Why not? Its only 17gb. If you are doing any substantive volume of transactions on that database* you may be better off storing the database in memory than buying the multiple CPUs and reliable RAID arrays you need to serve it off disk. A Dell PowerEdge 4600 w/ 24gb of memory and a write-caching controller w/ 6 36GB harddrives (RAID0 state,logging,status) costs around $34k. http://www1.us.dell.com/content/products/compare.aspx/tower?c=uscs=555l=ens=biz Using e.g. a Prevayler style in memory logged data structures** you may be able to serve 100,000 queries/second. (see e.g. http://www.prevayler.org/wiki.jsp?topic=ScalabilityTestResults) To achieve just 500 queries/second using MaxDB (SAP-DB from MySQL) requires apparently 61!! App servers. (http://www.mysql.com/products/maxdb/benchmarks.html) Calculating the cost of this much hardware is left as an exercise for the reader, but, even ignoring the hardware costs here, you are also paying for rackspace and system administration to keep this many servers operating. -Alex- * OTOH, if this is just your personal mail archive then nevermind :- ) ** Finishing off a Haskell variant of this concept that also handles side-effects correctly right now. It is part II of the rdbms, appserver, web/mail server triad that I plan to use for a variety of different web apps. _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: sizeFM type
On Tue, 27 Apr 2004, Tomasz Zielonka wrote: The data you provided is interesting. However, if I had such a machine, my work could be much less challenging :) I would note that people today are making strenuous efforts to retain compatibility with a Haskell98 standard that it only 6 years old! If we are making choices intended to have a lifetime of e.g. 10 years (see http://www.joelonsoftware.com/articles/fog17.html), then I would observe that the 24gb machine I specced out will, assuming Moore's law lasts, cost only $2k in 5-6 years. The Sun Fire 15k with 288GB of memory and 72 Sparcs (think GPH!), that today costs $2.6m will cost only $155k. Note, since you don't need 72 CPUs, you'll probably be able to get this machine for $50k. So, perhaps the question here is: What is the planned lifetime of sizeFM? Do we prefer the safety of knowing our code will work at arbitrary scale or the ecstacy of having it run fast today? Put differently, would you rather cope with hardware limitations today or software limitations tomorrow? -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: sizeFM type
On Tue, 27 Apr 2004, Tomasz Zielonka wrote: The data you provided is interesting. However, if I had such a machine, my work could be much less challenging :) I would note that people today are making strenuous efforts to retain compatibility with a Haskell98 standard that it only 6 years old! If we are making choices intended to have a lifetime of e.g. 10 years (see http://www.joelonsoftware.com/articles/fog17.html), then I would observe that the 24gb machine I specced out will, assuming Moore's law lasts, cost only $2k in 5-6 years. The Sun Fire 15k with 288GB of memory and 72 Sparcs (think GPH!), that today costs $2.6m will cost only $155k. Note, since you don't need 72 CPUs, you'll probably be able to get this machine for $50k. So, perhaps the question here is: What is the planned lifetime of sizeFM? Do we prefer the safety of knowing our code will work at arbitrary scale or the ecstacy of having it run fast today? Put differently, would you rather cope with hardware limitations today or software limitations tomorrow? -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Is it possible to read existential types?
Is is possible to read/show an existentially typed list? Would it be possible if, instead of using read/show, I defined some variant that relies on the typeof/typeable infrastructure? Is there a way to read in a typename for use in coercing a read? -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] handling read exceptions
I mean catch the read exception without escaping all the way out to the IO monad. -Alex- On Mon, 12 Apr 2004, S. Alexander Jacobson wrote: I want to read strings that look like 2 or hello into values of type Integer or String. The problem is that read requires that strings be read as \hello\. Is there a way either to convince read to not require wrapping quotation marks or, alternetively, to catch a read exception, and do something sane? -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] handling read exceptions
My point is that I am reading in name/value pairs and once I know the name, I know the type of the value, but I don't want to have to pass that information programatically to the point in the code where I am doing the read. -Alex- On Mon, 12 Apr 2004, Sven Panne wrote: S. Alexander Jacobson wrote: I want to read strings that look like 2 or hello into values of type Integer or String. The problem is that read requires that strings be read as \hello\. Is there a way either to convince read to not require wrapping quotation marks or, alternetively, to catch a read exception, and do something sane? reads is probably what you are looking for: Prelude (reads :: ReadS Integer) [] Prelude (reads :: ReadS Integer) a [] Prelude (reads :: ReadS Integer) 2 [(2,)] Prelude (reads :: ReadS Integer) 123blah [(123,blah)] And reading a string the way you want is best done by id. :-) Cheers, S. _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Adding Ord constraint to instance Monad Set?
On Wed, 31 Mar 2004, Tomasz Zielonka wrote: You can try to define a different version of Monad using multiparameter type classes, something like: class M m a b where (=) :: m a - (a - m b) - m b I don't think this works. GHC can't deduce context for (). I don't understand why, but I've tried a variety of permutations of constraint declarations (m b needs to be a Monad as well...). -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What are Kind errors and how do you fix them?
I want to thank everybody for the kind explanations of kind errors. I think I now understand them (figured it out through a LOT of trial and error). The problem (as Carl and others noted) was I was testing various ways of doing things using synonyms rather than data types and didn't know that you can't do that! Based on my recent experience as a new coder, here are some words of advice for future beginners: * Beware the monomorphism restriction! * Avoid type synonyms in instance declarations! * use newtype whenever possible (also see quickcheck docs) * you can't use existential types except through class methods! * you must wrap existential types if you want to use them in record-style data declarations (No, I have no idea why this is, but it appears to be true nonetheless) The problem with this sort of list is that it is probably only useful after you have already made these mistakes. Oh well. -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Adding Ord constraint to instance Monad Set?
Following the declaration of instance Monad [] in the prelude, and puzzling over the absence of its equivalent from Data.Set, I naively typed: instance Monad Set where m = k = concatSets (mapSet k m) return x = unitSet x fail s = emptySet concatSets sets = foldl union emptySet (setToList sets) instance (Eq b,Ord b) = Ord (Set b) where compare set1 set2 = compare (setToList set1) (setToList set2) and got the following error: Could not deduce (Ord b) from the context (Monad Set) arising from use of `concatSets' at dbMeta3.hs:242 Probable fix: Add (Ord b) to the class or instance method `=' In the definition of `=': = m k = concatSets (mapSet k m) In the definition for method `=' In the instance declaration for `Monad Set' Since I obviously can't modify the class declaration for Monad, the question arises: How does one add (Orb b) to the instance method '='? (Aside: it be really nice if the error messages suggested textual changes or at least provide sample syntax in addition to the conceptual recommendation.) -Alex- PS I assume the reason that Set is not declared as a Monad in Data.Set is oversight rather than incompatibility PPS I want to thank everyone who has been taking the time to answer all of my questions. I'll try to collect my various learnings into a useful beginners page once I reach the point where I think I can create a useful document. _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What are Kind errors and how do you fix them?
Ok, I am still trying to understand kind errors and now have a very simple class and types: class MyClass a b where emptyVal::a b type MyType a = [a] type MyType2 = [] I can't figure out why some instance work and others don't. e.g. this one works: instance MyClass MyType2 a where emptyVal=[] But this one doesn't: instance MyClass (MyType a) a where emptyVal=[] and neither does this one: instance MyClass (MyType) a where emptyVal=[] How do I make (MyType a) work? For example, a real world example is: type MyType a = FiniteMap a String? -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com On Tue, 23 Mar 2004, Jon Fairbairn wrote: On 2004-03-23 at 16:58EST S. Alexander Jacobson wrote: Implementing Reverse from before, I am running into this weird error: type ReverseType a string = (string -(string,a)) data Reverse a string = Reverse (ReverseType a string) instance Monad (Reverse a s) where return x = Reverse (\text - (text,x)) (Reverse p) = k = Reverse p3 where p3 s0 = p2 s1 where (Reverse p2) = k a (s1,a)=p s0 Produces the error: Kind error: Expecting kind `* - *', but `Reverse a s' has kind `*' When checking kinds in `Monad (Reverse a s)' In the instance declaration for `Monad (Reverse a s)' I have no clue what this error message means. Kinds are to types what types are to values. You've declared Reverse to have two arguments: it takes a type, then another type and returns a type, so its kind is * - * - *. (Reverse a) has kind * - * and (Reverse a s) has kind *. Now a monad is something that takes a type as an argument, so has kind * - *, for example IO has kind * - * -- you expect to see IO Something most places. So (Reverse a) could perhaps be a monad, but (Reverse a s) cannot be. -- Jón Fairbairn [EMAIL PROTECTED] ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] haskell idiom for reversible computations
If I am writing a rener/parser for e.g. HTTP Requests and Responses, I would like to be able to guarantee that the parser really is the inverse of the generator. I assume that if I define a pair of computations as reversible then I can put those computations in some monad such that I can do: parse = inverse generate and parse2 = inverse do {generate;generate2} Actually, I assume this is an arrow rather than a monad because a render is a computation that takes a value and produces a value rather than simply a computation that produces a value. Whether its an arrow or not, I also assume this problem is sufficiently common that there is a well worked out idiom for this such that I don't have to hand-code and prove inverse functions for all my data structures. I just don't know what it is. -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What are Kind errors and how do you fix them?
So if I want to use Monad, I have to have Reverse only work with Strings and not some data type that might be a String? Is there a workaround that would allow me to preserve flexibility around the target datatype? Otherwise I'll rename Forward and Reverse to toString and fromString, but the notion of being able to guarantee a roundtrip in and out of an arbitrary datatype seems useful and powerful. -Alex- On Tue, 23 Mar 2004, Jon Fairbairn wrote: On 2004-03-23 at 16:58EST S. Alexander Jacobson wrote: Implementing Reverse from before, I am running into this weird error: type ReverseType a string = (string -(string,a)) data Reverse a string = Reverse (ReverseType a string) instance Monad (Reverse a s) where return x = Reverse (\text - (text,x)) (Reverse p) = k = Reverse p3 where p3 s0 = p2 s1 where (Reverse p2) = k a (s1,a)=p s0 Produces the error: Kind error: Expecting kind `* - *', but `Reverse a s' has kind `*' When checking kinds in `Monad (Reverse a s)' In the instance declaration for `Monad (Reverse a s)' I have no clue what this error message means. Kinds are to types what types are to values. You've declared Reverse to have two arguments: it takes a type, then another type and returns a type, so its kind is * - * - *. (Reverse a) has kind * - * and (Reverse a s) has kind *. Now a monad is something that takes a type as an argument, so has kind * - *, for example IO has kind * - * -- you expect to see IO Something most places. So (Reverse a) could perhaps be a monad, but (Reverse a s) cannot be. -- Jón Fairbairn [EMAIL PROTECTED] _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ????Pattern match(es) are overlapped???
I am implementing HTTP and I have something like: newtype Method = Method String getMethod = Method GET putMethod = Method PUT [...] doMeth getMethod = ... doMeth putMethod = ... GHC gives me a patter matches are overlapped warning. And when I run, I discover that pattern matching is not actually happening. getMethod is always executed even though the method passed is putMethod What am I doing wrong? -Alex- _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ????Pattern match(es) are overlapped???
I actually ended up using a lookup list e.g. handlers=[(getMethod,doGet),(putMethod,doPut)] which has the convenience of being able to put a 501 Not Implemented in an obvious place. I'll post the code shortly. My goal is to form the core of a generically useful HTTP haskell server library. -Alex- On Mon, 22 Mar 2004, Ketil Malde wrote: Arjan van IJzendoorn [EMAIL PROTECTED] writes: newtype Method = Method String getMethod = Method GET putMethod = Method PUT doMeth getMethod = ... doMeth putMethod = ... You will have to write: doMeth (Method GET) = ... doMeth (Method PUT) = ... Or (I assume, haven't tested) if you insist on renaming the methods: doMeth m | m == getMethod = ... | m == putMethod = ... (or using a case statement, of course) -kzm -- If I haven't seen further, it is by standing in the footprints of giants _ S. Alexander Jacobson mailto:[EMAIL PROTECTED] tel:917-770-6565 http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: haskell httpd
On Fri, 14 Nov 2003, Simon Marlow wrote: However, several people have found the web server useful and are using it, either as the basis of further research, or in some cases as the basis for a real production web server. So anyone out there still using it in production? -Alex- ___ S. Alexander Jacobson Check out my new blog!!! 1-212-787-1914 voice http://alexjacobson.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: newbie conceptual question [from haskell list]
Is the LDAP client available somewhere? -Alex- On 1 Aug 2001, Steinitz, Dominic J wrote: I don't know about functional dependencies but using an existential type turned out to be very useful in writing an LDAP protocol handler. The protocol is specified at an abstract level using ASN.1 and could, in theory, be encoded using any set of encoding rules. It happens to use the Basic Encoding Rules. We used an existential type to encode the protocol at an abstract level and the encoding rules take this type and produce a concrete representation ready to send over a transport mechanism. Thus we get a good separation between the abstract protocol and the concrete encoding. So the next time we implement a protocol handler we can re-use the encoding code or we could encode LDAP with a different set of encoding rules without having to touch the LDAP code itself. We are presenting a paper which includes this at the Scottish Functional Programming workshop. Dominic. [EMAIL PROTECTED] on 31/07/2001 22:29:00 To: franka cc: haskell-cafe bcc: Dominic Steinitz Subject: Re: newbie conceptual question [from haskell list] Hi, Frank Atanassow wrote: D. Tweed wrote: I've never written a Haskell program using functional dependencies, or existential classes, ... I find them indispensible, and I know for a fact that I am not the only one around our office who feels that way. Though, the people around here (Utrecht's software technology group) are not exactly typical programmers... :) I've been recently experimenting quite a bit with existential classes and somewhat less with functional dependencies, primarily to help my understanding of the concepts. However, I've yet to be able to think of an appropriate place to use them in the real world. That is, in something more than a toy thought-experiment. Could you give some examples of what you are using them for? -- Hal Daume III Computer science is no more about computers| [EMAIL PROTECTED] than astronomy is about telescopes. -Dijkstra | www.isi.edu/~hdaume ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe - 21st century air travel http://www.britishairways.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe ___ S. Alexander Jacobson Shop.Com 1-646-638-2300 voiceThe Easiest Way To Shop (sm) ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Lambda Dance, Haskell polemic, etc. on O'Reilly site
Jerszy, Although I think Haskell is a beautiful language, Jelovic is right on his core points, Haskell implementations don't meet the needs of the working programmer. A user can download Python or Perl to his windows or linux computer, install, and very quickly be up and running writing code that calls system libraries, talks to mysql databases, retrieves XML content from the web and parses it, etc. Moreover, if the default libraries don't meet his/her needs, it is easy to find additional libraries on the web, and when found, there is a high likelyhood that they will work as advertised with the installed system. Contrast the above with Haskell, which doesn't immediately, easily and reliably install on all platforms (perhaps aside from Hugs), is still figuring out core language features,and does not even have a consistent set of libraries for simple stuff like filesystem access! There are, perhaps good reasons for all these failures, but please recognize them for what they are: failures to meet the needs of the working programmer who just wants to get something done (whether he/she lives in YU, FR, JP, or US) I would love to be using Haskell for day to day programming work but I can't at this time. Unless the community recognizes what is required and gets it done, I never will. -Alex- ___ S. Alexander Jacobson Shop.Com 1-646-638-2300 voiceThe Easiest Way To Shop (sm) On Fri, 30 Mar 2001, Jerzy Karczmarczuk wrote: Fritz K Ruehr wrote: ... The second link is a little polemic entitled "Why People Aren't Using Haskell", which I presume would be of interest to readers of this list (the author is Dejan Jelovic, whom I don't recognize as a regular contributor here): http://www.jelovic.com/articles/why_people_arent_using_haskell.htm If you didn't verify this site, forget it. There is NOTHING serious there. Over and over again the same silly song, by a person who - visibly - had never anything to do with functional languages, who thinks now about hiring some C and java programmers living in Belgrade, but who writes such silly, incompetent things as: And there is an air of staleness: where new versions of these other languages appear frequently, the Haskell community is offering you Hugs98. Delovic points out that some languages became "immensely" popular, as e.g. Ruby, and that Haskell is marginal. Hm. this extremely orthodox Japanese essence of O-O programming may have some practical merits, especially those which come from shameless borrowing from Eiffel, Sather, Clu and Common Lisp, but calling Haskell "marginal" or "obscure" informs us not what is Haskell, but who is Jelovic. He accuses the Haskell community of not providing libraries... == Perhaps there is *one* point worth mentioning: the necessity to publish papers about Haskell far from such journals as JFP or HOSC, but to try to reach DrDobbs etc. I would add: Software: Practice and experience, and journals on numerical software where one could show some non-trivial implementations of practical, numerical algorithms. Jerzy Karczmarczuk Caen, France PS. What is "hamster dance", anyway? ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe