Re: [Haskell-cafe] Coding conventions for Haskell?
Hi Johan, On Sat, Sep 25, 2010 at 01:44:07PM +0200, Johan Tibell wrote: Quite a few people follow my style guide http://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md which codifies the style used in Real World Haskell, bytestring, text, and a few other libraries. Thanks for sharing the link, it's quite helpful. It's just what I was looking for. One more thought: Do you also have some recommendations for formatting 'let ... in ...' expressions? Best regards, Petr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Coding conventions for Haskell?
I usually align the in under the let. On Sep 26, 2010 11:40 AM, Petr Pudlak d...@pudlak.name wrote: Hi Johan, On Sat, Sep 25, 2010 at 01:44:07PM +0200, Johan Tibell wrote: Quite a few people follow my style guide http://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md which codifies the style used in Real World Haskell, bytestring, text, and a few other libraries. Thanks for sharing the link, it's quite helpful. It's just what I was looking for. One more thought: Do you also have some recommendations for formatting 'let ... in ...' expressions? Best regards, Petr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Polymorphic record field?
I have an almost finished Haskell program and I discovered that I needed to change the type of one record field. The problem is that the new type is polymorphic. Being new to Haskell, I simply changed: data MyStruct = MyStruct {myField :: myType} to data MyStruct = MyStruct {myField :: MyTypeClass a = a} and then ended up in a maze of compiler messages about Rank N types and Inferred type is less polymorphic than expected. Upon Googling for this issue, I have discovered that Haskell records do not support polymorphic types and that there is a large literature about options to fix this. Although the literature is interesting, what I am looking for right now is a simple fix. I really don't want to have to rewrite all the many type and value references to MyStruct in my code. Is there a way to redefine the definition of MyStruct without changing any of my other code? If I have to change the way myField is accessed, I can handle that. What I don't really want to do is change the type signature of functions that take MyStruct parameters (of which there are many). Is this possible? What is the simplest way to do this? Kevin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Polymorphic record field?
How about: data MyStruct = forall a. MyTypeClass a = MyStruct {myField :: a} I haven't actually run that through the compiler, but it should work. For a real life example of this approach, look at SomeException[1]. Michael [1] http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Control-Exception.html#t%3ASomeException On Sun, Sep 26, 2010 at 12:51 PM, Kevin Jardine kevinjard...@gmail.com wrote: I have an almost finished Haskell program and I discovered that I needed to change the type of one record field. The problem is that the new type is polymorphic. Being new to Haskell, I simply changed: data MyStruct = MyStruct {myField :: myType} to data MyStruct = MyStruct {myField :: MyTypeClass a = a} and then ended up in a maze of compiler messages about Rank N types and Inferred type is less polymorphic than expected. Upon Googling for this issue, I have discovered that Haskell records do not support polymorphic types and that there is a large literature about options to fix this. Although the literature is interesting, what I am looking for right now is a simple fix. I really don't want to have to rewrite all the many type and value references to MyStruct in my code. Is there a way to redefine the definition of MyStruct without changing any of my other code? If I have to change the way myField is accessed, I can handle that. What I don't really want to do is change the type signature of functions that take MyStruct parameters (of which there are many). Is this possible? What is the simplest way to do this? Kevin ___ 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] Polymorphic record field?
On Sunday 26 September 2010 12:53:46, Michael Snoyman wrote: data MyStruct = forall a. MyTypeClass a = MyStruct {myField :: a} Note that that requires {-# LANGUAGE ExistentialQuantification #-} ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Polymorphic record field?
OK, thanks for this advice. The type definition compiles, but when I try to actually access myField, the compiler says: Cannot use record selector `myField' as a function due to escaped type variables Probable fix: use pattern-matching syntax instead So I took the hint and wrote a new pattern matching accessor function: getMyField (MyStruct value) = value and I get: Inferred type is less polymorphic than expected Quantified type variable `a' escapes When checking an existential match that binds value :: a Any further suggestions? On Sep 26, 1:09 pm, Daniel Fischer daniel.is.fisc...@web.de wrote: On Sunday 26 September 2010 12:53:46, Michael Snoyman wrote: data MyStruct = forall a. MyTypeClass a = MyStruct {myField :: a} Note that that requires {-# LANGUAGE ExistentialQuantification #-} ___ Haskell-Cafe mailing list haskell-c...@haskell.orghttp://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] Re: Polymorphic record field?
OK, I have a solution. Ugly, but it compiles. MyStruct actually has quite a few fields but I only need to access the polymorphic field 4 times. So for the functions that needed that I wrote: f myS@(MyStruct value _ _ _ ) and then could use value. I could then use the usual record accessors on myS to get the other (non-polymorphic) data. I guess that is what GHC was hinting at when it suggested pattern matching. That is, pattern matching could extract a value that no functions are apparently allowed to touch. All head spinning to me. Thanks for the (as always) fast and useful advice! Kevin On Sep 26, 2:00 pm, Kevin Jardine kevinjard...@gmail.com wrote: OK, thanks for this advice. The type definition compiles, but when I try to actually access myField, the compiler says: Cannot use record selector `myField' as a function due to escaped type variables Probable fix: use pattern-matching syntax instead So I took the hint and wrote a new pattern matching accessor function: getMyField (MyStruct value) = value and I get: Inferred type is less polymorphic than expected Quantified type variable `a' escapes When checking an existential match that binds value :: a Any further suggestions? On Sep 26, 1:09 pm, Daniel Fischer daniel.is.fisc...@web.de wrote: On Sunday 26 September 2010 12:53:46, Michael Snoyman wrote: data MyStruct = forall a. MyTypeClass a = MyStruct {myField :: a} Note that that requires {-# LANGUAGE ExistentialQuantification #-} ___ Haskell-Cafe mailing list haskell-c...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list haskell-c...@haskell.orghttp://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: Polymorphic record field?
On Sunday 26 September 2010 14:00:38, Kevin Jardine wrote: OK, thanks for this advice. The type definition compiles, but when I try to actually access myField, the compiler says: Cannot use record selector `myField' as a function due to escaped type variables Probable fix: use pattern-matching syntax instead So I took the hint and wrote a new pattern matching accessor function: getMyField (MyStruct value) = value and I get: Inferred type is less polymorphic than expected Quantified type variable `a' escapes When checking an existential match that binds value :: a Any further suggestions? Ah, yes, forgot about that. As GHC says, using getMyValue would let the quantified type variable escape, the type would be getMyValue :: exists a. MyStruct - a (not allowed in Haskell). You can only use myField per pattern matching foo :: MyStruct - whatever foo (MyStruct field) = methodOfMyTypeClass field On Sep 26, 1:09 pm, Daniel Fischer daniel.is.fisc...@web.de wrote: On Sunday 26 September 2010 12:53:46, Michael Snoyman wrote: data MyStruct = forall a. MyTypeClass a = MyStruct {myField :: a} Note that that requires {-# LANGUAGE ExistentialQuantification #-} ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Polymorphic record field?
How about f myS@(MyStruct { myField = value }) ? On Sun, Sep 26, 2010 at 2:14 PM, Kevin Jardine kevinjard...@gmail.com wrote: OK, I have a solution. Ugly, but it compiles. MyStruct actually has quite a few fields but I only need to access the polymorphic field 4 times. So for the functions that needed that I wrote: f myS@(MyStruct value _ _ _ ) and then could use value. I could then use the usual record accessors on myS to get the other (non-polymorphic) data. I guess that is what GHC was hinting at when it suggested pattern matching. That is, pattern matching could extract a value that no functions are apparently allowed to touch. All head spinning to me. Thanks for the (as always) fast and useful advice! Kevin On Sep 26, 2:00 pm, Kevin Jardine kevinjard...@gmail.com wrote: OK, thanks for this advice. The type definition compiles, but when I try to actually access myField, the compiler says: Cannot use record selector `myField' as a function due to escaped type variables Probable fix: use pattern-matching syntax instead So I took the hint and wrote a new pattern matching accessor function: getMyField (MyStruct value) = value and I get: Inferred type is less polymorphic than expected Quantified type variable `a' escapes When checking an existential match that binds value :: a Any further suggestions? On Sep 26, 1:09 pm, Daniel Fischer daniel.is.fisc...@web.de wrote: On Sunday 26 September 2010 12:53:46, Michael Snoyman wrote: data MyStruct = forall a. MyTypeClass a = MyStruct {myField :: a} Note that that requires {-# LANGUAGE ExistentialQuantification #-} ___ Haskell-Cafe mailing list haskell-c...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list haskell-c...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Polymorphic record field?
Hi Michael, Yes, that does compile! Much less ugly and does not expose the internal bits of MyStruct. Thanks. Kevin On Sep 26, 2:26 pm, Michael Snoyman mich...@snoyman.com wrote: How about f myS@(MyStruct { myField = value }) ? On Sun, Sep 26, 2010 at 2:14 PM, Kevin Jardine kevinjard...@gmail.com wrote: OK, I have a solution. Ugly, but it compiles. MyStruct actually has quite a few fields but I only need to access the polymorphic field 4 times. So for the functions that needed that I wrote: f myS@(MyStruct value _ _ _ ) and then could use value. I could then use the usual record accessors on myS to get the other (non-polymorphic) data. I guess that is what GHC was hinting at when it suggested pattern matching. That is, pattern matching could extract a value that no functions are apparently allowed to touch. All head spinning to me. Thanks for the (as always) fast and useful advice! Kevin On Sep 26, 2:00 pm, Kevin Jardine kevinjard...@gmail.com wrote: OK, thanks for this advice. The type definition compiles, but when I try to actually access myField, the compiler says: Cannot use record selector `myField' as a function due to escaped type variables Probable fix: use pattern-matching syntax instead So I took the hint and wrote a new pattern matching accessor function: getMyField (MyStruct value) = value and I get: Inferred type is less polymorphic than expected Quantified type variable `a' escapes When checking an existential match that binds value :: a Any further suggestions? On Sep 26, 1:09 pm, Daniel Fischer daniel.is.fisc...@web.de wrote: On Sunday 26 September 2010 12:53:46, Michael Snoyman wrote: data MyStruct = forall a. MyTypeClass a = MyStruct {myField :: a} Note that that requires {-# LANGUAGE ExistentialQuantification #-} ___ Haskell-Cafe mailing list haskell-c...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list haskell-c...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list haskell-c...@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list haskell-c...@haskell.orghttp://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] Help to create a function to calculate a n element moving average ??
Type signature would be Int - [Double] - [(Double,Double)] Any thoughts or ideas on how to calculate a n-element moving average of a list of Doubles? Let's say [1..10]::[Double] what is the function to calculate the average of the 3 elements? [(1,0),(2,0),(3,2),(4,3)] :: [(Double,Double)] (1,0) the average is zero as the length is less than 3 (2,0) the average is zero as the length is less than 3 (3,2) the average is (1+2+3)/3 = 2 (4,3) the average is (2+3+4)/3 = 9 .. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Coding conventions for Haskell?
On Sun, 2010-09-26 at 11:40 +0200, Petr Pudlak wrote: Hi Johan, On Sat, Sep 25, 2010 at 01:44:07PM +0200, Johan Tibell wrote: Quite a few people follow my style guide http://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md which codifies the style used in Real World Haskell, bytestring, text, and a few other libraries. Thanks for sharing the link, it's quite helpful. It's just what I was looking for. One more thought: Do you also have some recommendations for formatting 'let ... in ...' expressions? Best regards, Petr I use it in following way; 1. For short sharing name (rarely) let a = b ++ c in (a, a) 2. Default let a :: [Int] a = b ++ c f :: Int - String f 0 = f x = show x in map f a Regards signature.asc Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Coding conventions for Haskell?
On Sat, 2010-09-25 at 13:44 +0200, Johan Tibell wrote: On Sat, Sep 25, 2010 at 11:24 AM, Petr Pudlak d...@pudlak.name wrote: sometimes I have doubts how to structure my Haskell code - where to break lines, how much to indent, how to name functions and variables etc. Are there any suggested/recommended coding conventions? I searched a bit and I found a few articles and discussions: Quite a few people follow my style guide http://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md which codifies the style used in Real World Haskell, bytestring, text, and a few other libraries. -- Johan May I ask clarification about formatting (according to your convention) doSomething :: (a - a - a) - a - a - a doSomething f x = f y y where y = f x x i.e. single line function+where Regards signature.asc Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Coding conventions for Haskell?
Petr Pudlak schrieb: sometimes I have doubts how to structure my Haskell code - where to break lines, how much to indent, how to name functions and variables etc. Are there any suggested/recommended coding conventions? Coding conventions are often a matter of individual taste. You may find some suggestions under http://www.haskell.org/haskellwiki/Category:Style and choose the ones that you like. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Help to create a function to calculate a n element moving average ??
2010/9/26 rgowka1 rgow...@gmail.com: Type signature would be Int - [Double] - [(Double,Double)] Any thoughts or ideas on how to calculate a n-element moving average of a list of Doubles? Let's say [1..10]::[Double] what is the function to calculate the average of the 3 elements? [(1,0),(2,0),(3,2),(4,3)] :: [(Double,Double)] (1,0) the average is zero as the length is less than 3 (2,0) the average is zero as the length is less than 3 (3,2) the average is (1+2+3)/3 = 2 (4,3) the average is (2+3+4)/3 = 9 movingAverage n xs = map (/n) $ sums n xs sums 1 xs = xs sums n xx@(x:xs) = zipWith (+) xx (sums (n-1) xs) Tests: *Main movingAverage 1 [1..10] [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0] *Main movingAverage 2 [1..10] [1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5] *Main movingAverage 3 [1..10] [2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0] *Main movingAverage 4 [1..10] [2.5,3.5,4.5,5.5,6.5,7.5,8.5] Is it right? ;) It is more interesting to create movingAverage in CPS/iteratees style. That way you'll have solid interface with IO world and you can freely alternate between reading moving averages and waiting for another ticket. No magic usafeInterleaveIO, hGetContents, etc, will be required. I did this once for my friend's pet project in Erlang, we jointly developed a whole library of operators over time series - sums, averages, etc. It is simple and fun. ;) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: ieee version 0.7
Patrick Perry schrieb: Changes since the last release: * Add IEEE type class with instances for Double, Float, CDouble, and CFloat What about architectures, where Float and Double are not in IEEE format? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Web application framework comparison?
There are 179 packages in the Web category on Hackage. It am finding it difficult, as someone who is not familiar with any of the Haskell web application frameworks on Hackage (and there seem to be at least 9), to determine which are good quality, which do things I would like a web framework to do for me, and which insist on doing things I would rather do myself. Is there a page comparing the major frameworks somewhere? I've been unable to find one via Google. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] capture of idioms and patterns
I haven't read this thread completely, but if someone else hasn't beaten me to it, there are *lots* of Haskell idioms spelled out on the Haskell Wiki [1] cleverly hidden under the category Style. -deech [1] http://www.haskell.org/haskellwiki/Category:Style On Fri, Sep 24, 2010 at 5:24 PM, Vo Minh Thu not...@gmail.com wrote: 2010/9/24 Albert Y. C. Lai tre...@vex.net: On 10-09-23 04:57 PM, Andrew Coppin wrote: If you think that sounds silly, ask some random person (not a computer programmer, just some random human) how find the sum of a list of numbers. My reply: to sum 10 numbers, sum 9 numbers, then account for the 10th. More at: http://groups.google.com/group/comp.lang.functional/msg/51df24fbf33b7059 Ask some random person how to find page 314 in a book. No one replies check the 1st page, check the 2nd page, check the 3rd page In fact, no one replies in words. Almost everyone shows you how to cut to the middle or the estimated weighted middle (if the book seems to have 1000 pages, they cut near the one-third point), then say oh, before this or oh, after this, repeat. Almost everyone divides and conquers. Almost everyone recurses. I am not a computer programmer. (I know that someone is bound to think, when confronted with the problem of summing numbers, some people think, 'I know, I will divide and conquer'. Now they have two problems of summing numbers.) A computer scientist knows how to count the stars in the sky: simply count half of them then multiply by two. -- or something like that. ___ 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] A model theory question
Hi, Below is an assumption (which could be wrong) and two questions. ASSUMPTION 1 Only smaller models can be specified using the sub-class mechanism. For example if we directly make a subclass A = B then every instance of B must also be an instance of A (B implies A or B is a subset of A). Hence, type classes cannot be combined using sub-classing to provide specifications of bigger models. QUESTIONS 1) If assumption 1 is correct, is there a mechanism whereby the module system can be used to construct bigger models? 2) If there is such a mechanism does it involve type classes or is it a module only solution? Regards, Pat This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A model theory question
On 09/26/2010 01:32 PM, Patrick Browne wrote: Hi, Below is an assumption (which could be wrong) and two questions. ASSUMPTION 1 Only smaller models can be specified using the sub-class mechanism. For example if we directly make a subclass A = B then every instance of B must also be an instance of A (B implies A or B is a subset of A). Hence, type classes cannot be combined using sub-classing to provide specifications of bigger models. I'm not sure what you mean by models and subclass mechanism. For example, any set is a model of the first order logic. Presumably, we can subclass (i.e., add axioms to) from FOL into Peano Arithmetic. That cuts down on models that satisfy the axioms from any set to... well, the models of arithmetic (that is, the natural numbers, the class of ordinals less than the first uncountable ordinal, etc). A finite set is a model of FOL. But no finite set is a model of PA. QUESTIONS 1) If assumption 1 is correct, is there a mechanism whereby the module system can be used to construct bigger models? Bigger how? Under logical implication and its computational analogue? That is to say, do you want the model to be more SPECIFIC, describing a smaller class of objects more richly (i.e, with more logical implications to be made) or do you want the model to be more GENERAL, and contain the less specific submodels? This is how forcing works. 2) If there is such a mechanism does it involve type classes or is it a module only solution? Regards, Pat This message has been scanned for content and viruses by the DIT Information Services E-Mail Scanning Service, and is believed to be clean. http://www.dit.ie ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: Utrecht Haskell Compiler (UHC), version 1.1.0
John, UHC cannot compile itself: some of the used libraries use non-Haskell98 features still absent in UHC (e.g. functional dependencies). Runtime system comparison depends on what topic you want to compare on, otherwise UHC's runtime system just corresponds to what UHC supports, and thus obviously lacks what GHC does support and UHC does not (e.g. parallelism related features). regards, On 24 Sep, 2010, at 19:36 , John Van Enk wrote: Can UHC self-host yet? How does the runtime compare to GHC's? I suppose I could just go look... :) On Wed, Sep 22, 2010 at 10:30 AM, Atze Dijkstra a...@cs.uu.nl wrote: Utrecht Haskell Compiler -- second release 1.1.0 The UHC team is happy to announce the second public release of the Utrecht Haskell Compiler (UHC). UHC supports almost allmost all Haskell98 and Haskell2010 features plus some experimental extensions. The compiler runs on MacOSX, Windows (cygwin), and various Unix flavors. This second release has the following highlights relative to the previous first release: * Supports most of the Haskell2010 features. * Generic deriving [1]. * UHC knows about packages, and Cabal version 1.9.3 and later have basic support for UHC, so that Cabal can be used to build UHC packages. * For the default backend libraries are provided until including package haskell98. * The runtime system is no longer dependent on Boehm garbage collector, but uses UHCs own, a swap space collector allowing parameterization with backend specifics. * More programs from the nofib test suite compile and run. * Many smaller and larger problems fixed. For more info see http://www.cs.uu.nl/wiki/UHC Getting started Download -- UHC is available for download as source distribution via the UHC home page: http://www.cs.uu.nl/wiki/UHC Here you will also find instructions to get started and the specifics of what UHC can and cannot do. Status of the implementation Over the past year much effort by many people has been put into improving UHC, in particular to make it compile and run more library modules and test programs. Although the UHC project is very much work in progress overall reliability has improved, bugs have been fixed, and some Hackage packages compile. Warning --- Although we think that the compiler is stable enough to compile substantial Haskell programs, we do not recommend yet to use it for any serious development work in Haskell. We ourselves use the GHC as a development platform! We think however that it provides a great platform for experimenting with language implementations, language extensions, etc. Mailing lists - For UHC users and developers respectively: http://mail.cs.uu.nl/mailman/listinfo/uhc-users http://mail.cs.uu.nl/mailman/listinfo/uhc-developers Bug reporting - Please report bugs at: http://code.google.com/p/uhc/issues/list The UHC Team [1] Jose Pedro Magalhaes, Atze Dijkstra, Johan Jeuring, and Andres Loeh. A generic deriving mechanism for Haskell. http://dreixel.net/research/pdf/gdmh_draft.pdf (see Section 7.1 for the discussion on constrained datatypes) - Atze - Atze Dijkstra, Department of Information and Computing Sciences. /|\ Utrecht University, PO Box 80089, 3508 TB Utrecht, Netherlands. / | \ Tel.: +31-30-2534118/1454 | WWW : http://www.cs.uu.nl/~atze . /--| \ Fax : +31-30-2513971 | Email: a...@cs.uu.nl / |___\ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe - Atze - Atze Dijkstra, Department of Information and Computing Sciences. /|\ Utrecht University, PO Box 80089, 3508 TB Utrecht, Netherlands. / | \ Tel.: +31-30-2534118/1454 | WWW : http://www.cs.uu.nl/~atze . /--| \ Fax : +31-30-2513971 | Email: a...@cs.uu.nl / |___\ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Coding conventions for Haskell?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 9/25/10 11:06 , Donn Cave wrote: Though it's common practice for sure, maybe universal, does the Don't insert a space after a lambda rule make sense? I found it confusing at first sight, because of course it looks More to the point, some editors find it confusing. - -- brandon s. allbery [linux,solaris,freebsd,perl] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.10 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkyf4AIACgkQIn7hlCsL25XhtQCgnm9XsAGq6lmJkZCg5U1Of6hK Xb0AoJyqoVU9lI6QOJPQ6729NmS4kNvS =8eeh -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: Atom 1.0.7
Announcing Atom 1.0.7 http://hackage.haskell.org/package/atom/ Recent changes include: atom 1.0.6: Support for math.h expressions (contributed by Sebastian Niller) atom 1.0.7: Support for using a HW clock to control the duration of phases. The patch to atom 1.0.7 adds the ability to use your HW to control precisely the duration of phases. Previously, this would have to be done using ad-hoc C code. For example, on an AVR microprocessor[1], I might call compile[2] with compile name defaults { cCode = prePostCode , hardwareClock = Just defaultClock { clockName = millis , clockType = Word32 , delta = 50 , delay = delay , err = Just error } } atomFn to have phases of 50 milliseconds each, calling the user-defined error() C function if that bound is violated. See Code.hs[2] for documentation. It'll generate code that looks something like the following: void main_atom_loop() { __global_clock = millis(); ... Scheduled Atom functions ... // In the following we sample the hardware clock, waiting for the next phase. uint32_t const __phase_len = 30; uint32_t const __max = 255; uint32_t __curr_time = millis(); // An error check for when the phase has already expired. // The first disjunct is for when the current time has not overflowed, // and the second for when it has. if ( ( (__curr_time = __global_clock) (__curr_time - __global_clock __phase_len)) || ( (__curr_time __global_clock) ((__max - __global_clock) + __curr_time __phase_len))) { error(); } __curr_time = millis(); // Update the current time. // Wait until the phase has expired. If the current time hasn't // overflowed, execute the first branch; otherwise, the second. if (__curr_time = __global_clock) { delay(__phase_len - (__curr_time - __global_clock)); } else { delay(__phase_len - (__curr_time + (__max - __global_clock))); } } Suggestions, bug reports, improvements welcomed. Regards, Lee [1] http://www.nongnu.org/avr-libc/ [2] http://hackage.haskell.org/packages/archive/atom/1.0.7/doc/html/Language-Atom-Compile.html [3] http://hackage.haskell.org/packages/archive/atom/1.0.7/doc/html/Language-Atom-Code.html -- http://www.galois.com http://www.cs.indiana.edu/~lepike/ Phone: +1 503.808.7185 Fax: +1 503.350.0833 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Coding conventions for Haskell?
On Sun, Sep 26, 2010 at 12:31 PM, Maciej Piechotka uzytkown...@gmail.com wrote: May I ask clarification about formatting (according to your convention) doSomething :: (a - a - a) - a - a - a doSomething f x = f y y where y = f x x I always put 2 spaces before the where clause. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Coding conventions for Haskell?
On Sun, Sep 26, 2010 at 12:50 PM, Henning Thielemann schlepp...@henning-thielemann.de wrote: Coding conventions are often a matter of individual taste. You may find some suggestions under http://www.haskell.org/haskellwiki/Category:Style and choose the ones that you like. Absolutely. However, having a consistent style, whatever it might be, does bring some benefits and hence there are style guides. :) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Coding conventions for Haskell?
On Sep 27, 2010, at 5:31 AM, Maciej Piechotka wrote: May I ask clarification about formatting (according to your convention) doSomething :: (a - a - a) - a - a - a doSomething f x = f y y where y = f x x i.e. single line function+where There is a meta-rule that I use for indentation in a wide range of languages: where the line breaks are may depend on identifier spelling, but what the indentation is should not. In Haskell I sometimes violate that, but I usually end up regretting it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Coding conventions for Haskell?
On 09/25/2010 02:24 AM, Petr Pudlak wrote: Hi, sometimes I have doubts how to structure my Haskell code - where to break lines, how much to indent, how to name functions and variables etc. Are there any suggested/recommended coding conventions? I searched a bit and I found a few articles and discussions: I used a modified version of the best practices described by the Perl people for Perl code. Like things go under like things is the most important rule to follow. This rule, in other words, is a convention to make your code as tabular as possible. Also, most expressions have an outermost connective. I tend to align them: Consider: data Foo a b = Fooa | Bar b | Foobar a b That's not so nice looking now, but consider what happens when you have four or five arguments: type Label = String type Address = String data Foo a b = Foo (Maybe Label) Address a | Bar Label b | Foobar Label Address a b This is rather neat. Instead of focusing effort on parsing the source, we can merely compare lines for the differences in logic they embody. Compare it with an un-normalized definition: data Foo a b = Foo (Maybe Label) Address a | Bar Label b | Foobar Label Address a b Quick, which one of those has a b in it? Moreover, it make editing/refactoring easier with tools like Vim (with its visual block mode) and TextMate. I'm sure Emacs, etc have block editing modes too. To that end, I try to keep in the style of this style. For let-in pairs, I do: expression a = let exp = blah_blah a exp' = blah_blah' a in (exp ++ exp') I usually keep parentheses aligned as well, if a pair won't fit in a line. That's one of the more obvious consequences of my convention. Monadic operators are worth keeping together, for similar reasons as keeping parentheses aligned. action = first = second = third -- :fits on one line -- Steps added: action = first = second = third = fourth = fifth You can jump into do notation pretty easily from there, by deleting the = operators, and sticking a 'do' before first. Remember to treat values, functions, and monadic actions as servers that respond to your requests. This is the easiest way to maximize the value of Haskell's laziness. Also, and finally, remember that a function is a special kind of join on data types. (A many-to-one join, in terms of the relational algebra as spoken of by database people). My approach makes it easy to abstract operators out of the act of reading. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Coding conventions for Haskell?
Quoth Alexander Solla a...@2piix.com, ... That's not so nice looking now, but consider what happens when you have four or five arguments: type Label = String type Address = String data Foo a b = Foo (Maybe Label) Address a | Bar Label b | Foobar Label Address a b This is rather neat. Instead of focusing effort on parsing the source, we can merely compare lines for the differences in logic they embody. Note that it depends on a mono-spaced font. Works as intended in my terminal emulator window, and anywhere you or I have gone to the trouble, but my initial look at it was in my email, which as usual is a proportional font, and nothing lines up after the first column. Donn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] WANTED: Haskell web developer for two Yesod projects
Hi all, I have been working on two projects for a client, but will not be able to continue on them. I am currently looking for someone interested in some freelance work maintaining and adding features to two Yesod web applications. Please contact me if interested. Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe