Beginners Digest, Vol 54, Issue 48
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Value access in lambda function (Emanuel Koczwara) -- Message: 1 Date: Sat, 29 Dec 2012 15:26:43 +0100 From: Emanuel Koczwara poc...@emanuelkoczwara.pl Subject: Re: [Haskell-beginners] Value access in lambda function To: Divam dfordi...@gmail.com Cc: beginners@haskell.org Message-ID: 1356791203.2514.38.camel@emanuel-Dell-System-Vostro-3750 Content-Type: text/plain; charset=UTF-8 Hi, Brandon, I need to study this again, still dont understood how its related to partial function application. Take a look at: http://learnyouahaskell.com/higher-order-functions#lambdas addThree :: (Num a) = a - a - a - a addThree x y z = x + y + z can be defined as: addThree :: (Num a) = a - a - a - a addThree = \x - \y - \z - x + y + z and with brackets it would be: addThree = \x - (\y - (\z - (x + y + z))) Now, you just need to put brackets to see what's going on there (i've simplified your code for clarity): t v = Just v ? \v1 - Just (v + 1) ? \v2 - Just (v + v1 + v2) This would be (it actually is!): t v = Just v ? \v1 - (Just (v + 1) ? \v2 - (Just (v + v1 + v2) ) ) Now, if you will put braces in wrong place: t v = Just v ? (\v1 - Just (v + 1)) ? (\v2 - Just (v + v1 + v2)) Then you will get: Not in scope: `v1' Also consider this: in Haskell, a function is a binding like any other. If you couldn't refer to bindings from outer scopes, you couldn't define new functions! Well, aside from anonymous ones/lambdas, which are useful but somewhat limiting if you can't name and reuse them. Brandon, This is quite strange thing, the functions can access the globally defined variables and therefore there output is dependent not just on inputs but on those variables too. This goes against the understanding of pure functions. These 'global expressions' do not change during execution, output is dependent only on input, and function could be defined in terms of arguments and some 'constants' ('global expressions') and other functions (also 'global expressions' (there is no difference). Emanuel -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 54, Issue 48 *
Beginners Digest, Vol 54, Issue 49
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. ghc and android (Nathan H?sken) 2. Re: ghc and android (Kim-Ee Yeoh) 3. Re: ghc and android (Brandon Allbery) -- Message: 1 Date: Sun, 30 Dec 2012 14:19:32 +0100 From: Nathan H?sken nathan.hues...@posteo.de Subject: [Haskell-beginners] ghc and android To: beginners@haskell.org beginners@haskell.org Message-ID: 50e03f64.3080...@posteo.de Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hey, I know, this question has been asked in the past and there is a lot information one can find in the net. But in all of this information, I can not find definite answers for this. Is it currently possible to build haskell programs for android using the android NDK? If course, I know, bindings have to be written and android GUIs have to be written in Java. But if I would write the bindings for the things I need...? Via C/gcc? Its not the fastest, but should work, should it not? Via llvm? If not, what is the problem in doing this? Thank you! Nathan -- Message: 2 Date: Sun, 30 Dec 2012 21:36:07 +0700 From: Kim-Ee Yeoh k...@atamo.com Subject: Re: [Haskell-beginners] ghc and android To: Nathan H?sken nathan.hues...@posteo.de Cc: beginners@haskell.org beginners@haskell.org Message-ID: CAPY+ZdSG+607unMmzpDw2btsh3W=7+pccmjb8wzxylsfdus...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Nathan, it's better to redirect such questions to haskell-cafe. I've seen people DIY'ing various mobile/ARM projects there. Suffice to say, that's way out of beginner territory, unfortunately. -- Kim-Ee On Sun, Dec 30, 2012 at 8:19 PM, Nathan H?sken nathan.hues...@posteo.dewrote: Hey, I know, this question has been asked in the past and there is a lot information one can find in the net. But in all of this information, I can not find definite answers for this. Is it currently possible to build haskell programs for android using the android NDK? If course, I know, bindings have to be written and android GUIs have to be written in Java. But if I would write the bindings for the things I need...? Via C/gcc? Its not the fastest, but should work, should it not? Via llvm? If not, what is the problem in doing this? Thank you! Nathan __**_ Beginners mailing list Beginners@haskell.org http://www.haskell.org/**mailman/listinfo/beginnershttp://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20121230/2a4b2a22/attachment-0001.htm -- Message: 3 Date: Sun, 30 Dec 2012 09:43:47 -0500 From: Brandon Allbery allber...@gmail.com Subject: Re: [Haskell-beginners] ghc and android To: Nathan H?sken nathan.hues...@posteo.de Cc: beginners@haskell.org beginners@haskell.org Message-ID: cakfcl4xatf23zyzfl1hix5+hy-xcua5rwadrhg10ovofzrx...@mail.gmail.com Content-Type: text/plain; charset=utf-8 On Sun, Dec 30, 2012 at 8:19 AM, Nathan H?sken nathan.hues...@posteo.dewrote: Is it currently possible to build haskell programs for android using the android NDK? If course, I know, bindings have to be written and android GUIs have to be written in Java. But if I would write the bindings for the things I need...? GUIs can be written without requiring Java/Dalvik, at least on the more recent versions of Android. It's the basic runtime support that is still a bit lacking, last I checked. Via C/gcc? Its not the fastest, but should work, should it not? It's nonexistent for ARM; to get a working -fvia-C you have to go back to ghc versions that don't have any clue about ARM (if you want to scare yourself, check out via-C's Evil Mangler sometime). And I think the hosted build isn't working at the moment? Via llvm? I believe this is how current ARM development is doing it, rather than try to code up a native code generation backend. (I also get the impression that the NCGs are going to be deprecated in favor of -fllvm at some point, although they want to clean up some lingering optimization issues first; llvm wins for many things but does somewhat poorly for a few.) An additional issue: ghci (and Template Haskell because it uses the bytecode interpreter of ghci internally) currently(?) requires its own custom linker instead of being able to use the system linker. Said linker has no support
Beginners Digest, Vol 55, Issue 2
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: string - bytestring (Iustin Pop) 2. Re: string - bytestring (Mateusz Kowalczyk) 3. Re: string - bytestring (Christopher Howard) 4. Re: string - bytestring (Daniel Fischer) -- Message: 1 Date: Tue, 1 Jan 2013 13:03:44 +0100 From: Iustin Pop iu...@k1024.org Subject: Re: [Haskell-beginners] string - bytestring To: Christopher Howard christopher.how...@frigidcode.com Cc: Haskell Beginners beginners@haskell.org Message-ID: 20130101120344.ga29...@teal.hq.k1024.org Content-Type: text/plain; charset=us-ascii On Tue, Jan 01, 2013 at 01:53:44AM -0900, Christopher Howard wrote: Hi. I'm trying to use pcre-light in a small text-manip app. However, the module seems to want the incoming text data as a ByteString, whereas I in my child-like naivety am taking the data from stdin as Strings. After searching around, I tried using the fromString function from Data.ByteString.UTF8 to convert from String to ByteString; but all I get is: code: Couldn't match expected type `ByteString' with actual type `bytestring-0.9.2.1:Data.ByteString.Internal.ByteString' So I'm not sure what to do. Is it a mismatch between strict and lazy bytestrings? iustin -- Message: 2 Date: Tue, 01 Jan 2013 13:31:50 + From: Mateusz Kowalczyk fuuze...@fuuzetsu.co.uk Subject: Re: [Haskell-beginners] string - bytestring To: beginners@haskell.org Message-ID: 50e2e546.6050...@fuuzetsu.co.uk Content-Type: text/plain; charset=ISO-8859-1; format=flowed See the answer to http://stackoverflow.com/questions/12576817/couldnt-match-expected-type-with-actual-type-error-when-using-codec-bmp In the future, provide a small code snippet as well so that anyone helping can easily point out where you're messing up. On 01/01/13 12:03, Iustin Pop wrote: On Tue, Jan 01, 2013 at 01:53:44AM -0900, Christopher Howard wrote: Hi. I'm trying to use pcre-light in a small text-manip app. However, the module seems to want the incoming text data as a ByteString, whereas I in my child-like naivety am taking the data from stdin as Strings. After searching around, I tried using the fromString function from Data.ByteString.UTF8 to convert from String to ByteString; but all I get is: code: Couldn't match expected type `ByteString' with actual type `bytestring-0.9.2.1:Data.ByteString.Internal.ByteString' So I'm not sure what to do. Is it a mismatch between strict and lazy bytestrings? iustin ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- Message: 3 Date: Tue, 1 Jan 2013 11:41:45 -0900 From: Christopher Howard christopher.how...@frigidcode.com Subject: Re: [Haskell-beginners] string - bytestring To: beginners@haskell.org Message-ID: 50e342cc.1090...@frigidcode.com Content-Type: text/plain; charset=iso-8859-1 On 01/01/2013 04:31 AM, Mateusz Kowalczyk wrote: See the answer to http://stackoverflow.com/questions/12576817/couldnt-match-expected-type-with-actual-type-error-when-using-codec-bmp In the future, provide a small code snippet as well so that anyone helping can easily point out where you're messing up. On 01/01/13 12:03, Iustin Pop wrote: ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners With some more research, I figured it out: The problem was, it seems, that 8 bit ByteStrings are not the same as UTF8 ByteStrings. So I used the pack function from Data.ByteString.Char8, and this compiles fine. -- frigidcode.com -- next part -- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 553 bytes Desc: OpenPGP digital signature URL: http://www.haskell.org/pipermail/beginners/attachments/20130101/b6bdbb95/attachment-0001.pgp -- Message: 4 Date: Tue, 01 Jan 2013 22:01:25 +0100 From: Daniel Fischer daniel.is.fisc...@googlemail.com Subject: Re: [Haskell-beginners] string - bytestring To: beginners@haskell.org Message-ID: 6287139.tjwe9jl...@linux-v7dw.site Content-Type: text/plain; charset=us-ascii On Dienstag, 1. Januar 2013, 11:41:45, Christopher Howard wrote: With some more research, I figured it out: The problem was, it seems, that 8 bit ByteStrings are
Beginners Digest, Vol 55, Issue 3
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Machine Learning/ANN's in Haskell. (Jack Hunt) 2. Re: Machine Learning/ANN's in Haskell. (Erik de Castro Lopo) 3. Re: Machine Learning/ANN's in Haskell. (Ertugrul S?ylemez) 4. Re: Machine Learning/ANN's in Haskell. (Krzysztof Skrz?tnicki) -- Message: 1 Date: Wed, 02 Jan 2013 13:50:03 + From: Jack Hunt jackmilesh...@gmail.com Subject: [Haskell-beginners] Machine Learning/ANN's in Haskell. To: beginners@haskell.org Message-ID: 50e43b0b.8060...@gmail.com Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hi all, I have been interested in Haskell for a long time now, and am definitely going to invest a considerable amount of time into learning it. Next year is the final year of my CS degree, and I am set on having a final year project orientated around ML. Now, my question is this:- What are the advantages/disadvantages of using Haskell for such a project? Bearing in mind of course that I am an absolute beginner. Regards, Jack Hunt -- Message: 2 Date: Thu, 3 Jan 2013 06:58:39 +1100 From: Erik de Castro Lopo mle...@mega-nerd.com Subject: Re: [Haskell-beginners] Machine Learning/ANN's in Haskell. To: beginners@haskell.org Message-ID: 20130103065839.d958283bfcfac8ebb7983...@mega-nerd.com Content-Type: text/plain; charset=US-ASCII Jack Hunt wrote: Hi all, I have been interested in Haskell for a long time now, and am definitely going to invest a considerable amount of time into learning it. Next year is the final year of my CS degree, and I am set on having a final year project orientated around ML. Now, my question is this:- What are the advantages/disadvantages of using Haskell for such a project? Bearing in mind of course that I am an absolute beginner. Advantages? Well compiled Haskell code is faster than Python which seems to be a commonly used language in this field. Erik -- -- Erik de Castro Lopo http://www.mega-nerd.com/ -- Message: 3 Date: Wed, 2 Jan 2013 23:20:03 +0100 From: Ertugrul S?ylemez e...@ertes.de Subject: Re: [Haskell-beginners] Machine Learning/ANN's in Haskell. To: beginners@haskell.org Message-ID: 20130102232003.3c8cf...@tritium.streitmacht.eu Content-Type: text/plain; charset=us-ascii Jack Hunt jackmilesh...@gmail.com wrote: I have been interested in Haskell for a long time now, and am definitely going to invest a considerable amount of time into learning it. Next year is the final year of my CS degree, and I am set on having a final year project orientated around ML. Now, my question is this:- What are the advantages/disadvantages of using Haskell for such a project? Bearing in mind of course that I am an absolute beginner. My experience with using Haskell as a language for neural networks is very positive. The code is unusually short and mostly works right away. It is also much faster than the more common languages like Python and Common Lisp. I have uploaded one of my neural network implementations [1] to Hackage. It shows you how to exploit lazy vectors for expressing the most important algorithms, including querying the network and backpropagation learning. [1]: http://hackage.haskell.org/package/instinct Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -- next part -- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: http://www.haskell.org/pipermail/beginners/attachments/20130102/c4d54538/attachment-0001.pgp -- Message: 4 Date: Thu, 3 Jan 2013 10:09:58 +0100 From: Krzysztof Skrz?tnicki gte...@gmail.com Subject: Re: [Haskell-beginners] Machine Learning/ANN's in Haskell. To: Jack Hunt jackmilesh...@gmail.com Cc: beginners beginners@haskell.org Message-ID: CAM7aEVGhqaJPLXGN63m9LPATH5JYKG79CcHdYtW=gcqc9qw...@mail.gmail.com Content-Type: text/plain; charset=utf-8 I think that very important question is: whether you will find all the libraries you will need for your project or are you willing to fill the gaps? Haskell is a very fine language if you consider writing anything in it. But when it comes to libraries you may find out that what you are after is missing. For example, I wanted to
Beginners Digest, Vol 55, Issue 4
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Game of Life try ( ???) 2. Re: Game of Life try (Mateusz Kowalczyk) 3. Re: Game of Life try (Darren Grant) 4. Re: Game of Life try (KC) -- Message: 1 Date: Fri, 4 Jan 2013 22:41:36 +0200 From: ??? emanuela.moll...@gmail.com Subject: [Haskell-beginners] Game of Life try To: beginners@haskell.org Message-ID: CANUoYf2tESAKByVu=5qb9nv5-mzcbcaray-c4ggt1oap4n3...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Hello all! :) I'm new to Haskell and I would like to try to implement a simple version of Game of Life. I can imagine it in C++ for example, but I have a little difficulties in Haskell. All I can think for is a mutable array with all elements - 0 in the beginning and the user to be able to write in the coordinates of the cells, which are alive and this cells to become 1. Then to iterate through the array (but I'm not sure if I can iterate, there is no 'while' here) and to make the changes (but maybe I will need a new array for the changes, because when the first change happens, it will affect the result). Also I was thinking of how to make it visible, so I tried to make all 0-s red and all 1-s green, and after each iteration to clear the screen with ANSI so that it looks a bit like animation, but none of these ideas work... Here is an orientation in my ideas: import Data.Array.IO import System.Console.ANSI main :: IO () main = do arr - newArray ((1,1), (10,10)) 0 :: IO (IOArray (Int, Int) Int) writeAraay arr (1,1) 1 a - readArray (1,1) setSGR [SetColor Foreground Dull Red] putStr [a] Could you please suggest me what is a good place to store the information about my cells (mutable, unmutable array, lists, tuples...) and any ideas and tutorials at all would be really appreciated! Thank you very much in advance! :) -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130104/c61c2c14/attachment-0001.htm -- Message: 2 Date: Fri, 04 Jan 2013 23:21:23 + From: Mateusz Kowalczyk fuuze...@fuuzetsu.co.uk Subject: Re: [Haskell-beginners] Game of Life try To: beginners@haskell.org Message-ID: 50e763f3.8030...@fuuzetsu.co.uk Content-Type: text/plain; charset=utf-8; Format=flowed I recommend that you read a guide/tutorial/book on Haskell first, before you try to implement this. Having a very limited knowledge about the language will only provide frustration when your solution doesn't work when you try to approach it naively, trying to use methods from a very different language. A widely recommended book is Learn You A Haskell [1]. After reading it, it should become fairly obvious how to approach your problem as well as how to solve it. You'll soon realise that there's simply no need for things such as `while' or a mutable array. To just hint towards what you might want is a function that takes a list (or list of lists, whatever your representation may be)) and returns a list with the next generation. You can then use any of the graphics libraries (or just print ASCII) to visualise the transformation. Again, this will be a lot easier when you actually study the basic language concepts first, instead of diving head-in and trying to hammer C++ into Haskell. [1] http://learnyouahaskell.com/ Mateusz Kowalczyk Oops, forgot to CC the mailing list. On 04/01/13 20:41, ??? wrote: Hello all! :) I'm new to Haskell and I would like to try to implement a simple version of Game of Life. I can imagine it in C++ for example, but I have a little difficulties in Haskell. All I can think for is a mutable array with all elements - 0 in the beginning and the user to be able to write in the coordinates of the cells, which are alive and this cells to become 1. Then to iterate through the array (but I'm not sure if I can iterate, there is no 'while' here) and to make the changes (but maybe I will need a new array for the changes, because when the first change happens, it will affect the result). Also I was thinking of how to make it visible, so I tried to make all 0-s red and all 1-s green, and after each iteration to clear the screen with ANSI so that it looks a bit like animation, but none of these ideas work... Here is an orientation in my ideas: import Data.Array.IO http://Data.Array.IO import System.Console.ANSI
Beginners Digest, Vol 55, Issue 5
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Functional analysis and design (Martin Drautzburg) 2. Haskell connectTo problem (Alexander 0xAX) 3. Re: Haskell connectTo problem (Kim-Ee Yeoh) 4. Re: Functional analysis and design (Gianfranco Alongi) 5. Re: Haskell connectTo problem (Brandon Allbery) 6. Re: Functional analysis and design (Rustom Mody) -- Message: 1 Date: Sat, 5 Jan 2013 12:10:22 +0100 From: Martin Drautzburg martin.drautzb...@web.de Subject: [Haskell-beginners] Functional analysis and design To: Haskell Beginners beginners@haskell.org Message-ID: 201301051210.22888.martin.drautzb...@web.de Content-Type: Text/Plain; charset=us-ascii Hello all, often, when I read tutorials or lectures about haskell, I am absolutely intrigued by the solutions presented there. It often creates this aha effect and I think yes, this perfectly describes the problem to solve, this is what the problem IS. But alas, I have difficulties to come up with equally brilliant solutions for my own problems. As for learning haskell, I am now pretty comfortable with it, but I fail to apply it to real world problems. I am pretty good at semantic data modelling, but this technique gives me nothing but trouble, when I try to apply it in the functional world (while it works well in the OO world). What I am trying now it asking what do I want the system to compute in the first place and then think about how to implement these top-level functions. Do you think that this is a good way to start? Other than that I was trying to find some information about haskell as a specification language, but could not find anything. Is this a sensible idea at all? If not, how would you write a specification if not in haskell itself? So if you have any pointers on how to address a non-trivial problem in haskell, this would by much appreciated. -- Martin -- Message: 2 Date: Sat, 5 Jan 2013 19:25:16 +0600 From: Alexander 0xAX anotherworldofwo...@gmail.com Subject: [Haskell-beginners] Haskell connectTo problem To: beginners@haskell.org Message-ID: cafpzw88_h951eaxuhmqonawycv8eqhp8jotnz9rcpfegc+-...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Hello, I try to connect to host: connectTo httpbin.org (PortNumber 80) {handle: socket: 8} It's ok. But if i try to connect: connectTo httpbin.org/ip (PortNumber 80) *** Exception: getAddrInfo: does not exist (Name or service not known) Why i got this error? Thank you. -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130105/28e5dec3/attachment-0001.htm -- Message: 3 Date: Sat, 5 Jan 2013 21:10:37 +0700 From: Kim-Ee Yeoh k...@atamo.com Subject: Re: [Haskell-beginners] Haskell connectTo problem To: Alexander 0xAX anotherworldofwo...@gmail.com Cc: beginners@haskell.org beginners@haskell.org Message-ID: CAPY+ZdTB447j=x1di02rdeuvew2iujnizrfwxqry-rfa88p...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Not knowing anything about the package or the function, my guess is connectTo wants a domain name, not a URL, because it proceeds to do a DNS lookup on exactly that. You probably want a different function. There's something called simpleHTTP or thereabouts. -- Kim-Ee On Sat, Jan 5, 2013 at 8:25 PM, Alexander 0xAX anotherworldofwo...@gmail.com wrote: Hello, I try to connect to host: connectTo httpbin.org (PortNumber 80) {handle: socket: 8} It's ok. But if i try to connect: connectTo httpbin.org/ip (PortNumber 80) *** Exception: getAddrInfo: does not exist (Name or service not known) Why i got this error? Thank you. ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130105/261c28db/attachment-0001.htm -- Message: 4 Date: Sat, 5 Jan 2013 15:57:15 +0100 From: Gianfranco Alongi gianfranco.alo...@gmail.com Subject: Re: [Haskell-beginners] Functional analysis and design To: Martin Drautzburg martin.drautzb...@web.de Cc: Haskell Beginners beginners@haskell.org Message-ID: CALs9xayMfs0Wmw+67EzxhG10hwa4M=rmjvynsx3n-xbcpsg...@mail.gmail.com Content-Type: text/plain;
Beginners Digest, Vol 55, Issue 6
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Functional analysis and design (Martin Drautzburg) 2. Confused by the qualified imports (Libor Wagner) 3. Re: Confused by the qualified imports (David McBride) 4. Re: Confused by the qualified imports (Brandon Allbery) 5. Natural functions versus existential types (Darren Grant) -- Message: 1 Date: Sun, 6 Jan 2013 12:17:44 +0100 From: Martin Drautzburg martin.drautzb...@web.de Subject: Re: [Haskell-beginners] Functional analysis and design To: beginners@haskell.org Message-ID: 201301061217.45041.martin.drautzb...@web.de Content-Type: Text/Plain; charset=iso-8859-15 On Sunday, 6. January 2013 08:13:14 Rustom Mody wrote: A favourite example of mine: Today J S Bach is regarded as the pinnacle of western classical music. When he was a young man he spent much of his time just copying out 'the masters' Perfect analogy! You see, with music there is a set of rules which can be learned, because they are written down. But mastering these does not make you a good composer. When given the task write a tooth-paste jingle you would still not know where to start. But when you talk to a jingle writer, he could probably tell you his train of thoughts and you would be able to learn from him. Incidently I am interested in writing music too and I ran into the exact same problem as with haskell. Try to find information about how to write 3-4voice vocals, so it sounds like the Beach Boys, the BGs or Abba. Even though this wisdom is known to someone, it is impossible to find something which resembles a tutorial. Either this wisdom cannot be written down at all, or the masters prefer to keep their wisdom concealed. Copying the masters will certainly help, but it is a long and time-consuming process. I was hoping for ways to shorten it. -- Martin -- Message: 2 Date: Sun, 6 Jan 2013 17:30:50 +0100 From: Libor Wagner liborwag...@gmail.com Subject: [Haskell-beginners] Confused by the qualified imports To: beginners@haskell.org Message-ID: 88f0283390c24324a53acf918d0e3...@gmail.com Content-Type: text/plain; charset=utf-8 Hi, I was looking into Gloss examples for usage of Repa arrays. For example the Snow example (http://code.ouroborus.net/gloss/gloss-stable/gloss-examples/raster/Snow/Main.hs). What I do not get is that there is qualified import of the Repa package, but the Z and :. are used without the prefix. When I some times accidentally omit the prefix the ghc always yell at me. What em I missing? Thanks, Libor -- Message: 3 Date: Sun, 6 Jan 2013 12:00:03 -0500 From: David McBride toa...@gmail.com Subject: Re: [Haskell-beginners] Confused by the qualified imports To: Libor Wagner liborwag...@gmail.com Cc: beginners@haskell.org Message-ID: CAN+Tr43q_S0Fi_=d3ncroq-mlt+1ddfta7xbnypcwmgp3cy...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 If you use import qualified Data.Array.Repa as R then you have to specify R in front of every function, operator, or type. But if you use import Data.Array.Repa as R without the qualified keyword, then you only have to use it when it would be ambiguous which module your function or type comes from (ie. you had multiple modules imported without qualification). On Sun, Jan 6, 2013 at 11:30 AM, Libor Wagner liborwag...@gmail.com wrote: Hi, I was looking into Gloss examples for usage of Repa arrays. For example the Snow example ( http://code.ouroborus.net/gloss/gloss-stable/gloss-examples/raster/Snow/Main.hs). What I do not get is that there is qualified import of the Repa package, but the Z and :. are used without the prefix. When I some times accidentally omit the prefix the ghc always yell at me. What em I missing? Thanks, Libor ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130106/401f2570/attachment-0001.htm -- Message: 4 Date: Sun, 6 Jan 2013 12:01:53 -0500 From: Brandon Allbery allber...@gmail.com Subject: Re: [Haskell-beginners] Confused by the qualified imports To: Libor Wagner liborwag...@gmail.com Cc: beginners@haskell.org Message-ID:
Beginners Digest, Vol 55, Issue 7
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. stage restriction when using Data.Heap (Martin Drautzburg) 2. Re: stage restriction when using Data.Heap (Darren Grant) 3. Re: stage restriction when using Data.Heap (Twan van Laarhoven) -- Message: 1 Date: Tue, 8 Jan 2013 07:03:20 +0100 From: Martin Drautzburg martin.drautzb...@web.de Subject: [Haskell-beginners] stage restriction when using Data.Heap To: Haskell Beginners beginners@haskell.org Message-ID: 201301080703.20818.martin.drautzb...@web.de Content-Type: Text/Plain; charset=us-ascii When I :load this into ghci import Data.Heap heap = empty :: MinHeap (Int,String) insert (1,kjh) heap I get GHC stage restriction: `heap' is used in a top-level splice or annotation, and must be imported, not defined locally In the second argument of `insert', namely `heap' In the expression: insert (1, kjh) heap But when I type in import Data.Heap let heap = empty :: MinHeap (Int,String) insert (1,kjh) heap everything works and I get fromList [(1,kjh)] Why is that so and what can I do to prevent the stage restriction? -- Martin -- Message: 2 Date: Mon, 7 Jan 2013 22:40:58 -0800 From: Darren Grant therealklu...@gmail.com Subject: Re: [Haskell-beginners] stage restriction when using Data.Heap To: Martin Drautzburg martin.drautzb...@web.de Cc: Haskell Beginners beginners@haskell.org Message-ID: ca+jd6sgjyhrdjmezcvzip8hovumrtquinet7qmqhxo5e1fv...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 The GHC stage restriction is an error invoked when some Template Haskell [1] construct requires the evaluation of run-time values at compile time. I am going out on a limb and assuming that same code probably works in GHCI because the interpreter does not have a discrete compile-time phase. I assume that MinHeap is templated, but exactly how I do not know. Maybe someone who is more familiar with Data.Heap will have an answer. [1] http://www.haskell.org/haskellwiki/Template_Haskell On Mon, Jan 7, 2013 at 10:03 PM, Martin Drautzburg martin.drautzb...@web.de wrote: When I :load this into ghci import Data.Heap heap = empty :: MinHeap (Int,String) insert (1,kjh) heap I get GHC stage restriction: `heap' is used in a top-level splice or annotation, and must be imported, not defined locally In the second argument of `insert', namely `heap' In the expression: insert (1, kjh) heap But when I type in import Data.Heap let heap = empty :: MinHeap (Int,String) insert (1,kjh) heap everything works and I get fromList [(1,kjh)] Why is that so and what can I do to prevent the stage restriction? -- Martin ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130107/c9e9ef02/attachment-0001.htm -- Message: 3 Date: Tue, 08 Jan 2013 11:22:40 +0100 From: Twan van Laarhoven twa...@gmail.com Subject: Re: [Haskell-beginners] stage restriction when using Data.Heap To: beginners@haskell.org Message-ID: 50ebf370.4090...@gmail.com Content-Type: text/plain; charset=UTF-8; format=flowed On 08/01/13 07:03, Martin Drautzburg wrote: import Data.Heap heap = empty :: MinHeap (Int,String) insert (1,kjh) heap Your error is in the last line. `insert (1,kjh) heap` is an expression, and in Haskell expressions can only occur inside (function) declarations. So you should instead write something like: heap = empty :: MinHeap (Int,String) heap2 = insert (1,kjh) heap In Ghci, expressions are evaluated and the result is printed, which is why you are able to use it there. Twan -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 55, Issue 7
Beginners Digest, Vol 55, Issue 8
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: stage restriction when using Data.Heap (Brent Yorgey) 2. Re: stage restriction when using Data.Heap (Daniel Fischer) 3. hsmagic core dump (Sergey Bushnyak) -- Message: 1 Date: Tue, 8 Jan 2013 12:02:45 -0500 From: Brent Yorgey byor...@seas.upenn.edu Subject: Re: [Haskell-beginners] stage restriction when using Data.Heap To: beginners@haskell.org Message-ID: 20130108170245.ga16...@seas.upenn.edu Content-Type: text/plain; charset=us-ascii On Tue, Jan 08, 2013 at 07:03:20AM +0100, Martin Drautzburg wrote: When I :load this into ghci import Data.Heap heap = empty :: MinHeap (Int,String) insert (1,kjh) heap I get GHC stage restriction: `heap' is used in a top-level splice or annotation, and must be imported, not defined locally In the second argument of `insert', namely `heap' In the expression: insert (1, kjh) heap But when I type in import Data.Heap let heap = empty :: MinHeap (Int,String) insert (1,kjh) heap everything works and I get fromList [(1,kjh)] Why is that so and what can I do to prevent the stage restriction? Twan's analysis is correct. But wow, that's a horrible error message. Do you by any chance have the TemplateHaskell extension enabled (either with {-# LANGUAGE TemplateHaskell #-} at the top or your file, or with :set -XTemplateHaskell in a .ghci file, or anything like that)? If not this should really be filed as a bug, GHC has no business giving TH-related error messages without TH being turned on. -Brent -- Message: 2 Date: Tue, 08 Jan 2013 18:40:27 +0100 From: Daniel Fischer daniel.is.fisc...@googlemail.com Subject: Re: [Haskell-beginners] stage restriction when using Data.Heap To: beginners@haskell.org Message-ID: 5933532.5hviumd...@linux-v7dw.site Content-Type: text/plain; charset=us-ascii On Tuesday 08 January 2013, 12:02:45, Brent Yorgey wrote: Twan's analysis is correct. But wow, that's a horrible error message. Do you by any chance have the TemplateHaskell extension enabled (either with {-# LANGUAGE TemplateHaskell #-} at the top or your file, or with :set -XTemplateHaskell in a .ghci file, or anything like that)? Must be: module Naked where start :: Int start = 13 start + 5 == $ ghci Naked GHCi, version 7.6.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. [1 of 1] Compiling Naked( Naked.hs, interpreted ) Naked.hs:6:1: Parse error: naked expression at top level Failed, modules loaded: none. == $ ghci -XTemplateHaskell Naked GHCi, version 7.6.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. [1 of 1] Compiling Naked( Naked.hs, interpreted ) Naked.hs:6:1: GHC stage restriction: `start' is used in a top-level splice or annotation, and must be imported, not defined locally In the first argument of `(+)', namely `start' In the expression: start + 5 Failed, modules loaded: none. The message without TH is clear and good. If not this should really be filed as a bug, GHC has no business giving TH-related error messages without TH being turned on. -Brent -- Message: 3 Date: Wed, 09 Jan 2013 11:51:20 +0200 From: Sergey Bushnyak sergey.bushn...@sigrlami.eu Subject: [Haskell-beginners] hsmagic core dump To: beginners@haskell.org beginners@haskell.org Message-ID: 50ed3d98.60...@sigrlami.eu Content-Type: text/plain; charset=ISO-8859-1; format=flowed Trying to work with images via hsmagic package, use something like this scaleTest :: FilePath - IO() scaleTest dst = do initializeMagick image - readImage dst let image' = scaleImage 450 450 image writeImage dst image' but get core dump, when compiling. Types are ok, and path are valid, can it be problem of os or I'm doing something wrong? -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 55, Issue 8
Beginners Digest, Vol 55, Issue 9
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: hsmagic core dump (Alexander Alexeev) 2. Is http://hackage.haskell.org/packages/hackage.html having a challenging serving up archive.tar? (KC) 3. Re: stage restriction when using Data.Heap (Martin Drautzburg) 4. Approach to resolve dependencies (Sergey Bushnyak) 5. Cabal problems (Abram Demski) 6. Re: Cabal problems (Sergey Bushnyak) 7. Re: Cabal problems (Brandon Allbery) -- Message: 1 Date: Wed, 09 Jan 2013 17:53:03 +0400 From: Alexander Alexeev m...@eax.me Subject: Re: [Haskell-beginners] hsmagic core dump To: beginners@haskell.org beginners@haskell.org Message-ID: 50ed763f.7030...@eax.me Content-Type: text/plain; charset=ISO-8859-1; format=flowed On 01/09/2013 01:51 PM, Sergey Bushnyak wrote: Trying to work with images via hsmagic package, use something like this scaleTest :: FilePath - IO() scaleTest dst = do initializeMagick image - readImage dst let image' = scaleImage 450 450 image writeImage dst image' but get core dump, when compiling. Types are ok, and path are valid, can it be problem of os or I'm doing something wrong? ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners Same problem here (Ubuntu 12.10, amd64, GHC 7.4.2). This package seems to be broken. -- Best regards, Alexander Alexeev http://eax.me/ -- Message: 2 Date: Wed, 9 Jan 2013 11:05:07 -0800 From: KC kc1...@gmail.com Subject: [Haskell-beginners] Is http://hackage.haskell.org/packages/hackage.html having a challenging serving up archive.tar? To: haskell-cafe haskell-c...@haskell.org,Haskell Beginners beginners@haskell.org Message-ID: CAMLKXy=OL=-cjhjce9b4aqqrodklv1funi5wirgm0dnywm6...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 :) -- -- Regards, KC -- Message: 3 Date: Wed, 9 Jan 2013 20:13:59 +0100 From: Martin Drautzburg martin.drautzb...@web.de Subject: Re: [Haskell-beginners] stage restriction when using Data.Heap To: beginners@haskell.org Message-ID: 201301092013.59752.martin.drautzb...@web.de Content-Type: Text/Plain; charset=iso-8859-1 Thanks guys -- Martin -- Message: 4 Date: Wed, 09 Jan 2013 23:08:12 +0200 From: Sergey Bushnyak sergey.bushn...@sigrlami.eu Subject: [Haskell-beginners] Approach to resolve dependencies To: beginners@haskell.org beginners@haskell.org Message-ID: 50eddc3c.4010...@sigrlami.eu Content-Type: text/plain; charset=ISO-8859-1; format=flowed Currently switched to ghc-7.6.1 and when I want to install new packages, they are broke others, because of use older versions. Observe this: $ cabal install fay Resolving dependencies... In order, the following would be installed: QuickCheck-2.5.1.1 (reinstall) ansi-terminal-0.5.5.1 (new package) ansi-wl-pprint-0.6.4 (new package) attoparsec-0.10.3.0 (reinstall) changes: containers-0.5.2.1 - 0.5.0.0 ... and others Things like in last row with containers repeats in a lot of packages, which with --reinstall key broke them. So, I wondering what is the easiest and proper way to install new packages with respect to old dependencies? -- Best regards, Sergey Bushnyak -- Message: 5 Date: Wed, 9 Jan 2013 17:02:53 -0800 From: Abram Demski abramdem...@gmail.com Subject: [Haskell-beginners] Cabal problems To: beginners@haskell.org Message-ID: cal8fc7zkq+g3tbdkbjmf5btfk4h16o1ctgvxcdimxjbumbm...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Hi all, I'm just trying to install some of the games from the game list (on the wiki) so that I have something to look at. I tried the ones which have cabal packages as I assumed that would be easy. Every one I tried so far has failed to install. Below are two of the quickest failures. Any comments are appreciated. Is there something I'm generally not getting? Or are there just various problems with installing possibly-old packages? abram@whitehead:~$ cabal install shu-thing Resolving dependencies... Configuring Shu-thing-1.1.1... Building Shu-thing-1.1.1... Preprocessing executable 'shu-thing' for Shu-thing-1.1.1... [1 of 1] Compiling Main ( Shu-thing.hs, dist/build/shu-thing/shu- thing-tmp/Main.o ) Shu-thing.hs:4:27: Module
Beginners Digest, Vol 55, Issue 10
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Cabal problems (Sergey Bushnyak) 2. Re: Cabal problems (Abram Demski) 3. Re: hsmagic core dump (alexander.vershi...@gmail.com) -- Message: 1 Date: Thu, 10 Jan 2013 07:12:40 +0200 From: Sergey Bushnyak sergey.bushn...@sigrlami.eu Subject: Re: [Haskell-beginners] Cabal problems Cc: beginners@haskell.org Message-ID: 50ee4dc8.3010...@sigrlami.eu Content-Type: text/plain; charset=utf-8; Format=flowed On 01/10/2013 06:48 AM, Brandon Allbery wrote: On Wed, Jan 9, 2013 at 11:37 PM, Sergey Bushnyak sergey.bushn...@sigrlami.eu mailto:sergey.bushn...@sigrlami.eu wrote: Shu-thing.hs:4:27: Module `Control.Exception' does not export `Exception(ExitException)' cabal: Error: some packages failed to install: Shu-thing-1.1.1 failed during the building phase. The exception was: ExitFailure 1 What version of ghc and cabal are you using? shu-thing builds on ghc-6.8 and failed on ghc-7.*. Package probably broken and need to be updated, due to changes in other packages. The other package that changed is base; it's still using old-style exceptions. I thought someone was going to package up old-exceptions and put it on hackage for backward compatibility, but I don't see it there. Same with the other package they tried to install. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com mailto:allber...@gmail.com ballb...@sinenomine.net mailto:ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net Isn't it better to send patch with corrections to maintainer? -- Best regards, Sergey Bushnyak -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130110/4ad91ac8/attachment-0001.htm -- Message: 2 Date: Wed, 9 Jan 2013 21:14:12 -0800 From: Abram Demski abramdem...@gmail.com Subject: Re: [Haskell-beginners] Cabal problems To: Sergey Bushnyak sergey.bushn...@sigrlami.eu Cc: beginners@haskell.org Message-ID: cal8fc7wxrkaw1cvt0zhcy3+1sdc-fnnluwfo-wb68e6zhxg...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Yea, I'm using a 7.* version... ok, thanks! On Wed, Jan 9, 2013 at 8:37 PM, Sergey Bushnyak sergey.bushn...@sigrlami.eu wrote: On 01/10/2013 03:02 AM, Abram Demski wrote: Hi all, I'm just trying to install some of the games from the game list (on the wiki) so that I have something to look at. I tried the ones which have cabal packages as I assumed that would be easy. Every one I tried so far has failed to install. Below are two of the quickest failures. Any comments are appreciated. Is there something I'm generally not getting? Or are there just various problems with installing possibly-old packages? abram@whitehead:~$ cabal install shu-thing Resolving dependencies... Configuring Shu-thing-1.1.1... Building Shu-thing-1.1.1... Preprocessing executable 'shu-thing' for Shu-thing-1.1.1... [1 of 1] Compiling Main ( Shu-thing.hs, dist/build/shu-thing/shu- thing-tmp/Main.o ) Shu-thing.hs:4:27: Module `Control.Exception' does not export `Exception(ExitException)' cabal: Error: some packages failed to install: Shu-thing-1.1.1 failed during the building phase. The exception was: ExitFailure 1 === abram@whitehead:~$ cabal install spaceInvaders Resolving dependencies... Configuring HGL-3.2.0.0... Building HGL-3.2.0.0... Preprocessing library HGL-3.2.0.0... [ 1 of 27] Compiling Graphics.HGL.Internals.Flag ( Graphics/HGL/Internals/Flag. hs, dist/build/Graphics/HGL/Internals/Flag.o ) [ 2 of 27] Compiling Graphics.HGL.Internals.Utilities ( Graphics/HGL/Internals/Utilities.hs, dist/build/Graphics/HGL/Internals/Utilities.o ) Graphics/HGL/Internals/Utilities.hs:33:31: Expecting one more argument to `E.Exception' In the type signature for `safeTry': safeTry :: IO a - IO (Either E.Exception a) cabal: Error: some packages failed to install: HGL-3.2.0.0 failed during the building phase. The exception was: ExitFailure 1 -- Abram Demski http://lo-tho.blogspot.com/ ___ Beginners mailing listBeginners@haskell.orghttp://www.haskell.org/mailman/listinfo/beginners What version of ghc and cabal are you using? shu-thing builds on ghc-6.8 and failed
Beginners Digest, Vol 55, Issue 11
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Cabal problems (Brandon Allbery) 2. Re: Cabal problems (Sergey Bushnyak) 3. A Week in and Clueless (Philip Cote) 4. Re: A Week in and Clueless (Alexander O'Neill) 5. Re: A Week in and Clueless (Jay Sulzberger) 6. Re: A Week in and Clueless (Mateusz Kowalczyk) -- Message: 1 Date: Thu, 10 Jan 2013 09:37:43 -0500 From: Brandon Allbery allber...@gmail.com Subject: Re: [Haskell-beginners] Cabal problems To: Sergey Bushnyak sergey.bushn...@sigrlami.eu Cc: beginners@haskell.org Message-ID: cakfcl4vu7xscmyy49lya+odkqh_ea-bhmssft4ydgwgezst...@mail.gmail.com Content-Type: text/plain; charset=utf-8 On Thu, Jan 10, 2013 at 12:12 AM, Sergey Bushnyak sergey.bushn...@sigrlami.eu wrote: Isn't it better to send patch with corrections to maintainer? It is, but if the packages haven't been updated for new-style exceptions by now, they're probably effectively unmaintained. Do you want to take over maintainership? -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130110/28ce1c51/attachment-0001.htm -- Message: 2 Date: Thu, 10 Jan 2013 23:40:22 +0200 From: Sergey Bushnyak sergey.bushn...@sigrlami.eu Subject: Re: [Haskell-beginners] Cabal problems To: Brandon Allbery allber...@gmail.com Cc: beginners@haskell.org Message-ID: 50ef3546.3050...@sigrlami.eu Content-Type: text/plain; charset=utf-8; Format=flowed On 01/10/2013 04:37 PM, Brandon Allbery wrote: On Thu, Jan 10, 2013 at 12:12 AM, Sergey Bushnyak sergey.bushn...@sigrlami.eu mailto:sergey.bushn...@sigrlami.eu wrote: Isn't it better to send patch with corrections to maintainer? It is, but if the packages haven't been updated for new-style exceptions by now, they're probably effectively unmaintained. Do you want to take over maintainership? -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com mailto:allber...@gmail.com ballb...@sinenomine.net mailto:ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net I don't want to take over maintainership, area of my interest is slightly different and not covering games at all. Recently, I stumbled at this kind of problem by myself. I wrote to maintainer, submit patch and it's work now for new ghc. The thing we should talk here, that cabal shouldn't even show package in install list, that don't builds on users current compiler. This information can be seen at hackage, but there still a lot of work is going on new hackage, which would be more accurate continuous integration portal. In this situation I always get sources and correct by myself. Maintainership policy is very controversial subject and discussed regularly in community. -- Best regards, Sergey Bushnyak -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130110/ae68b9aa/attachment-0001.htm -- Message: 3 Date: Thu, 10 Jan 2013 21:44:02 -0500 From: Philip Cote cote...@gmail.com Subject: [Haskell-beginners] A Week in and Clueless To: beginners@haskell.org Message-ID: caokmgisnu71jv+zzjcs5peoswjxdelyr9_zcb9denad6no7...@mail.gmail.com Content-Type: text/plain; charset=windows-1252 So a week into Haskell, I still seem to be not ?getting? it which is kind of weird in my case. I came in with knowledge of a lot of functional ideas from using them in Javascript and Python. Or at least I thought I knew them. 5 chapters into Learn You a Haskell, I admit it's not really sinking in for me even after typing in and running all the examples. I acknowledge that I don't know jack. Any ideas or exercises that might help me along? -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130110/668a7d0e/attachment-0001.htm -- Message: 4 Date: Thu, 10 Jan 2013 19:18:46 -0800 From: Alexander O'Neill alone...@gmail.com Subject: Re: [Haskell-beginners] A Week in and Clueless To: Philip Cote cote...@gmail.com,
Beginners Digest, Vol 55, Issue 12
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: A Week in and Clueless (Kim-Ee Yeoh) 2. Re: A Week in and Clueless (Ertugrul S?ylemez) 3. Re: A Week in and Clueless (KC) 4. Re: A Week in and Clueless (mukesh tiwari) -- Message: 1 Date: Fri, 11 Jan 2013 12:50:20 +0700 From: Kim-Ee Yeoh k...@atamo.com Subject: Re: [Haskell-beginners] A Week in and Clueless To: Philip Cote cote...@gmail.com Cc: beginners@haskell.org beginners@haskell.org Message-ID: CAPY+ZdQpKnkTUjy1v2e4MXo1PdddfyThZG7=o-bbypauacx...@mail.gmail.com Content-Type: text/plain; charset=windows-1252 Hey Philip, Could it be that if you get some feedback, whether from your peers or from an instructor, you'd overcome this block? Learning can be a lot more effective in a group. There's a ureddit course on haskell just announced here [1]. You may want to take a look at it. Whether during the course or after it's over, please provide feedback here! (Disclaimer: I'm not affiliated with it in any way. Just supporting the community, 's all.) [1] http://www.reddit.com/r/haskell/comments/169k67/im_teaching_an_introductory_12week_class_on/ -- Kim-Ee On Fri, Jan 11, 2013 at 9:44 AM, Philip Cote cote...@gmail.com wrote: So a week into Haskell, I still seem to be not ?getting? it which is kind of weird in my case. I came in with knowledge of a lot of functional ideas from using them in Javascript and Python. Or at least I thought I knew them. 5 chapters into Learn You a Haskell, I admit it's not really sinking in for me even after typing in and running all the examples. I acknowledge that I don't know jack. Any ideas or exercises that might help me along? ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130111/82b59090/attachment-0001.htm -- Message: 2 Date: Fri, 11 Jan 2013 07:23:45 +0100 From: Ertugrul S?ylemez e...@ertes.de Subject: Re: [Haskell-beginners] A Week in and Clueless To: beginners@haskell.org Message-ID: 20130111072345.3189f...@tritium.streitmacht.eu Content-Type: text/plain; charset=utf-8 Philip Cote cote...@gmail.com wrote: So a week into Haskell, I still seem to be not ?getting? it which is kind of weird in my case. I came in with knowledge of a lot of functional ideas from using them in Javascript and Python. Or at least I thought I knew them. 5 chapters into Learn You a Haskell, I admit it's not really sinking in for me even after typing in and running all the examples. I acknowledge that I don't know jack. This is going to be a somewhat long mail, in which I'm attempting to give you an introduction of my own. Be brave and read it. =) Well, despite popular belief JavaScript and Python are not anywhere near functional. JS just uses callbacks and passes them around through higher order functions, but that's just the regular event-handling imperative style. There is really nothing functional about that. Functional style in JS starts when you start using things like 'each' from jQuery, i.e. you're not just defining event handlers. You are actually passing /behavior/ to a function. This is basically what a functional language takes to its conclusion. You have an action (like putStrLn Hello world), and you want to perform it n times. Let me give this example in both JavaScript and Haskell: function timesHello(n) { while (n 0) { print(Hello world); n--; } } timesHello 0 = return () timesHello n = putStrLn Hello world nTimes (n - 1) But why should we be constrained to printing hello world? On the other hand, how could we abstract it? The complicated answer is to use a complicated OO solution, but functional programmers can do a lot better: function times(n, action) { while (n 0) { action(); n--; } } times 0 action = return () times n action = action times (n - 1) action Unfortunately JavaScript has quite a heavy syntax for anonymous functions, which makes this style a lot less useful: times(3, function() { print(Hello world); }); But in Haskell we can write this elegantly: 3 `times` putStrLn Hello world This is the very fundamental idea. Since Haskell
Beginners Digest, Vol 55, Issue 13
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Is http://hackage.haskell.org/packages/hackage.html having a challenging serving up archive.tar? (Henk-Jan van Tuyl) 2. Re: Game of Life try (KC) -- Message: 1 Date: Sat, 12 Jan 2013 00:04:39 +0100 From: Henk-Jan van Tuyl hjgt...@chello.nl Subject: Re: [Haskell-beginners] Is http://hackage.haskell.org/packages/hackage.html having a challenging serving up archive.tar? To: haskell-cafe haskell-c...@haskell.org, Haskell Beginners beginners@haskell.org, KC kc1...@gmail.com Message-ID: op.wqrrp1tepz0...@zen5.arnhem.chello.nl Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes On Wed, 09 Jan 2013 20:05:07 +0100, KC kc1...@gmail.com wrote: :) I can't download it either. Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming -- -- Message: 2 Date: Fri, 11 Jan 2013 17:19:31 -0800 From: KC kc1...@gmail.com Subject: Re: [Haskell-beginners] Game of Life try To: ??? emanuela.moll...@gmail.com Cc: beginners@haskell.org Message-ID: camlkxynxfj+c5a1k_yqbdubavkfgdjk1gti0sh-h9wfcrn2...@mail.gmail.com Content-Type: text/plain; charset=windows-1251 Thinking about Bird's handling of Sudoku; it may be efficiently possible to represent colonies as lists (or trees). Then one just has to consider the merging and splitting of colonies. Usually, all the space in a cell array is not used anyway. :) On Fri, Jan 4, 2013 at 11:27 PM, KC kc1...@gmail.com wrote: You might want to look at the chapter on Sudoku (and the whole book) in Pearls of Functional Algorithm Design by Richard Bird. On Fri, Jan 4, 2013 at 12:41 PM, ??? emanuela.moll...@gmail.com wrote: Hello all! :) I'm new to Haskell and I would like to try to implement a simple version of Game of Life. I can imagine it in C++ for example, but I have a little difficulties in Haskell. All I can think for is a mutable array with all elements - 0 in the beginning and the user to be able to write in the coordinates of the cells, which are alive and this cells to become 1. Then to iterate through the array (but I'm not sure if I can iterate, there is no 'while' here) and to make the changes (but maybe I will need a new array for the changes, because when the first change happens, it will affect the result). Also I was thinking of how to make it visible, so I tried to make all 0-s red and all 1-s green, and after each iteration to clear the screen with ANSI so that it looks a bit like animation, but none of these ideas work... Here is an orientation in my ideas: import Data.Array.IO import System.Console.ANSI main :: IO () main = do arr - newArray ((1,1), (10,10)) 0 :: IO (IOArray (Int, Int) Int) writeAraay arr (1,1) 1 a - readArray (1,1) setSGR [SetColor Foreground Dull Red] putStr [a] Could you please suggest me what is a good place to store the information about my cells (mutable, unmutable array, lists, tuples...) and any ideas and tutorials at all would be really appreciated! Thank you very much in advance! :) ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- -- Regards, KC -- -- Regards, KC -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 55, Issue 13 *
Beginners Digest, Vol 55, Issue 14
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Natural functions versus existential types (Darren Grant) 2. Re: Game of Life try (Darren Grant) 3. Re: Natural functions versus existential types (Brandon Allbery) 4. Re: Game of Life try (KC) 5. Re: Natural functions versus existential types (Darren Grant) -- Message: 1 Date: Sun, 13 Jan 2013 17:34:18 -0800 From: Darren Grant therealklu...@gmail.com Subject: Re: [Haskell-beginners] Natural functions versus existential types To: Aleksandar Dimitrov aleks.dimit...@gmail.com Cc: Haskell Beginners beginners@haskell.org Message-ID: CA+jD6Sj1b_W=+=pwdvqv5wa+zlbh+j4zhynbm+gzxktstax...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 On Wed, Jan 9, 2013 at 1:45 PM, Aleksandar Dimitrov aleks.dimit...@gmail.com wrote: On Sun, Jan 06, 2013 at 11:22:51PM -0800, Darren Grant wrote: I've seen some cases where Haskell examples dive into existential types instead of using natural higher order functions. For instance, the Existential type wiki page [1] section 2.2 proposes existentials as the solution to a heterogeneous list problem where a ray-tracer must evaluate a trace function for different types of objects. Is there a good reason for this, or is it just a case of prior language assumptions leading to unnatural code? Why could I not just make the list homogeneous by supplying a list of partially evaluated trace functions instead? I have never written a ray-tracer, so I don't know about the exact requirements, but depending on the code in question, partial evaluation might not be possible. Parametric types can only be instantiated with *one* specific type. A list [a] can only be either [Int] or [Bool], but not [Int,Bool] or so. [1] So whenever you'd like to have a collection of things that won't have the same type, but have a certain operation defined on them, existential types come in handy. A partial application only makes sense when you have a function of higher arity, but `hits` in the example on the Wiki has only one argument, namely the list. At some point, a *collection* of Renderables needs to pass by the function `hit`. This collection probably needs to be stored somewhere, presumably a list, that is then fed to `hits`. Of course, you might set up your types differently, so that everything that will need to pass by the function `hits` would also be of one certain type. You could, for example, instead of storing the heterogeneous Renderables in a list, just reduce the different shapes to a Renderable data type that contains the important fields. Then, whenever a geometric object gets created, a Rendereable also gets created, then stored in that list. But how *viable* that is, I don't know. My gut feeling says that it won't be viable at all. Consider the following: If I have a traceable data type like data Sphere, I can define it and a trace function as follows: data Sphere = Sphere { spherepos :: (Double,Double,Double), sphereradius :: Double } traceSphere :: Sphere - Ray - [Hit] Where Ray is self-explanatory and [Hit] is a resulting list of hits where ray intersects sphere. I can then define a list of traceable objects thus, [Ray - [Hit]] Which can also be thought of as, type Trace = Ray - [Hit] [Trace] Now I am able to define a homogeneous list [Trace] of partially applied functions like so, [traceSphere $ Sphere (0,0,0) 20, traceSphere $ Sphere (10,20,30) 40, traceBox $ Box (0,0,0) (10,10,10) -- where traceBox is also partially applied ] You see what I mean? This is very natural in Haskell. I'm sure there must be counter-examples, but I haven't the comprehension for these. What do you think? Sometimes I read an argument that existentials are required due to unknown constraints at compile time, but do not have an intuition for this situation yet. For instance, I read that IO requires existentials. Still working on that one. :) Where did you read that? The *definition* of the IO type does not use existentials [2]. But I'm not very familiar with the internals. You're right! I'm not sure what I saw, but I would guess that I conflated some application of IO with the definition. Cheers, Darren -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130113/dfbef124/attachment-0001.htm
Beginners Digest, Vol 55, Issue 15
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. How to represent a (running) network? (Martin Drautzburg) -- Message: 1 Date: Mon, 14 Jan 2013 21:51:29 +0100 From: Martin Drautzburg martin.drautzb...@web.de Subject: [Haskell-beginners] How to represent a (running) network? To: beginners@haskell.org Message-ID: 201301142151.29765.martin.drautzb...@web.de Content-Type: Text/Plain; charset=us-ascii Hello all, I am trying to implement a discrete event siumulation for a logistic network. To do this, I need a representation of the network as such and a way to express what each Process does when it gets alerted by an event. A Process has inputs and outputs which are again connected to outputs and inputs of other Processes. Establishing these connections constructs the network as such. But the Processes also need to do something. They need to take something from one of their inputs, so something with it and place something on one of their outputs. So I kind of have a dual usage for inputs and outputs: they play a role in the topology of the network and in the function which defines a process. How can I keep the two in sync? Is there a way prevent a Process from trying to use an output which does not exist? What would be a good way to represent a Network anyways? I believe the classic approach is a list of nodes and a list vertices. In the simulation I will frequently have to find the process of an input or output and to find the input connected to an output. The node/vertices implementation seems to require scanning lists, which could be slow once I have thousands of processes. Other than that any pointers to how to construct networks (which go beyond mere graphs) would be much appreciated. -- Martin -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 55, Issue 15 *
Beginners Digest, Vol 55, Issue 16
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. kind of path search (Olivier Scalbert) -- Message: 1 Date: Tue, 15 Jan 2013 21:30:27 +0100 From: Olivier Scalbert olivier.scalb...@algosyn.com Subject: [Haskell-beginners] kind of path search To: beginners@haskell.org Message-ID: 50f5bc63.8000...@algosyn.com Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hello, I am a beginner in Haskell and in functional programming. Here is the problem I want to solve with Haskell. I am sure that this fascinating language can do it Suppose I have N nodes: node1, node, ..., nodeN At each node I have a subset of values taken from [v1, v2, ..., vk]. For exemple: node1 : [v1, v3] node2 : [v2, V5, v6] node3 : [v2, v3] I have also a directed graph. From a value you can go to other values. v1 - v5 v1 - v6 v2 - v1 v2 - v2 v3 - v2 v6 - v2 Now, I want to get all the paths from node1, to nodeN, following the node values and the graph. node1.v1 - node2.v6 - node3.v2 is a path. node1.v3 - node2.v2 - node3.v2 is also a path. My problem size: N around 1000 and each node has 3 to 4 values taken from [1..10]. Thanks for your help !!! Olivier -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 55, Issue 16 *
Beginners Digest, Vol 55, Issue 17
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: How to represent a (running) network? (Dmitry Vyal) 2. Type Inference (Johannes Engels) 3. Type system for constructor preconditions (Bryan Vicknair) 4. Re: Type Inference (Johannes Engels) 5. Re: How to represent a (running) network? (C K Kashyap) 6. Re: Type system for constructor preconditions (Daniel Trstenjak) -- Message: 1 Date: Thu, 17 Jan 2013 00:11:34 +0400 From: Dmitry Vyal akam...@gmail.com Subject: Re: [Haskell-beginners] How to represent a (running) network? To: Martin Drautzburg martin.drautzb...@web.de Cc: beginners@haskell.org Message-ID: 50f70976@gmail.com Content-Type: text/plain; charset=ISO-8859-1; format=flowed On 01/15/2013 12:51 AM, Martin Drautzburg wrote: What would be a good way to represent a Network anyways? I believe the classic approach is a list of nodes and a list vertices. In the simulation I will frequently have to find the process of an input or output and to find the input connected to an output. The node/vertices implementation seems to require scanning lists, which could be slow once I have thousands of processes. Other than that any pointers to how to construct networks (which go beyond mere graphs) would be much appreciated. Hello Martin, I guess the exact way depends on what precisely you want to achieve. I'm thinking about two options, hope others will suggest more. Either you try to model it in a pure setting or you go into IO. In a former case you may try to make use of lazy streams, say function of type f :: [a] - [b] - [c] is basically your's processing unit which takes two inputs and produces one output. For example, this is an integrator: f1 xs ys = zipWith (+) xs ys summer xs = let ret = f1 xs ys ys = 0 : ret in ret Here you depend on mutually recursive bindings in order to form the loops, so you can't make a dynamic structures this way, I believe. Speaking about IO, you may either go the classic boring way by collecting all the outputs in some mutable data structure and updating them in a loop, or you may try to have some fun with GHC's green threads: import Control.Monad import Control.Concurrent import Control.Concurrent.MVar mkBinaryF f i1 i2 = do ret - newEmptyMVar let worker = do v1 - i1 v2 - i2 res - f v1 v2 putMVar ret res forkIO $ forever worker return (takeMVar ret) main = do inp2 - newMVar 0 out - mkBinaryF (\x y - return $ x + y) (getLine = return . read) (takeMVar inp2) forever $ do v - out putStrLn $ out: ++ show v putMVar inp2 v For a more theoretically backed approach I suggest you to look at CSP. http://www.cs.kent.ac.uk/projects/ofa/chp/ Best wishes, Dmitry -- Message: 2 Date: Wed, 16 Jan 2013 22:43:06 +0100 From: Johannes Engels johannes.eng...@hft-stuttgart.de Subject: [Haskell-beginners] Type Inference To: beginners@haskell.org Message-ID: 50f71eea.6040...@hft-stuttgart.de Content-Type: text/plain; charset=ISO-8859-15; format=flowed Hello, playing around with type classes, I came up with the idea to implement Matlab-like array slices by overloading the (!) - Operator. My first try goes {-# LANGUAGE MultiParamTypeClasses , FunctionalDependencies , FlexibleContexts , FlexibleInstances #-} import Data.Array.Unboxed hiding ((!)) import qualified Data.Array.Unboxed as AU class Sliceable arrtype indtype resulttype | arrtype indtype - resulttype where (!) :: arrtype - indtype - resulttype instance (Ix i, IArray UArray e) = Sliceable (UArray i e) i e where (!) = (AU.!) instance (Ix i, IArray UArray e) = Sliceable (UArray i e) [i] (UArray Int e) where (!) arr ilist = listArray (0,end_ind) [(AU.!) arr i | i - ilist] where end_ind = length ilist - 1 In principle this seems to work, for instance ghci let arr = listArray (0,99) [0..99] :: UArray Int Double ghci arr ! (17::Int) 17.0 ghci arr ! [13..15 :: Int] array (0,2) [(0,13.0),(1,14.0),(2,15.0)] However, the ugly type annotations (::Int) are necessary, otherwise I get an error message: arr ! 17 No instance for (Sliceable (UArray Int Double) indtype0 resulttype0) arising from a use of `!' Possible fix: add an instance declaration for Sliceable (UArray Int Double) indtype resulttype0 in the expression: arr ! 17
Beginners Digest, Vol 55, Issue 18
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. How to get qualifiers into type (Rustom Mody) 2. Re: How to get qualifiers into type (Daniel Trstenjak) 3. Re: How to get qualifiers into type (Kim-Ee Yeoh) 4. Re: How to get qualifiers into type (Rustom Mody) 5. Literate Haskell - capturing output (Martin Drautzburg) 6. Things which predictedly change over time (Martin Drautzburg) -- Message: 1 Date: Thu, 17 Jan 2013 19:10:48 +0530 From: Rustom Mody rustompm...@gmail.com Subject: [Haskell-beginners] How to get qualifiers into type To: beginners beginners@haskell.org Message-ID: caj+teoe4yf1w6+6yu5detfcyhxt+rsaacfpclgwkaa3jtrl...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 I am playing around with some small graph theory problems. [Yeah I know there are good libraries -- as I said just playing around...] And I need to do things like type Vertex = Ix a = a (so that a vertex can be used to index an adjacency-list-array) That is to say that whenever 'Vertex' appears in a type signature, the Ix should 'float' out to the qualifier list After a lot of nudging from the error messages and rewriting as type Vertex = forall a. Ix a = a and giving options LANGUAGE RankNTypes, ImpredicativeTypes, LiberalTypeSynonyms I still get all kinds of errors. I'll report them if required. However first of all would like to know: Is this the way to go? Is this possible? -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130117/23bc2ba8/attachment-0001.htm -- Message: 2 Date: Thu, 17 Jan 2013 15:53:31 +0100 From: Daniel Trstenjak daniel.trsten...@gmail.com Subject: Re: [Haskell-beginners] How to get qualifiers into type To: beginners@haskell.org Message-ID: 20130117145331.GA29344@machine Content-Type: text/plain; charset=us-ascii Hi Rustom, On Thu, Jan 17, 2013 at 07:10:48PM +0530, Rustom Mody wrote: type Vertex = Ix a = a (so that a vertex can be used to index an adjacency-list-array) Ix is a type class, so you can only create an instance for an existing type, but not rename the type class to something else. That is to say that whenever 'Vertex' appears in a type signature, the Ix should 'float' out to the qualifier list You add the constraint to the functions using the index: element :: Ix a = a - ListArray b - b element index array = ... Greetings, Daniel -- Message: 3 Date: Thu, 17 Jan 2013 22:32:50 +0700 From: Kim-Ee Yeoh k...@atamo.com Subject: Re: [Haskell-beginners] How to get qualifiers into type To: Rustom Mody rustompm...@gmail.com Cc: beginners beginners@haskell.org Message-ID: CAPY+ZdSbNNLyiEbJvnpJ5wZMs7_ieW=x4rusyy0onjhj6xd...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 On Thu, Jan 17, 2013 at 8:40 PM, Rustom Mody rustompm...@gmail.com wrote: And I need to do things like type Vertex = Ix a = a (so that a vertex can be used to index an adjacency-list-array) Two things seem to be going on: (1) you're trying to define a data type using type and not data+class instances. Recall that the type declares a type /synonym/, and while type synonyms seem to behave like CPP-style macros, they aren't. That is to say that whenever 'Vertex' appears in a type signature, the Ix should 'float' out to the qualifier list (2) you're trying to save on keyboarding by using Vertex as a CPP-style macro that expands in the smart way you just described. Something that has been requested before is collapsing a list of constraints into just one (search haskell-cafe archives and also see No Module Abstraction of [1]). The larger the number of constraints, i.e. (A x) expands out to (B x, C x, D x, ...) the greater the need for such a feature. But there's no benefit to be gained here. (3) you're trying to improve readability of code because Ix a = a isn't explicit that type variable a is a vertex. Nothing stops you from writing Ix vertex = vertex however. See [2]. [1] http://lukepalmer.wordpress.com/2010/03/19/haskells-big-three/ [2] http://www.amateurtopologist.com/blog/2011/10/11/name-your-type-variables/ -- Kim-Ee -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130117/ed3db080/attachment-0001.htm -- Message: 4 Date: Thu, 17 Jan 2013 22:22:32 +0530 From:
Beginners Digest, Vol 55, Issue 19
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Things which predictedly change over time (Twan van Laarhoven) 2. Re: Things which predictedly change over time (Martin Drautzburg) -- Message: 1 Date: Fri, 18 Jan 2013 14:51:55 +0100 From: Twan van Laarhoven twa...@gmail.com Subject: Re: [Haskell-beginners] Things which predictedly change over time To: beginners@haskell.org Message-ID: 50f9537b.10...@gmail.com Content-Type: text/plain; charset=UTF-8; format=flowed First of all, I would separate the mathematical description of the problem from issues about optimization such as without having to enumerate all days and check each day individually. First make a specification, and make it correct. You can worry about optimizations later. So what would a specification for a schedule be? You already suggested a list of pairs. Something like type ScheduleSpec event = [(DateTime,event)] For trains the situation is more complicated, because a single train has a schedule of where it will be at what time, and there can be multiple trains. So then you get data Train = { trainStops :: [(DateTime,Place)], trainInfo :: MoreStuff } type TrainSchedule = [Train] -- or maybe use relative time for the stops, I'm not sure Now you implement your queries on this datatype. For specifying schedules you could think of combinators like -- union of two schedules () :: Schedule - Schedule - Schedule empty :: Schedule -- a schedule with a single train singleton :: Train - Schedule -- a copy of the train runs every day until the end of days everyDay :: Schedule - Schedule everyHour :: Schedule - Schedule -- trains no longer depart after the given date untilDate :: DateTime - Schedule - Schedule untilTime :: TimeOfDay - Schedule - Schedule -- trains don't run on the given day of the week notOnDay :: DayOfWeek - Schedule - Schedule -- etc. *If* the code that uses lists turns out to be too slow for you, you can think about turning the TrainSchedule into something more complicated. I would still keep the unoptimized version around, since it gives you something to compare and test against. A more complicated type could be data Schedule = Single Train | Union [Schedule] | Repeat Schedule TimeDiff | IfThenElse Condition Schedule Schedule Whether this work any better depends on your application, your schedules, etc. Twan On 17/01/13 21:34, Martin Drautzburg wrote: Hello all, ... and I thought this was easy: find a way to represent a schedule, i.e. a thing which assumes different values at different days. It turned out I don't know what a schedule is. What is the formalism behind This train leaves at 11:00 every day except sundays (where it doesn't run at all), except on Easter Sunday where it leaves at 11:10? I do not even need to know the most compact representation, just some representation which is reasonably compact and which can be translated into human language. So far I believe a Schedule is a function which takes a day and retuns a Value. If I had this function, I could easily list values for all days within given interval of days. But the inverse should also be possible. Given a List of (Day, Value) pairs, I should be able to construct a Schedule. The reason why I am interested in this is the following: On every Monday I take a trip from A to C. To do so, I need to take two trains and change trains in B. So I have to consider the two train schedules to decide whether or not my itinerary will work. So I kind of have a Constraint which is scheduled itself (every Monday) and which depends on two other Schedules. The Constraint can be satisfied for some days and violated for others. I want to find out when it is violated (within a finit interval of days) without having to enumerate all days and check each day individually. And most importantly I want to specify the Constraint without referring to individual days, just like I did in the quoted sentence above. You may also say, I want to lift the fine world of relational algebra to a world where things change over time, i.e. assume different values at different days. This seems to be such a common planning problem! You face it every time you deal with things which are not constant over time, and it becomes a nightmare when you deal with relationships
Beginners Digest, Vol 55, Issue 20
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. helper tools for reading haskell source (Nathan H?sken) 2. Re: helper tools for reading haskell source (Henk-Jan van Tuyl) 3. Re: helper tools for reading haskell source (Miguel Negrao) 4. Re: helper tools for reading haskell source (Joey Hess) 5. Antiderivative (indefinite integral)? (Martin Drautzburg) 6. Re: Antiderivative (indefinite integral)? (Miguel Negrao) 7. Re: Antiderivative (indefinite integral)? (Mateusz Kowalczyk) 8. Re: Antiderivative (indefinite integral)? (Martin Drautzburg) 9. Re: Antiderivative (indefinite integral)? (Martin Drautzburg) 10. Re: Antiderivative (indefinite integral)? (Kim-Ee Yeoh) -- Message: 1 Date: Sat, 19 Jan 2013 13:52:59 +0100 From: Nathan H?sken nathan.hues...@posteo.de Subject: [Haskell-beginners] helper tools for reading haskell source To: beginners@haskell.org Message-ID: 50fa972b.3090...@posteo.de Content-Type: text/plain; charset=ISO-8859-15; format=flowed Hey, Often, when I read haskell code, I would like to know how and where a datatype or function is defined. Normaly I read the code of package, and I then use grep. But when it is not defined in the same package, grep can not help me. Example: I want to know where the datatype Frame and the function windowGetChildren in the wxHaskell odule are defined. I know there is hoogle, but for these it was unable to help me (or I was unable to use it correctly?). So I was wondering, what other tools or methods do you use to analyse haskell source? Regards, Nathan -- Message: 2 Date: Sat, 19 Jan 2013 14:04:19 +0100 From: Henk-Jan van Tuyl hjgt...@chello.nl Subject: Re: [Haskell-beginners] helper tools for reading haskell source To: beginners@haskell.org, Nathan H?skennathan.hues...@posteo.de Message-ID: op.wq5s9iblpz0...@zen5.arnhem.chello.nl Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes On Sat, 19 Jan 2013 13:52:59 +0100, Nathan H?sken nathan.hues...@posteo.de wrote: Example: I want to know where the datatype Frame and the function windowGetChildren in the wxHaskell module are defined. I know there is Hoogle, but for these it was unable to help me (or I was unable to use it correctly?). windowGetChildren is defined in wxcore, so you have to enter windowGetChildren +wxcore in the Hoogle search field Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming -- -- Message: 3 Date: Sat, 19 Jan 2013 13:51:00 + From: Miguel Negrao miguel.negrao-li...@friendlyvirus.org Subject: Re: [Haskell-beginners] helper tools for reading haskell source To: beginners@haskell.org Message-ID: 045432c1-c456-40b8-9446-c62d92173...@friendlyvirus.org Content-Type: text/plain; charset=windows-1252 A 19/01/2013, ?s 12:52, Nathan H?sken escreveu: Hey, Often, when I read haskell code, I would like to know how and where a datatype or function is defined. Normaly I read the code of package, and I then use grep. But when it is not defined in the same package, grep can not help me. Example: I want to know where the datatype Frame and the function windowGetChildren in the wxHaskell odule are defined. I know there is hoogle, but for these it was unable to help me (or I was unable to use it correctly?). Also, it?s useful to know that hayoo has access to many more packages then hoogle, so I mostly use hayoo now. Also, EclipseFP and Leksah can give you this information with a key press or even just hovering the mouse over a function. best, Miguel -- Message: 4 Date: Sat, 19 Jan 2013 11:58:02 -0400 From: Joey Hess j...@kitenet.net Subject: Re: [Haskell-beginners] helper tools for reading haskell source To: beginners@haskell.org Message-ID: 20130119155802.gb21...@gnu.kitenet.net Content-Type: text/plain; charset=iso-8859-1 Nathan H?sken wrote: Often, when I read haskell code, I would like to know how and where a datatype or function is defined. Normaly I read the code of package, and I then use grep. But when it is not defined in the same package, grep can not help me. Example: I want to know where the datatype Frame and the function windowGetChildren in the wxHaskell odule are defined. I know there is hoogle, but for these it was unable to help me (or I was unable to
Beginners Digest, Vol 55, Issue 21
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Antiderivative (indefinite integral)? (Miguel Negrao) 2. Re: Antiderivative (indefinite integral)? (Kim-Ee Yeoh) 3. Re: Antiderivative (indefinite integral)? (Martin Drautzburg) -- Message: 1 Date: Sun, 20 Jan 2013 20:07:41 + From: Miguel Negrao miguel.negrao-li...@friendlyvirus.org Subject: Re: [Haskell-beginners] Antiderivative (indefinite integral)? To: beginners@haskell.org Message-ID: 3a68bea1-74f5-4f36-9762-7370be0a3...@friendlyvirus.org Content-Type: text/plain; charset=windows-1252 A 20/01/2013, ?s 05:50, Kim-Ee Yeoh escreveu: p.s. Everyone, please Reply to All to make sure your email gets to the list reflector at haskell.org. Otherwise your responses are private to Martin and you lose out on the aspect of community. I don?t understand: why can?t this mailing automatically set the ?reply-to? field to beginners@haskell.org ? A lot of the other mailing lists that I?m subscribed to do that... Is it a conscious decision or a technical limitation ? best, Miguel -- Message: 2 Date: Mon, 21 Jan 2013 03:26:00 +0700 From: Kim-Ee Yeoh k...@atamo.com Subject: Re: [Haskell-beginners] Antiderivative (indefinite integral)? To: Miguel Negrao miguel.negrao-li...@friendlyvirus.org Cc: beginners@haskell.org beginners@haskell.org, beginners-ow...@haskell.org Message-ID: CAPY+ZdR-SNAr3Ce3pGxTn9m5UNXFv_-COeQJQb8H_Zv=m-e...@mail.gmail.com Content-Type: text/plain; charset=windows-1252 On Mon, Jan 21, 2013 at 3:07 AM, Miguel Negrao miguel.negrao-li...@friendlyvirus.org wrote: A 20/01/2013, ?s 05:50, Kim-Ee Yeoh escreveu: p.s. Everyone, please Reply to All to make sure your email gets to the list reflector at haskell.org. Otherwise your responses are private to Martin and you lose out on the aspect of community. I don?t understand: why can?t this mailing automatically set the ?reply-to? field to beginners@haskell.org ? A lot of the other mailing lists that I?m subscribed to do that... Is it a conscious decision or a technical limitation ? Excellent question! I believe we're on mailman software and the list admin is Benjamin Russell: dekudekup...@yahoo.com or beginners-ow...@haskell.org I've cc'ed both to see if we can get a response from him. It does look as if it's merely a config option: http://ccit.mines.edu/Mailman-FAQ#25 -- Kim-Ee -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130121/878d5902/attachment-0001.htm -- Message: 3 Date: Sun, 20 Jan 2013 21:42:16 +0100 From: Martin Drautzburg martin.drautzb...@web.de Subject: Re: [Haskell-beginners] Antiderivative (indefinite integral)? To: beginners@haskell.org Message-ID: 201301202142.16308.martin.drautzb...@web.de Content-Type: Text/Plain; charset=iso-8859-15 On Sunday, 20. January 2013 06:50:27 Kim-Ee Yeoh wrote: So no, you don't get a simple number. It is ambiguous to evaluate the antiderivative at a point. So F(x=x0) has no meaning in itself? Only the differences F(x=x1) - F(x=x0) have a meaning? Using the F(0)=0 rule, you'll be summing /about the origin/. So you'd avoid nastiness like having to sum f(x) starting from the lowest possible x. Thanks. It took me a while to fully understand what you said here. -- Martin -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 55, Issue 21 *
Beginners Digest, Vol 55, Issue 22
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Antiderivative (indefinite integral)? (Twan van Laarhoven) 2. cabal install error: (Illegal instance declaration for `StrictByteString String') (miro) 3. can't install hackage package (Emmanuel Touzery) 4. Re: can't install hackage package (Emmanuel Touzery) 5. Re: can't install hackage package (Hartmut) 6. Fwd: Re: can't install hackage package (Emmanuel Touzery) -- Message: 1 Date: Mon, 21 Jan 2013 16:30:26 +0100 From: Twan van Laarhoven twa...@gmail.com Subject: Re: [Haskell-beginners] Antiderivative (indefinite integral)? To: beginners@haskell.org Message-ID: 50fd5f12.6060...@gmail.com Content-Type: text/plain; charset=UTF-8; format=flowed If you don't care about efficiency, you can define antideriv :: (Int - Int) - Int - Int antideriv f x | x = 0 = sum [ f y | y - [0..x-1] ] | x 0 = - sum [ f y | y - [x..-1] ] which has the property that antideriv f x1 - antideriv f x0 == sum [f x | x - [x0..x1-1]] Twan On 19/01/13 19:55, Martin Drautzburg wrote: Hello all, not strictly a Haskell question, but anyways ... is it possible to compute the antiderivative of a function f::Int-Int ? I understand that you can compute the definite integral by simply summing up the values of f within a given interval. My first guess would be: no this is not possible. The antiderivative F of a function f::Int-Int needs to have the property that F(b) - F(a) must be the sum of f within [a,b]. To do this I must know all values withib [a,b]. But at the time I compute the antiderivative I do not know this interval yet. What is striking me is that in calculus I can often symbolically compute the antiderivative and I get a simple function, and I can get the value of F for a given x and I get a simple number. Why is that so? -- Message: 2 Date: Mon, 21 Jan 2013 20:43:17 +0100 From: miro miroslav.kar...@gmail.com Subject: [Haskell-beginners] cabal install error: (Illegal instance declaration for `StrictByteString String') To: beginners@haskell.org Message-ID: 50fd9a55.8030...@gmail.com Content-Type: text/plain; charset=iso-8859-1; Format=flowed Hi, please,I'm trying to install one package (neo4j-haskell-http-client) and below is the error I'm getting. Pls. any ideas how can I fix that? --- 1 of 1] Compiling Data.ByteString.Class ( Data/ByteString/Class.hs, dist/build/Data/ByteString/Class.o ) Data/ByteString/Class.hs:39:10: Illegal instance declaration for `StrictByteString String' (All instance types must be of the form (T a1 ... an) where a1 ... an are *distinct type variables*, and each type variable appears at most once in the instance head. Use -XFlexibleInstances if you want to disable this.) In the instance declaration for `StrictByteString String' Data/ByteString/Class.hs:55:10: Illegal instance declaration for `LazyByteString String' (All instance types must be of the form (T a1 ... an) where a1 ... an are *distinct type variables*, and each type variable appears at most once in the instance head. Use -XFlexibleInstances if you want to disable this.) In the instance declaration for `LazyByteString String' Updating documentation index /Users/miro/Library/Haskell/doc/index.html cabal: Error: some packages failed to install: bytestring-class-0.0.0 failed during the building phase. The exception was: ExitFailure 1 neo4j-haskell-0.4.1 depends on bytestring-class-0.0.0 which failed to install. --- cheers, m. -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130121/a2ec26ae/attachment-0001.htm -- Message: 3 Date: Mon, 21 Jan 2013 20:53:29 +0100 From: Emmanuel Touzery etouz...@gmail.com Subject: [Haskell-beginners] can't install hackage package To: beginners@haskell.org beginners@haskell.org Message-ID: cac42remcxhbnmpesyfqqh4sfo03qtak49bab90k7exk8msm...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Hello, I've been using this hackage package rex without problems on two computers (linux, windows) but now I fail setting it up on a third computer which confuses me, and the error message is not really enlightening for me: $ cabal update Downloading the latest package list from
Beginners Digest, Vol 55, Issue 23
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: can't install hackage package (Emmanuel Touzery) 2. Re: can't install hackage package (Andres L?h) 3. Re: can't install hackage package (Emmanuel Touzery) 4. Re: can't install hackage package (Emmanuel Touzery) 5. Re: can't install hackage package (Andres L?h) 6. Re: can't install hackage package (Emmanuel Touzery) -- Message: 1 Date: Mon, 21 Jan 2013 21:43:59 +0100 From: Emmanuel Touzery etouz...@gmail.com Subject: Re: [Haskell-beginners] can't install hackage package To: beginners@haskell.org beginners@haskell.org Message-ID: CAC42RekPqEReL8Ej=S18neBifhnbS=vcypeqfo2kuwb73gk...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Yes i put the source then extra include dirs and extra lib dirs and pcre.dll in the same folder and worked great. On 21 Jan 2013 21:37, Hartmut hartmut0...@googlemail.com wrote: Hi, I wanted to try this under Windows also, but there are even more problems, since pcre-light dependency is not available (perhaps in case of using MSys, MingW) Hartmut Windows, cabal 1.16.0.2, I got cabal install rex --dry-run Resolving dependencies... In order, the following would be installed (use -v for more details): hslogger-1.2.1 MissingH-1.2.0.0 pcre-light-0.4 split-0.2.1.1 th-lift-0.5.5 th-orphans-0.6 haskell-src-meta-0.6.0.1 rex-0.3.1 cabal install Resolving dependencies... Configuring pcre-light-0.4... cabal: Missing dependency on a foreign library: * *Missing C library: pcre* This problem can usually be solved by installing the system package that provides this library (you may need the -dev version). If the library is already installed but in a non-standard location then you can use the flags --extra-include-dirs= and --extra-lib-dirs= to specify where it is. cabal: Error: some packages failed to install: pcre-light-0.4 failed during the configure step. The exception was: ExitFailure 1 rex-0.3.1 depends on pcre-light-0.4 which failed to install. Am 21.01.2013 21:10, schrieb Emmanuel Touzery: This is on fedora18 if it can help. On 21 Jan 2013 20:53, Emmanuel Touzery etouz...@gmail.com wrote: Hello, I've been using this hackage package rex without problems on two computers (linux, windows) but now I fail setting it up on a third computer which confuses me, and the error message is not really enlightening for me: $ cabal update Downloading the latest package list from hackage.haskell.org $ cabal --version cabal-install version 1.16.0.2 using version 1.16.0.3 of the Cabal library $ cabal install rex Resolving dependencies... cabal: Could not resolve dependencies: trying: rex-0.3.1 Any idea? Thank you! Emmanuel ___ Beginners mailing listBeginners@haskell.orghttp://www.haskell.org/mailman/listinfo/beginners ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130121/5d3e828c/attachment-0001.htm -- Message: 2 Date: Mon, 21 Jan 2013 21:44:09 +0100 From: Andres L?h andres.l...@gmail.com Subject: Re: [Haskell-beginners] can't install hackage package To: Emmanuel Touzery etouz...@gmail.com Cc: beginners@haskell.org beginners@haskell.org Message-ID: caljd_v51f1bsxgau904wu5l4wja0fxxyjhy29nbcsjpeqxt...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 Hi. I've been using this hackage package rex without problems on two computers (linux, windows) but now I fail setting it up on a third computer which confuses me, and the error message is not really enlightening for me: $ cabal update Downloading the latest package list from hackage.haskell.org $ cabal --version cabal-install version 1.16.0.2 using version 1.16.0.3 of the Cabal library $ cabal install rex Resolving dependencies... cabal: Could not resolve dependencies: trying: rex-0.3.1 That's a bad error message indeed ;) What's your GHC version? Is this an otherwise clean package database? Can you post the output of cabal install rex --dry-run -v3? If the log is too long to attach to a mailing list mail, just mail it to me personally. Cheers, Andres -- Message: 3 Date: Mon, 21 Jan 2013 21:50:21
Beginners Digest, Vol 55, Issue 26
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Can I lift this interestingly typed function into a Maybe? (Simon Peter Nicholls) 2. Re: Can I lift this interestingly typed function into a Maybe? (Kim-Ee Yeoh) 3. Re: Can I lift this interestingly typed function into a Maybe? (Simon Peter Nicholls) 4. Reply-To fixed for this mailing list (Kim-Ee Yeoh) -- Message: 1 Date: Thu, 24 Jan 2013 15:56:47 +0100 From: Simon Peter Nicholls si...@mintsource.org Subject: [Haskell-beginners] Can I lift this interestingly typed functioninto a Maybe? To: beginners@haskell.org Message-ID: caeacoj+vgy70nienjsehbslqwiw56u0tviavf3vyn9-2mfh...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Hi all, My issue is generic Haskell use, but I should provide the specific background. I have some Snap code: eres - eitherWithDB $ DB.findOne (DB.select [] someCollection) let maybeVal = either (error Mongoed) (maybe Nothing fromBson) eres and this works so that maybeVal will be of type Maybe MyType. eres is either a MongoDB Failure, or a Maybe Document (I find one document, or not). I'd like to convert this Maybe Document to a Maybe MyType without unpacking and repacking the Maybe. Is this possible? The fromBson function, that converts from a Document to an end user type, confuses me due to it's type: fromBson :: Monadhttp://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html/Control-Monad.html#t:Monad m = Documenthttp://hackage.haskell.org/packages/archive/bson/0.1.7/doc/html/Data-Bson.html#t:Document - m a Thanks, Si -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130124/9f21e3af/attachment-0001.htm -- Message: 2 Date: Thu, 24 Jan 2013 22:24:55 +0700 From: Kim-Ee Yeoh k...@atamo.com Subject: Re: [Haskell-beginners] Can I lift this interestingly typed function into a Maybe? To: Simon Peter Nicholls si...@mintsource.org Cc: beginners@haskell.org Message-ID: CAPY+ZdSLqAnC_rhpcaQrCwFx6thsYiq=gvbrf_0ukhg151m...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 On Thu, Jan 24, 2013 at 9:56 PM, Simon Peter Nicholls si...@mintsource.orgwrote: I'd like to convert this Maybe Document to a Maybe MyType without unpacking and repacking the Maybe. Is this possible? That would be exactly fmap :: (Document - MyType) - (Maybe Document - Maybe MyType) where I've instantiated the type variables for your use case. The fromBson function, that converts from a Document to an end user type, confuses me due to it's type: fromBson :: Monadhttp://hackage.haskell.org/packages/archive/base/4.5.0.0/doc/html/Control-Monad.html#t:Monad m = Documenthttp://hackage.haskell.org/packages/archive/bson/0.1.7/doc/html/Data-Bson.html#t:Document - m a All the small, single letters are type variables. Because they are implicitly universally quantified; you, the caller, gets to specify what you want them to be. Written out in full, it's actually fromBson :: forall (m :: * - *), a. Monad m = Document - m a Here, again specializing for your use case, fromBson probably needs to be of type fromBson :: Document - Maybe MyType So if you have a rightEres :: Maybe Document then fmap fromBson rightEres :: Maybe (Maybe MyType) which you could then join $ fmap fromBson rightEres :: Maybe MyType What you're really after is the more idiomatic rightEres = fromBson :: Maybe MyType HTH, -- Kim-Ee Thanks, Si ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130124/b0867d76/attachment-0001.htm -- Message: 3 Date: Thu, 24 Jan 2013 16:37:30 +0100 From: Simon Peter Nicholls si...@mintsource.org Subject: Re: [Haskell-beginners] Can I lift this interestingly typed function into a Maybe? To: Kim-Ee Yeoh k...@atamo.com Cc: beginners@haskell.org Message-ID: CAEaCoJK=nuej9nkwueakd6iyub7emxobf5uk4y8txetaajr...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Ahhh, thank you. The following works: let meal = either (error Mongoed) (= fromBson) eres On Thu, Jan 24, 2013 at 4:24 PM, Kim-Ee Yeoh
Beginners Digest, Vol 55, Issue 27
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Reply-To fixed for this mailing list (Olivier Scalbert) 2. missing ghci, need to install cca (Franco) -- Message: 1 Date: Fri, 25 Jan 2013 23:00:53 +0100 From: Olivier Scalbert olivier.scalb...@algosyn.com Subject: Re: [Haskell-beginners] Reply-To fixed for this mailing list To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: 51030095.3030...@algosyn.com Content-Type: text/plain; charset=windows-1252; format=flowed Thanks for your help Kim ! Olivier On 01/25/2013 10:43 AM, Kim-Ee Yeoh wrote: Hey Miguel, Just got word from Benjamin (list owner) that he's fixed it. -- Kim-Ee On Mon, Jan 21, 2013 at 3:26 AM, Kim-Ee Yeoh k...@atamo.com mailto:k...@atamo.com wrote: On Mon, Jan 21, 2013 at 3:07 AM, Miguel Negrao miguel.negrao-li...@friendlyvirus.org mailto:miguel.negrao-li...@friendlyvirus.org wrote: A 20/01/2013, ?s 05:50, Kim-Ee Yeoh escreveu: p.s. Everyone, please Reply to All to make sure your email gets to the list reflector at haskell.org http://haskell.org. Otherwise your responses are private to Martin and you lose out on the aspect of community. I don?t understand: why can?t this mailing automatically set the ?reply-to? field to beginners@haskell.org mailto:beginners@haskell.org ? A lot of the other mailing lists that I?m subscribed to do that... Is it a conscious decision or a technical limitation ? Excellent question! I believe we're on mailman software and the list admin is Benjamin Russell: dekudekup...@yahoo.com or beginners-ow...@haskell.org mailto:beginners-ow...@haskell.org I've cc'ed both to see if we can get a response from him. It does look as if it's merely a config option: http://ccit.mines.edu/Mailman-FAQ#25 -- Kim-Ee ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- Message: 2 Date: Sat, 26 Jan 2013 09:56:34 + From: Franco franc...@gmx.com Subject: [Haskell-beginners] missing ghci, need to install cca To: beginners@haskell.org Message-ID: 20130126095634.GA25246@efikamx Content-Type: text/plain; charset=us-ascii Hello haskellers, I am trying to install Euterpea [1], a DSL computer music development written in Haskell. Its git repository lies here [2]. Once finished cloning it, i tried running 'cabal install'. Packet CCA-1.0.3 fails to install with errors like src/Language/Haskell/TH/Instances.hs:175:12: Template Haskell bracket illegal in a stage-1 compiler [| D# ($(return (LitE (DoublePrimL (toRational d) |] src/Language/Haskell/TH/Instances.hs:175:18: Template Haskell splice illegal in a stage-1 compiler return (LitE (DoublePrimL (toRational d))) cabal: Error: some packages failed to install: CCA-0.1.3 failed during the building phase. The exception was: ExitFailure 1 Euterpea-1.0.0 depends on CCA-0.1.3 which failed to install. I have been warned by the #haskell irc channel on freenode that those errors essentially mean you don't have ghci installed, so no template haskell for you. Indeed my platform (ARM, running Debian ARMHF) does not have ghci. Question is: do you think there is a workaround to install package Euterpa (or CCA?). Or should I just give up? [1] http://haskell.cs.yale.edu/euterpea-2/ [2] https://github.com/dwincort/Euterpea -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 55, Issue 27 *
Beginners Digest, Vol 55, Issue 28
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: missing ghci, need to install cca (Erik de Castro Lopo) 2. Re: missing ghci, need to install cca (Franco) 3. Idiomatic way of working with Either and lists (Emmanuel Surleau) 4. Laziness problem, some code never being executed,when using Control.Monad.State.Strict (Olivier Boudry) 5. Re: Idiomatic way of working with Either and lists (Daniel Fischer) 6. Re: Idiomatic way of working with Either and lists (Daniel Fischer) 7. Re: Idiomatic way of working with Either and lists (Emmanuel Surleau) 8. Re: Laziness problem,some code never being executed, when using Control.Monad.State.Strict (Olivier Boudry) -- Message: 1 Date: Sat, 26 Jan 2013 22:11:56 +1100 From: Erik de Castro Lopo mle...@mega-nerd.com Subject: Re: [Haskell-beginners] missing ghci, need to install cca To: beginners@haskell.org Message-ID: 20130126221156.edc8266051f68bbe4259b...@mega-nerd.com Content-Type: text/plain; charset=US-ASCII Franco wrote: I have been warned by the #haskell irc channel on freenode that those errors essentially mean you don't have ghci installed, so no template haskell for you. Indeed my platform (ARM, running Debian ARMHF) does not have ghci. What version of ghc do you have? I thought the 7.6.1 version of ghci for armhf did support a working ghci. Erik -- -- Erik de Castro Lopo http://www.mega-nerd.com/ -- Message: 2 Date: Sat, 26 Jan 2013 12:00:22 + From: Franco franc...@gmx.com Subject: Re: [Haskell-beginners] missing ghci, need to install cca To: beginners@haskell.org Message-ID: 20130126120022.GA5527@efikamx Content-Type: text/plain; charset=us-ascii What version of ghc do you have? I thought the 7.6.1 version of ghci for armhf did support a working ghci. 7.4.1 (I am running wheezy/sid). 7.6.1 is being tested in experimental [1], but debian experimental is quite a nightmare for me, I plan to stay on stable as soon as wheezy is released. [1] http://packages.debian.org/experimental/ghc -- Message: 3 Date: Sat, 26 Jan 2013 17:26:26 +0100 From: Emmanuel Surleau emmanuel.surl...@gmail.com Subject: [Haskell-beginners] Idiomatic way of working with Either and lists To: Haskell Beginners beginners@haskell.org Message-ID: 20130126162626.GA8793@mercurialalchemist Content-Type: text/plain; charset=us-ascii Hi, I'm trying to figure out the best way to work with Either and lists. I have a function f which goes: f :: a - Either SomeError b Now, I'd like to do: applyF :: [a] - (a - Either SomeError b) - Either SomeError [b] That is, map f over a list and return either a list or the first error found. The function should stop at the first error. I have implemented applyF with a fold, but I'm sure there must be something like this already, being a fairly generic pattern. Thanks, Emm -- Message: 4 Date: Sat, 26 Jan 2013 17:29:20 +0100 From: Olivier Boudry olivier.bou...@gmail.com Subject: [Haskell-beginners] Laziness problem, some code never being executed, when using Control.Monad.State.Strict To: beginners@haskell.org Message-ID: CAC-kiLCnESVbcFoji1iL9=r7wFYGC0+pV52Q_n1z=92fzbd...@mail.gmail.com Content-Type: text/plain; charset=utf-8 Hi folks, I'm using the state monad (Control.Monad.State.Strict) to keep track of the state of a monopoly game (Project Euler problem #84). I'm really close to get something that works, but I just have some code with side effects only that does not execute and I struggle force it to execute. I used hpc to discover which part of the code was never run and found lines 93 to 95. In those lines I'm trying to update a visits Map that holds the number of times I've been on a particular cell of the board. What I don't understand is that the code in lines 66 to 68 is almost identical and this one gets executed. The visit Map is used at the very end to retrieve results. 57 execAction :: State Monopoly () 58 execAction = do 59 m - get 60 let b = board m 61 let s = CL.value b 62 case s of 63 (CC _) - execCommunityChest 64 (CH _) - execChance 65 G2J- execMove gotoJail 66 _ - do 67 let v = insertWith (+) s 1 (visit m) 68 put m {visit = v}... 80
Beginners Digest, Vol 55, Issue 29
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Why Functional Programming Matters -- this will make you smarter (Costello, Roger L.) -- Message: 1 Date: Sun, 27 Jan 2013 10:32:31 + From: Costello, Roger L. coste...@mitre.org Subject: [Haskell-beginners] Why Functional Programming Matters -- thiswill make you smarter To: beginners@haskell.org beginners@haskell.org Message-ID: b5fee00b53cf054aa8439027e8fe17751e6f3...@imcmbx04.mitre.org Content-Type: text/plain; charset=us-ascii Hi Folks, I have written a summary of the outstanding paper by John Hughes titled, Why Functional Programming Matters. Hughes says that the purpose of his paper is to demonstrate to the real world that functional programming is vitally important. I say that the purpose of his paper is to make you smarter. The paper presents a series of problems. As I proceeded through the problems, I realized that I was on a beautiful journey to the promised land of solving problems by simply combining existing parts. It was a thrilling, mind-expanding journey. Hughes implemented the solutions to the problems using Miranda. I converted them to Haskell. http://www.xfront.com/Haskell/Why-Functional-Programming-Matters.pdf /Roger -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 55, Issue 29 *
Beginners Digest, Vol 55, Issue 30
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. How to unnest do (Martin Drautzburg) 2. Re: How to unnest do (Ertugrul S?ylemez) 3. Re: How to unnest do (David McBride) 4. Re: How to unnest do (Emmanuel Touzery) 5. Re: How to unnest do (Brent Yorgey) 6. Re: How to unnest do (Emmanuel Touzery) -- Message: 1 Date: Sun, 27 Jan 2013 18:27:48 +0100 From: Martin Drautzburg martin.drautzb...@web.de Subject: [Haskell-beginners] How to unnest do To: beginners@haskell.org Message-ID: 201301271827.48843.martin.drautzb...@web.de Content-Type: text/plain; charset=us-ascii Hello all, in the code snippet below, is there a way to factor out the second do? import System (getArgs) main :: IO () main = do args - getArgs case args of [fname] - do fstr - readFile fname let nWords = length . words $ fstr nLines = length . lines $ fstr nChars = length fstr putStrLn . unwords $ [ show nLines , show nWords , show nChars , fname] _ -putStrLn usage: wc fname -- Message: 2 Date: Sun, 27 Jan 2013 20:43:58 +0100 From: Ertugrul S?ylemez e...@ertes.de Subject: Re: [Haskell-beginners] How to unnest do To: beginners@haskell.org Message-ID: 20130127204358.4d65d...@tritium.streitmacht.eu Content-Type: text/plain; charset=us-ascii Hi there Martin, since the nested 'do' makes sense, there is little you can do about it. However, you can make the code more beautiful and restructure it a bit. This is how I would have written it: import Control.Applicative import System.Environment import System.IO stats :: String - String stats = unwords . sequence [show . length . words, show . length . lines, show . length] main :: IO () main = do args - getArgs case args of [fn] - fmap stats (readFile fn) = putStrLn _- hPutStrLn stderr Usage: wc FNAME This improves the statistics code slightly, but uses some monadic machinery you may not be familiar with. Another way to read the 'stats' function is this: stats :: String - String stats str = unwords [show . length . words $ str, show . length . lines $ str, show . length $ str] Finally you can improve the command line argument processing itself simply by being more sensible about what makes a valid command line: main = getArgs = mapM_ (fmap stats . readFile = putStrLn) Instead of expecting exactly one command line argument you print the counts for every argument. That means, if there are no arguments, you print no counts. This makes more sense than the highhanded I want exactly one argument, otherwise I won't work syntax, because now your whole program forms a homomorphism (shell syntax): `prog x` `prog y` = `prog x y` This allows reasoning and optimization. Greets, Ertugrul Martin Drautzburg martin.drautzb...@web.de wrote: in the code snippet below, is there a way to factor out the second do? import System (getArgs) main :: IO () main = do args - getArgs case args of [fname] - do fstr - readFile fname let nWords = length . words $ fstr nLines = length . lines $ fstr nChars = length fstr putStrLn . unwords $ [ show nLines , show nWords , show nChars , fname] _ -putStrLn usage: wc fname -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -- next part -- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: http://www.haskell.org/pipermail/beginners/attachments/20130127/f7505ede/attachment-0001.pgp -- Message: 3 Date: Sun, 27 Jan 2013 15:06:47 -0500 From: David McBride
Beginners Digest, Vol 55, Issue 31
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: How to unnest do (Martin Drautzburg) 2. Re: How to unnest do (Brent Yorgey) 3. Re: missing ghci, need to install cca (C K Kashyap) 4. Re: missing ghci, need to install cca (Franco) -- Message: 1 Date: Sun, 27 Jan 2013 23:29:18 +0100 From: Martin Drautzburg martin.drautzb...@web.de Subject: Re: [Haskell-beginners] How to unnest do To: beginners@haskell.org Message-ID: 201301272329.18303.martin.drautzb...@web.de Content-Type: Text/Plain; charset=iso-8859-15 On Sunday, 27. January 2013 20:43:58 Ertugrul S?ylemez wrote: Hi there Martin, since the nested 'do' makes sense, there is little you can do about it. However, you can make the code more beautiful and restructure it a bit. This is how I would have written it: import Control.Applicative import System.Environment import System.IO stats :: String - String stats = unwords . sequence [show . length . words, show . length . lines, show . length] main :: IO () main = do args - getArgs case args of [fn] - fmap stats (readFile fn) = putStrLn -- _- hPutStrLn stderr Usage: wc FNAME This improves the statistics code slightly, but uses some monadic machinery you may not be familiar with. Thanks, this looks much nicer and is very inspiring. But let me see if I get this correctly: readFile fn returns IO String I cannot see the String itself, but I can map the stats function over it, which gives me anoter IO String. This works, because every Monad is also a functor. Another way of looking at this is that fmap lifts the String-String function stats to (IO String) - (IO String), Again I cannot see the String inside the IO String, but I can pass it to a function String-IO String, using (=) and putStrLn is such a function, which also does what I need. I cannot use the same fmap mechanism (fmap putStrLn), because putStrLn is already String - IO String and fmap would lift both sides of -. I tried to find another way of passing the IO String to putStrLn, but there aren't many options. If I want to use putStrLn, then I need to get the String out of the IO String. AFAICS (=) is the only way to do this (other than do notation). In contrast to fmap, (=) lifts only the left side. For the hell of it, I tried to replace putStrLn by a String - Maybe String function. This does not work and it made me realize, that the signature of (=) :: m a - (a- m b) - m b demands that the the Monad m is the same all the way through, and only its type parameter can change. And the Applicative import is not really needed. Is this about correct? When I have a program, which accesses stdin and stdout and a database, I suppose I will have to do things like this a lot? Sorry for the long post, but I am getting kindof excieted. -- Message: 2 Date: Sun, 27 Jan 2013 17:42:04 -0500 From: Brent Yorgey byor...@seas.upenn.edu Subject: Re: [Haskell-beginners] How to unnest do To: beginners@haskell.org Message-ID: 20130127224204.ga26...@seas.upenn.edu Content-Type: text/plain; charset=iso-8859-1 On Sun, Jan 27, 2013 at 11:29:18PM +0100, Martin Drautzburg wrote: On Sunday, 27. January 2013 20:43:58 Ertugrul S?ylemez wrote: Hi there Martin, since the nested 'do' makes sense, there is little you can do about it. However, you can make the code more beautiful and restructure it a bit. This is how I would have written it: import Control.Applicative import System.Environment import System.IO stats :: String - String stats = unwords . sequence [show . length . words, show . length . lines, show . length] main :: IO () main = do args - getArgs case args of [fn] - fmap stats (readFile fn) = putStrLn -- _- hPutStrLn stderr Usage: wc FNAME This improves the statistics code slightly, but uses some monadic machinery you may not be familiar with. Thanks, this looks much nicer and is very inspiring. But let me see if I get this correctly: readFile fn returns IO String I cannot see the String itself, but I can map the stats function over it, which gives me anoter IO String. This works, because every Monad is also a functor. Another
Beginners Digest, Vol 55, Issue 32
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: How to unnest do (Daniel Trstenjak) 2. reorganizing lists (Bryce Verdier) 3. Re: reorganizing lists (Ozgur Akgun) 4. Re: reorganizing lists (divyanshu ranjan) 5. Re: reorganizing lists (Bryce Verdier) 6. Re: reorganizing lists (Brent Yorgey) 7. Re: reorganizing lists (Martin Drautzburg) 8. How to interact with a process (Martin Drautzburg) -- Message: 1 Date: Mon, 28 Jan 2013 15:27:44 +0100 From: Daniel Trstenjak daniel.trsten...@gmail.com Subject: Re: [Haskell-beginners] How to unnest do To: beginners@haskell.org Message-ID: 20130128142744.GA16791@machine Content-Type: text/plain; charset=us-ascii Hi Emmanuel, On Sun, Jan 27, 2013 at 09:46:30PM +0100, Emmanuel Touzery wrote: Thank you. I thought it might be, but it isn't exactly intuitive for me at this point. I'll read some more about that monad. Sometimes it's hard to tell if Haskell is the most beautiful language or the most abstract nonsense. ;) Let's look at the Monad instance for the function (r - a): instance Monad ((-) r) where -- return :: a - (r - a) return a = \_ - a -- (=) :: (r - a) - (a - r - b) - (r - b) left = right = \r - right (left r) r 'return' creates a function ignoring its argument and just returning 'a'. '=' creates a function with the argument 'r'. The function 'left' is called with 'r' and the function 'right' is called with the result of 'left' and 'r'. Now let's look at the 'sequence' function: sequence ms = foldr k (return []) ms where k m ms = do x - m xs - ms return (x : xs) It's easier to see what happens if we rewrite 'k': k m ms = m = (\x - (ms = \xs - return (x : xs))) We saw that '=' creates a function with one argument, that argument is the String containing the file contents, 'x' is the return value of one sequenced function which is combined (:) with the previous ones. At the end we have the function (String - [String]). Greetings, Daniel -- Message: 2 Date: Mon, 28 Jan 2013 10:37:53 -0800 From: Bryce Verdier bryceverd...@gmail.com Subject: [Haskell-beginners] reorganizing lists To: beginners@haskell.org Message-ID: 5106c581.1050...@gmail.com Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hi All, At the moment I have a list of lists. The inner list is a coordinate, like (x,y) but is [x,y] instead. What I would like to do is group all the x's into one list, and the y's into another. I know I can do this with calling 2 maps on the container, but I would also like to do this in one iteration. Does anyone have any ideas? Thanks in advance, Bryce -- Message: 3 Date: Mon, 28 Jan 2013 18:42:58 + From: Ozgur Akgun ozgurak...@gmail.com Subject: Re: [Haskell-beginners] reorganizing lists To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: calzazparl9ei5ce_ettvn+2xi9urlwuchmyp11brlza6gvj...@mail.gmail.com Content-Type: text/plain; charset=utf-8 Hi, On 28 January 2013 18:37, Bryce Verdier bryceverd...@gmail.com wrote: I know I can do this with calling 2 maps on the container, but I would also like to do this in one iteration. As a learning experience, may I suggest you post the code you would have written with two maps? Then we can try and improve on that to have only one map. Best, -- Ozgur Akgun -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130128/f234f5e8/attachment-0001.htm -- Message: 4 Date: Tue, 29 Jan 2013 00:14:18 +0530 From: divyanshu ranjan idivyanshu.ran...@gmail.com Subject: Re: [Haskell-beginners] reorganizing lists To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAL9hw24QC5hJZcPoJdXv=fklaqadu664_u3ey_przf95meb...@mail.gmail.com Content-Type: text/plain; charset=utf-8 Hi, You can use foldl (\(fx, fy) [x,y] - (x:fx, y:fy)) ([],[]) Thanks Divyanshu Ranjan On Tue, Jan 29, 2013 at 12:07 AM, Bryce Verdier bryceverd...@gmail.comwrote: Hi All, At the moment I have a list of lists. The inner list is a coordinate, like (x,y) but is [x,y] instead. What I would like to do is group all the x's into one list, and the
Beginners Digest, Vol 55, Issue 33
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: reorganizing lists (Bryce Verdier) 2. Re: How to unnest do (Emmanuel Touzery) 3. Re: reorganizing lists (Bryce Verdier) 4. Re: reorganizing lists (Sylvain HENRY) 5. Looking for a 20/min day study partner (Heath Matlock) 6. Re: Looking for a 20/min day study partner (Darren Grant) 7. Re: How to interact with a process (Miguel Negrao) -- Message: 1 Date: Mon, 28 Jan 2013 11:51:58 -0800 From: Bryce Verdier bryceverd...@gmail.com Subject: Re: [Haskell-beginners] reorganizing lists To: beginners@haskell.org Message-ID: 5106d6de.9050...@gmail.com Content-Type: text/plain; charset=ISO-8859-1; format=flowed On 01/28/2013 11:24 AM, Brent Yorgey wrote: On Mon, Jan 28, 2013 at 10:37:53AM -0800, Bryce Verdier wrote: Hi All, At the moment I have a list of lists. The inner list is a coordinate, like (x,y) but is [x,y] instead. What I would like to do is group all the x's into one list, and the y's into another. I know I can do this with calling 2 maps on the container, but I would also like to do this in one iteration. This can be done using the 'transpose' function from Data.List. -Brent ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners That was exactly what I was looking for. Thank you Brent! Bryce -- Message: 2 Date: Mon, 28 Jan 2013 21:24:47 +0100 From: Emmanuel Touzery etouz...@gmail.com Subject: Re: [Haskell-beginners] How to unnest do To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: cac42rekevflwzjcj6oustte1pkfbmqcmd4r3rpyygvwffqo...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Sometimes it's hard to tell if Haskell is the most beautiful language or the most abstract nonsense. ;) Amen. ;-) Let's look at the Monad instance for the function (r - a): instance Monad ((-) r) where -- return :: a - (r - a) return a = \_ - a -- (=) :: (r - a) - (a - r - b) - (r - b) left = right = \r - right (left r) r 'return' creates a function ignoring its argument and just returning 'a'. '=' creates a function with the argument 'r'. The function 'left' is called with 'r' and the function 'right' is called with the result of 'left' and 'r'. Now let's look at the 'sequence' function: sequence ms = foldr k (return []) ms where k m ms = do x - m xs - ms return (x : xs) It's easier to see what happens if we rewrite 'k': k m ms = m = (\x - (ms = \xs - return (x : xs))) We saw that '=' creates a function with one argument, that argument is the String containing the file contents, 'x' is the return value of one sequenced function which is combined (:) with the previous ones. At the end we have the function (String - [String]). I will look at this more in depth this week-end, really thank you for the heads up! This stuff is really a bit crazy, but somehow I still like it ;-) Emmanuel -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130128/6ef97726/attachment-0001.htm -- Message: 3 Date: Mon, 28 Jan 2013 13:50:34 -0800 From: Bryce Verdier bryceverd...@gmail.com Subject: Re: [Haskell-beginners] reorganizing lists To: beginners@haskell.org Message-ID: 5106f2aa.6020...@gmail.com Content-Type: text/plain; charset=ISO-8859-1; format=flowed On 01/28/2013 11:32 AM, Martin Drautzburg wrote: On Monday, 28. January 2013 19:37:53 Bryce Verdier wrote: Hi All, At the moment I have a list of lists. The inner list is a coordinate, like (x,y) but is [x,y] instead. What I would like to do is group all the x's into one list, and the y's into another. I know I can do this with calling 2 maps on the container, but I would also like to do this in one iteration. Something like this? groupMe = foldl (\[rx,ry] [x,y] - [x:rx,y:ry]) [[],[]] *Main groupMe [[1,2],[1,3],[2,3]] [[2,1,1],[3,3,2]] Thank you all for your responses. This is what I ultimately went with (pasted below). If anyone would like to share a way to improve this (because I know it can be), please share. I'm still learning. :) module Main where import qualified Data.Text as T import qualified Data.Text.IO as
Beginners Digest, Vol 56, Issue 1
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Literate Haskell - capturing output (Rustom Mody) 2. Re: Literate Haskell - capturing output (Rustom Mody) 3. Using Parsec to parse Haskell Language (Sean Cormican) 4. Type classes vs Java interfaces (Mateusz Kowalczyk) 5. Re: Type classes vs Java interfaces (Peter Hall) 6. cabal-debian (Ryan) -- Message: 1 Date: Thu, 31 Jan 2013 19:55:56 +0530 From: Rustom Mody rustompm...@gmail.com Subject: Re: [Haskell-beginners] Literate Haskell - capturing output To: Martin Drautzburg martin.drautzb...@web.de Cc: beginners@haskell.org Message-ID: CAJ+TeociEmb0B99MG1ab+eCdG-JEz=hmui_71v3o9a7rth5...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 On Fri, Jan 18, 2013 at 12:30 AM, Martin Drautzburg martin.drautzb...@web.de wrote: Hello all, I am using literate haskell quite a lot (otherwise I don't understand my own code). This works fine for the code as such. But when I give an example usage, I run code snippets in ghci and copypaste into the main document/program, which turns them into text (and not code). When I make changes to the program these examples tend to no longer reflect the actual program. Is there a way to automatically run examples and include them in the .lhs file, preferably with the haskell prompt and everything? If you are ok with emacs, emacs - orgmode - babel may be worth a consider http://orgmode.org/worg/org-contrib/babel/intro.html http://www.jstatsoft.org/v46/i03/paper -- http://www.the-magus.in http://blog.languager.org -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130131/7cbeef10/attachment-0001.htm -- Message: 2 Date: Thu, 31 Jan 2013 20:12:22 +0530 From: Rustom Mody rustompm...@gmail.com Subject: Re: [Haskell-beginners] Literate Haskell - capturing output To: Martin Drautzburg martin.drautzb...@web.de Cc: beginners@haskell.org Message-ID: caj+teodf8bqwwa1cwfjrpbwcfxm4ywa5arlh8wfjuvkt7c-...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 On Thu, Jan 31, 2013 at 7:55 PM, Rustom Mody rustompm...@gmail.com wrote: On Fri, Jan 18, 2013 at 12:30 AM, Martin Drautzburg martin.drautzb...@web.de wrote: Hello all, I am using literate haskell quite a lot (otherwise I don't understand my own code). This works fine for the code as such. But when I give an example usage, I run code snippets in ghci and copypaste into the main document/program, which turns them into text (and not code). When I make changes to the program these examples tend to no longer reflect the actual program. Is there a way to automatically run examples and include them in the .lhs file, preferably with the haskell prompt and everything? If you are ok with emacs, emacs - orgmode - babel may be worth a consider http://orgmode.org/worg/org-contrib/babel/intro.html http://www.jstatsoft.org/v46/i03/paper http://www.cs.unm.edu/~eschulte/data/CISE-13-3-SciProg.pdf maybe a better read -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130131/ea6befab/attachment-0001.htm -- Message: 3 Date: Thu, 31 Jan 2013 16:40:49 + From: Sean Cormican seancormic...@gmail.com Subject: [Haskell-beginners] Using Parsec to parse Haskell Language To: beginners@haskell.org Message-ID: CAF6xeQdRnywdM=xfngbCr=0ohi1gbr_yz7gvhtcw6v2si3f...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 I'm working on a project in which I am attempting to write a parser for Haskell within Haskell itself using Parsec. The parser itself only deals with a subset of the features of the full Haskell implementation but I'm having difficulty figuring out how to implement the grammar with precedence of operations for example boolean expression involving over || and also 'if then else statements in relation to other operations. I'm attempting to do this with the Text.Parsec.Expr module more specifically BuildExpressionParser combinator using table and term as used in a number of tutorials I have seen which deal with arithmetic expression. Is this the correct course of action? Or will it fail to meet my needs. Will it be necessary to create an AST for the grammar by creating new data types as outlined in the following tutorial?
Beginners Digest, Vol 56, Issue 2
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: cabal-debian (Brandon Allbery) -- Message: 1 Date: Fri, 1 Feb 2013 00:24:00 -0500 From: Brandon Allbery allber...@gmail.com Subject: Re: [Haskell-beginners] cabal-debian To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAKFCL4X7Mnm9j_ox31_2eVkm=ngr9p0otqfrz-92bygomum...@mail.gmail.com Content-Type: text/plain; charset=utf-8 On Fri, Feb 1, 2013 at 12:01 AM, Ryan rde...@gmail.com wrote: then I get a the following error: cabal-debian: cabal-debian: No bundled package list for ghc Version {versionBranch = [7,4,2], versionTags = []} shouldn't cabal-debian be pulling the package list from the hoodle.cabal file? That error sounds like it's looking for the system package.conf database, not the package's own dependencies. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130201/68593d94/attachment-0001.htm -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 56, Issue 2
Beginners Digest, Vol 56, Issue 3
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Type classes vs Java interfaces (Bob Hutchison) 2. Re: Type classes vs Java interfaces (Phil Scott) 3. Re: Type classes vs Java interfaces (Bryan Vicknair) 4. f . g or f g or f $ g? (Martin Drautzburg) 5. Re: f . g or f g or f $ g? (Emanuel Koczwara) 6. Re: f . g or f g or f $ g? (Emanuel Koczwara) 7. Re: f . g or f g or f $ g? (Emanuel Koczwara) 8. Re: How to interact with a process (Martin Drautzburg) 9. Re: How to interact with a process (Martin Drautzburg) -- Message: 1 Date: Fri, 1 Feb 2013 08:25:43 -0500 From: Bob Hutchison hutch-li...@recursive.ca Subject: Re: [Haskell-beginners] Type classes vs Java interfaces To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: e1b50614-5b3a-4576-8304-f3304a92f...@recursive.ca Content-Type: text/plain; charset=windows-1252 On 2013-01-31, at 6:36 PM, Mateusz Kowalczyk fuuze...@fuuzetsu.co.uk wrote: Greetings, I often wonder how one would explain type classes to someone coming from an environment such as Java. Whenever I think about type classes, I seem to think of them as Java interfaces. Bah, even the bottom of [1] states Haskell classes are roughly similar to a Java interface. Like an interface declaration, a Haskell class declaration defines a protocol for using an object rather than defining an object itself. Is there more to this `roughly similar' statement? Syntax is an obvious difference but beyond that, I can't think of anything I can do with a Haskell type class that I wouldn't be able to do with similar amount of effort with a Java interface, except for the fact that the interface would look absolutely disgusting syntax wise. Any insight appreciated. Well I have limited insight but? Type classes can provide default implementations, which is not possible in Java. Type classes in a type signature describe or constrain a type and but are not themselves types. Among other things, this means in Haskell that collections must be homogeneous in their actual type, it's not sufficient to be homogeneous in a type class. There are extensions to GHC that make this possible [1] but there are limitations and the usage has its detractors [2]. In Java you can have collections of objects that conform to a given interface even if they are of different classes. Personally, I find Haskell's restriction counter-intuitive but the sense of surprise and limitation is diminishing as I use the language. Cheers, Bob [1] -- http://www.haskell.org/haskellwiki/Heterogenous_collections#Existential_types [2] -- https://lukepalmer.wordpress.com/2010/01/24/haskell-antipattern-existential-typeclass/ [1] - http://www.haskell.org/tutorial/classes.html ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- Message: 2 Date: Fri, 1 Feb 2013 14:37:57 + From: Phil Scott m...@philscotted.com Subject: Re: [Haskell-beginners] Type classes vs Java interfaces To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: 20130201143756.ga8...@julian.ed.ac.uk Content-Type: text/plain; charset=utf-8 On Fri, Feb 01, 2013 at 08:25:43AM -0500, Bob Hutchison wrote: On 2013-01-31, at 6:36 PM, Mateusz Kowalczyk fuuze...@fuuzetsu.co.uk wrote: Greetings, I often wonder how one would explain type classes to someone coming from an environment such as Java. Whenever I think about type classes, I seem to think of them as Java interfaces. Bah, even the bottom of [1] states Haskell classes are roughly similar to a Java interface. Like an interface declaration, a Haskell class declaration defines a protocol for using an object rather than defining an object itself. Is there more to this `roughly similar' statement? Syntax is an obvious difference but beyond that, I can't think of anything I can do with a Haskell type class that I wouldn't be able to do with similar amount of effort with a Java interface, except for the fact that the interface would look absolutely disgusting syntax wise. Any insight appreciated. Well I have limited insight but? Type classes can provide default implementations, which is not
Beginners Digest, Vol 56, Issue 4
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Literate Haskell - capturing output (Martin Drautzburg) 2. Re: f . g or f g or f $ g? (Ertugrul S?ylemez) 3. Re: f . g or f g or f $ g? (Brent Yorgey) 4. Re: f . g or f g or f $ g? (Denis Kasak) 5. Re: Using Parsec to parse Haskell Language (Henk-Jan van Tuyl) -- Message: 1 Date: Fri, 1 Feb 2013 22:23:01 +0100 From: Martin Drautzburg martin.drautzb...@web.de Subject: Re: [Haskell-beginners] Literate Haskell - capturing output To: beginners@haskell.org Message-ID: 201302012223.01336.martin.drautzb...@web.de Content-Type: Text/Plain; charset=iso-8859-15 On Thursday, 31. January 2013 15:25:56 Rustom Mody wrote: If you are ok with emacs, emacs - orgmode - babel may be worth a consider http://orgmode.org/worg/org-contrib/babel/intro.html http://www.jstatsoft.org/v46/i03/paper Yes, I'm okay with emacs and I use org-mode a lot. Can you point be to an example of using org-mode with haskell? I've only seen that as a way to add program output to a documentation, but will I still end up with a runnable haskell program? -- Martin -- Message: 2 Date: Fri, 1 Feb 2013 23:02:39 +0100 From: Ertugrul S?ylemez e...@ertes.de Subject: Re: [Haskell-beginners] f . g or f g or f $ g? To: beginners@haskell.org Message-ID: 20130201230239.49eac...@tritium.streitmacht.eu Content-Type: text/plain; charset=us-ascii Martin Drautzburg martin.drautzb...@web.de wrote: I frequently get confused over f . g vs f g. I do understand the following Out of the three choices f . g, f g and f $ g, only the dot operator has a special meaning. The others are the same thing. Remember the function composition operator from math? It's the circle operator. That's how you should read the dot. In fact, if you use Emacs, you can make it display the dot that way. The haskell-mode has this built in. (f . g) x = f (g x) There is also something interesting to note about application: f $ x = ($) f x ($) f x = f x From that follows: ($) f = f And from that follows: ($) = id Indeed: id :: a- a ($) :: (a - b) - (a - b) ($) is really just id with a more special type. I hope this helps. =) Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -- next part -- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: http://www.haskell.org/pipermail/beginners/attachments/20130201/9857b09c/attachment-0001.pgp -- Message: 3 Date: Fri, 1 Feb 2013 17:04:44 -0500 From: Brent Yorgey byor...@seas.upenn.edu Subject: Re: [Haskell-beginners] f . g or f g or f $ g? To: beginners@haskell.org Message-ID: 20130201220444.ga19...@seas.upenn.edu Content-Type: text/plain; charset=us-ascii On Fri, Feb 01, 2013 at 08:42:56PM +0100, Martin Drautzburg wrote: Is there a way to easily remember when to use f.g and when to use f g without having to do this type algebra. No. After enough practice, however, this sort of type algebra becomes second nature, and no longer requires much conscious effort. -Brent -- Message: 4 Date: Fri, 1 Feb 2013 23:12:23 +0100 From: Denis Kasak denis.ka...@gmail.com Subject: Re: [Haskell-beginners] f . g or f g or f $ g? To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: canjrnzcn1a1zjnzhchjyfbapd4ihetr6edaydewabhmo7m1...@mail.gmail.com Content-Type: text/plain; charset=utf-8 On 1 February 2013 20:42, Martin Drautzburg martin.drautzb...@web.dewrote: Hello all I frequently get confused over f . g vs f g. I do understand the following With: g :: a-b f :: b -c f.g :: a-c However f g is a type error, because then f would have to accept a function (a-b) as its first parameter, but it only accepts a b. Is there a way to easily remember when to use f.g and when to use f g without having to do this type algebra. If you're familiar with the analogous operations in mathematics (function composition and function application), it should be easy to reason about. Function application is the act of calling the function: passing it an argument and making it return a result. In math, we write function
Beginners Digest, Vol 56, Issue 5
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Parsec problem (Kees Bleijenberg) 2. Re: Parsec problem (Andres L?h) 3. Re: Parsec problem (Daniel Fischer) 4. Re: Literate Haskell - capturing output (Rustom Mody) 5. Re: Parsec problem (Kees Bleijenberg) -- Message: 1 Date: Sat, 2 Feb 2013 15:00:52 +0100 From: Kees Bleijenberg k.bleijenb...@lijbrandt.nl Subject: [Haskell-beginners] Parsec problem To: beginners@haskell.org Message-ID: 01ce014d$b6c02b80$24408280$@bleijenb...@lijbrandt.nl Content-Type: text/plain; charset=us-ascii module Main(main) where import Text.ParserCombinators.Parsec parseToNewLine = do line - manyTill anyChar newline return line keyValue = do fieldName - many letter spaces char '=' spaces fieldValue - parseToNewLine return (fieldName,fieldValue) main = parseTest keyValue key=\n I don't understand why te code above doesn't parse to (key,) parseToNewLine \n parses to parseTest keyValue a=b\n works fine and parses to (a,b) Kees -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130202/8a2f3b3c/attachment-0001.htm -- Message: 2 Date: Sat, 2 Feb 2013 15:23:36 +0100 From: Andres L?h and...@well-typed.com Subject: Re: [Haskell-beginners] Parsec problem To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CALjd_v7rSp0_3CyMib_8aN+yhH4KZwPB=q8-fcgmqybovzr...@mail.gmail.com Content-Type: text/plain; charset=windows-1252 Hi. keyValue = do fieldName - many letter spaces char '=' spaces fieldValue - parseToNewLine return (fieldName,fieldValue) main = parseTest keyValue key=\n I don?t understand why te code above doesn?t parse to (?key?,??) The problem is that the \n is already consumed by spaces. The subsequent parseToNewLine fails. Cheers, Andres -- Andres L?h, Haskell Consultant Well-Typed LLP, http://www.well-typed.com -- Message: 3 Date: Sat, 02 Feb 2013 15:24:11 +0100 From: Daniel Fischer daniel.is.fisc...@googlemail.com Subject: Re: [Haskell-beginners] Parsec problem To: beginners@haskell.org Message-ID: 10971726.cjtncp9...@linux-v7dw.site Content-Type: text/plain; charset=utf-8 On Saturday 02 February 2013, 15:00:52, Kees Bleijenberg wrote: module Main(main) where import Text.ParserCombinators.Parsec parseToNewLine = do line - manyTill anyChar newline return line keyValue = do fieldName - many letter spaces char '=' spaces fieldValue - parseToNewLine return (fieldName,fieldValue) main = parseTest keyValue key=\n I don?t understand why te code above doesn?t parse to (?key?,??) Because the newline is already consumed by the `spaces`. So parseToNewLine gets an empty string as input, and fails on that. parseToNewLine ?\n? parses to ? parseTest keyValue ?a=b\n? works fine and parses to (?a?,?b?) The input of parseToNewLine must contain a newline, or it fails. In the last example, the `spaces` after `char '='` stops at reaching the 'b', so the newline remains. In the first (problematic) example, all the remaining input after the '=' consists of whitespace. -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130202/1583c98b/attachment-0001.htm -- Message: 4 Date: Sun, 3 Feb 2013 12:24:58 +0530 From: Rustom Mody rustompm...@gmail.com Subject: Re: [Haskell-beginners] Literate Haskell - capturing output To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAJ+Teof2R2QU9+geJ7YexRJ=md8g080c+tz28paruxdu-t9...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 On Sat, Feb 2, 2013 at 2:53 AM, Martin Drautzburg
Beginners Digest, Vol 56, Issue 6
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. too lazy parsing? (Kees Bleijenberg) -- Message: 1 Date: Mon, 4 Feb 2013 11:50:24 +0100 From: Kees Bleijenberg k.bleijenb...@lijbrandt.nl Subject: [Haskell-beginners] too lazy parsing? To: beginners@haskell.org Message-ID: 000601ce02c5$6f6d73e0$4e485ba0$@bleijenb...@lijbrandt.nl Content-Type: text/plain; charset=us-ascii module Main where import Text.ParserCombinators.Parsec (many,many1,string, Parser, parse) import System.IO (IOMode(..),hClose,openFile,hGetContents,hPutStrLn) parseFile hOut fn = do handle - openFile fn ReadMode cont - hGetContents handle print cont let res = parse (many (string blah)) cont hClose handle case res of (Left err) - hPutStrLn hOut $ Error: ++ (show err) (Right goodRes) - mapM_ (hPutStrLn hOut) goodRes main = do hOut - openFile outp.txt WriteMode mapM (parseFile hOut) [inp.txt] hClose hOut I'am writing a program that parses a lot of files. Above is the simplest program I can think of that demonstrates my problem. The program above parses inp.txt. Inp.txt has only the word blah in it. The output is saved in outp.txt. This file contains the word blah after running the program. if I comment out the line 'print cont' nothing is saved in outp.txt. If I comment out 'print cont' and replace many with many1 in the following line, it works again? Can someone explain to me what is going on? Kees -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130204/b99d96be/attachment-0001.htm -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 56, Issue 6
Beginners Digest, Vol 56, Issue 7
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: too lazy parsing? (Kyle Murphy) 2. Re: too lazy parsing? (Patrick Mylund Nielsen) 3. Re: too lazy parsing? (Kyle Murphy) -- Message: 1 Date: Mon, 4 Feb 2013 08:00:14 -0500 From: Kyle Murphy orc...@gmail.com Subject: Re: [Haskell-beginners] too lazy parsing? To: beginners beginners@haskell.org Message-ID: CA+y6JcyoQx=xqxbp6vujkju+1r76wff8w2pg4kr_39drp0w...@mail.gmail.com Content-Type: text/plain; charset=utf-8 I can't say 100% for sure, but I'd guess it's because parsec is pure, and the file operations are using lazy bytestrings. Since no IO operations are applied to cont until after you close the handle, nothing can be read (since at that time the handle is closed). If you want to keep the program structured the same I believe there are functions that can convert a lazy bytestring into a strict one, and then you can perform the parsing on that. Alternatively you could rewrite things to close the file handle after you write it's contents to the output file. The default file operations in Haskell are known to be a source of difficulty in terms of laziness, and there has been some debate as to whether they're poorly designed or not. I might suggest you look into some of the alternatives, particular those based on stream fusion principles, that allow you to kill two birds with one stone by iteratively dealing with input thereby forcing evaluation and also improving memory usage and making it harder to trigger space leaks. I don't have the names available at the moment or I'd provide them, but I'm pretty sure at least one of them is named something like enumeratee, although I believe there's at least one other that might debatably be considered better. On Feb 4, 2013 5:51 AM, Kees Bleijenberg k.bleijenb...@lijbrandt.nl wrote: module Main where ** ** import Text.ParserCombinators.Parsec (many,many1,string, Parser, parse)*** * import System.IO (IOMode(..),hClose,openFile,hGetContents,hPutStrLn) parseFile hOut fn = do handle - openFile fn ReadMode cont - hGetContents handle print cont let res = parse (many (string blah)) cont hClose handle case res of (Left err) - hPutStrLn hOut $ Error: ++ (show err) (Right goodRes) - mapM_ (hPutStrLn hOut) goodRes main = do hOut - openFile outp.txt WriteMode mapM (parseFile hOut) [inp.txt] hClose hOut ** ** I?am writing a program that parses a lot of files. Above is the simplest program I can think of that demonstrates my problem. The program above parses inp.txt. Inp.txt has only the word blah in it. The output is saved in outp.txt. This file contains the word blah after running the program. if I comment out the line ?print cont? nothing is saved in outp.txt. If I comment out ?print cont? and replace many with many1 in the following line, it works again? Can someone explain to me what is going on? ** ** Kees ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130204/a4e2ce2b/attachment-0001.htm -- Message: 2 Date: Mon, 4 Feb 2013 14:03:48 +0100 From: Patrick Mylund Nielsen hask...@patrickmylund.com Subject: Re: [Haskell-beginners] too lazy parsing? To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAEw2jfxgy1f7eb4j9p4ZO=i-p09jhgtcxrjzyptjcyj8mhk...@mail.gmail.com Content-Type: text/plain; charset=utf-8 conduit and pipes are two examples: http://hackage.haskell.org/package/conduit http://hackage.haskell.org/package/pipes On Mon, Feb 4, 2013 at 2:00 PM, Kyle Murphy orc...@gmail.com wrote: I can't say 100% for sure, but I'd guess it's because parsec is pure, and the file operations are using lazy bytestrings. Since no IO
Beginners Digest, Vol 56, Issue 10
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: How to improve the accuracy of floating point calculation? (Patrick Mylund Nielsen) 2. Re: How to improve the accuracy of floating point calculation? (Darren Grant) 3. Re: How to improve the accuracy of floating point calculation? (Mateusz Kowalczyk) 4. Re: How to improve the accuracy of floating point calculation? (Mateusz Kowalczyk) 5. Re: How to improve the accuracy of floating point calculation? (Darren Grant) -- Message: 1 Date: Wed, 6 Feb 2013 00:24:26 +0100 From: Patrick Mylund Nielsen hask...@patrickmylund.com Subject: Re: [Haskell-beginners] How to improve the accuracy of floatingpoint calculation? To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAEw2jfyKyr7KW7LMMK5+HsAEFHNJh1u4wUt7tABd-g+Fr=7...@mail.gmail.com Content-Type: text/plain; charset=utf-8 http://floating-point-gui.de/ http://floating-point-gui.de/formats/fp/ http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems On Wed, Feb 6, 2013 at 12:08 AM, KC kc1...@gmail.com wrote: 0.1 cannot be represented exactly in floating point. 0.5 can be represented exactly. Why? On Tue, Feb 5, 2013 at 2:41 PM, yi lu zhiwudazhanjiang...@gmail.com wrote: Hi, I found that in ghci, I input [0.1,0.2..2] and run, I get a result of [0.1,0.2,0.30004,0.4001,0.5001,0.6001,0.7001,0.8,0.9,1.0,1.1,1.2002,1.3003,1.4004,1.5004,1.6005,1.7006,1.8007,1.9008,2.001] But, as you know, it is not the exact answer. So, I wonder if there is something I can do to achieve a better performance and get [0.1,0.2,0.3,0.4..] as the result. Thanks. ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- -- Regards, KC ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130206/8004e377/attachment-0001.htm -- Message: 2 Date: Tue, 5 Feb 2013 16:12:25 -0800 From: Darren Grant therealklu...@gmail.com Subject: Re: [Haskell-beginners] How to improve the accuracy of floatingpoint calculation? To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CA+jD6SivHcp4oG47bFz3aw3HE7fTEdmKrouh1ML=1a4a627...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 I'm not sure how CReal implements its values, but IEEE754 also supports decimal formats preferred for accuracy in many applications. Take a look: http://en.wikipedia.org/wiki/IEEE_floating_point Cheers, d On Tue, Feb 5, 2013 at 3:24 PM, Patrick Mylund Nielsen hask...@patrickmylund.com wrote: http://floating-point-gui.de/ http://floating-point-gui.de/formats/fp/ http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems On Wed, Feb 6, 2013 at 12:08 AM, KC kc1...@gmail.com wrote: 0.1 cannot be represented exactly in floating point. 0.5 can be represented exactly. Why? On Tue, Feb 5, 2013 at 2:41 PM, yi lu zhiwudazhanjiang...@gmail.com wrote: Hi, I found that in ghci, I input [0.1,0.2..2] and run, I get a result of [0.1,0.2,0.30004,0.4001,0.5001,0.6001,0.7001,0.8,0.9,1.0,1.1,1.2002,1.3003,1.4004,1.5004,1.6005,1.7006,1.8007,1.9008,2.001] But, as you know, it is not the exact answer. So, I wonder if there is something I can do to achieve a better performance and get [0.1,0.2,0.3,0.4..] as the result. Thanks. ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- -- Regards, KC ___ Beginners mailing list
Beginners Digest, Vol 56, Issue 12
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: How to improve the accuracy of floating point calculation? (John Wiegley) 2. Re: How to improve the accuracy of floating point calculation? (Brandon Allbery) 3. Can someone help to unnest this do cascade (Martin Drautzburg) 4. Hackages that only depend on Haskell Platform (Darren Grant) -- Message: 1 Date: Wed, 06 Feb 2013 02:31:29 -0600 From: John Wiegley jo...@fpcomplete.com Subject: Re: [Haskell-beginners] How to improve the accuracy of floatingpoint calculation? To: beginners@haskell.org Message-ID: m2a9rhsv1a@newartisans.com Content-Type: text/plain yi lu zhiwudazhanjiang...@gmail.com writes: I'll try CReal. Also try the 'numbers' library. -- John Wiegley FP Complete Haskell tools, training and consulting http://fpcomplete.com johnw on #haskell/irc.freenode.net -- Message: 2 Date: Wed, 6 Feb 2013 09:03:48 -0500 From: Brandon Allbery allber...@gmail.com Subject: Re: [Haskell-beginners] How to improve the accuracy of floatingpoint calculation? To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: cakfcl4xvwxmqd9hvuoefj_szsqqap_shbknd-noyixb0_mr...@mail.gmail.com Content-Type: text/plain; charset=utf-8 On Tue, Feb 5, 2013 at 6:04 PM, yi lu zhiwudazhanjiang...@gmail.com wrote: Thanks! I'll try CReal. But can I set *significant figures **myself?* You can't change ghci's output format, but you can do your own output instead of relying on ghci's. http://hackage.haskell.org/packages/archive/base/latest/doc/html/Text-Printf.htmlmight be of interest, or doing it manually with scaling and Prelude.round. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130206/8d15422c/attachment-0001.htm -- Message: 3 Date: Wed, 6 Feb 2013 22:31:05 +0100 From: Martin Drautzburg martin.drautzb...@web.de Subject: [Haskell-beginners] Can someone help to unnest this do cascade To: beginners@haskell.org Message-ID: 201302062231.05196.martin.drautzb...@web.de Content-Type: Text/Plain; charset=iso-8859-1 Hello all, here is a Code snipped from a Sound.ALSA.Sequencer example (much has been stripped and this code does not do anything). I just don't seem to get it. Can someone please walk me through it and possibly show ways to avoid the massive nesting. dtz = do SndSeq.withDefault SndSeq.Block $ \h - do Client.setName (h :: SndSeq.T SndSeq.DuplexMode) Haskell-Melody Port.withSimple h out (Port.caps [Port.capRead, Port.capSubsRead, Port.capWrite]) (Port.types [Port.typeMidiGeneric, Port.typeApplication]) $ \p - do Queue.with h $ \q - do c - Client.getId h let me = Addr.Cons c p conn - parseDestArgs h me [20:0] Queue.control h q Event.QueueStart Nothing Queue.control h q (Event.QueueTempo (Event.Tempo 1000)) Nothing return () -- Martin -- Message: 4 Date: Wed, 6 Feb 2013 22:37:59 -0800 From: Darren Grant therealklu...@gmail.com Subject: [Haskell-beginners] Hackages that only depend on Haskell Platform To: Haskell Beginners beginners@haskell.org Message-ID: ca+jd6sjaksqp0jq9nxb1jseipqhblpzyjbmupe4vdp4ehan...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 So after encountering the dangers associated with installing many random hackages I am on a mission to cull the herd. So to that effect: Is there a list of hackages available that *only* depend on the latest Haskell Platform? -or- Can such a list be reasonably generated? -or- Will there even be anything left after the hackages are filtered? Apologies if this is in fact already in the archives! Cheers, Darren -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130206/20c0cdf5/attachment-0001.htm
Beginners Digest, Vol 56, Issue 13
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Hackages that only depend on Haskell Platform (Richard Norton) 2. GUI library (Emanuel Koczwara) 3. Re: GUI library (Miguel Negrao) 4. Re: GUI library (Emanuel Koczwara) 5. Re: GUI library (Brandon Allbery) 6. Re: GUI library (Tim Perry) 7. Re: GUI library (Emanuel Koczwara) 8. Re: GUI library (Brandon Allbery) -- Message: 1 Date: Thu, 7 Feb 2013 06:53:12 -0600 From: Richard Norton rwtnor...@gmail.com Subject: Re: [Haskell-beginners] Hackages that only depend on Haskell Platform To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: d9ccaa55-44cc-4cd4-a2f3-ff5d8cad8...@gmail.com Content-Type: text/plain; charset=iso-8859-1 On Feb 7, 2013, at 12:37 AM, Darren Grant therealklu...@gmail.com wrote: Is there a list of hackages available that *only* depend on the latest Haskell Platform? -or- Can such a list be reasonably generated? -or- Will there even be anything left after the hackages are filtered? This project seems related: https://github.com/fpco/stackage Richard -- Message: 2 Date: Thu, 07 Feb 2013 17:10:15 +0100 From: Emanuel Koczwara poc...@emanuelkoczwara.pl Subject: [Haskell-beginners] GUI library To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: 1360253415.2852.1.camel@emanuel-Dell-System-Vostro-3750 Content-Type: text/plain; charset=UTF-8 Hi, Is there a gui library written in haskell (based on purely functional concepts)? Emanuel -- Message: 3 Date: Thu, 7 Feb 2013 17:03:10 + From: Miguel Negrao miguel.negrao-li...@friendlyvirus.org Subject: Re: [Haskell-beginners] GUI library To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: 6989b885-3096-4bbd-8700-5de406204...@friendlyvirus.org Content-Type: text/plain; charset=windows-1252 A 07/02/2013, ?s 16:10, Emanuel Koczwara escreveu: Hi, Is there a gui library written in haskell (based on purely functional concepts)? Emanuel See the High-level part of http://www.haskell.org/haskellwiki/Applications_and_libraries/GUI_libraries Many are not currently developed anymore though. I find reactive-banana together with wxHaskell to have a quite ?functional? feel to it, might be the best option currently. best, Miguel -- Message: 4 Date: Thu, 07 Feb 2013 18:08:55 +0100 From: Emanuel Koczwara poc...@emanuelkoczwara.pl Subject: Re: [Haskell-beginners] GUI library To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: 1360256935.2852.3.camel@emanuel-Dell-System-Vostro-3750 Content-Type: text/plain; charset=UTF-8 Hi, Dnia 2013-02-07, czw o godzinie 17:03 +, Miguel Negrao pisze: A 07/02/2013, ?s 16:10, Emanuel Koczwara escreveu: Hi, Is there a gui library written in haskell (based on purely functional concepts)? Emanuel See the High-level part of http://www.haskell.org/haskellwiki/Applications_and_libraries/GUI_libraries Many are not currently developed anymore though. I find reactive-banana together with wxHaskell to have a quite ?functional? feel to it, might be the best option currently. I'm looking for a library written from scratch in haskell, not high level bindings. Reactive programming isn't well explained. Emanuel -- Message: 5 Date: Thu, 7 Feb 2013 12:32:08 -0500 From: Brandon Allbery allber...@gmail.com Subject: Re: [Haskell-beginners] GUI library To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAKFCL4V=w1xjxcy-hfkq+njcz5f7ydvkobpg5wlvrcuauag...@mail.gmail.com Content-Type: text/plain; charset=utf-8 On Thu, Feb 7, 2013 at 12:08 PM, Emanuel Koczwara poc...@emanuelkoczwara.pl wrote: I'm looking for a library written from scratch in haskell, not high level bindings. Nobody's going to reimplement an entire graphics stack in Haskell (or any other language, except as a tour-de-force with no practical use); they're going to use existing
Beginners Digest, Vol 56, Issue 14
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: GUI library (Tim Perry) 2. Re: GUI library (Emanuel Koczwara) 3. Re: Hackages that only depend on Haskell Platform (Darren Grant) 4. How do I perform things inside a Monad? (Martin Drautzburg) 5. Re: How do I perform things inside a Monad? (Brent Yorgey) 6. Re: How do I perform things inside a Monad? (Martin Drautzburg) 7. Re: Can someone help to unnest this do cascade (Henk-Jan van Tuyl) 8. interface/abstract class: what is the haskellway? (Emmanuel Touzery) -- Message: 1 Date: Thu, 7 Feb 2013 11:04:06 -0800 From: Tim Perry tim.v...@gmail.com Subject: Re: [Haskell-beginners] GUI library To: The Haskell-Beginners Mailing List - Discussion of primarilybeginner-level topics related to Haskell beginners@haskell.org Cc: The Haskell-Beginners Mailing List - Discussion of primarilybeginner-level topics related to Haskell beginners@haskell.org Message-ID: 0ddd6efa-a06b-445e-87f4-52de3809e...@gmail.com Content-Type: text/plain; charset=us-ascii Are you kidding? Swing is a dream. Ever spent time with MFC? Get real On Feb 7, 2013, at 10:59 AM, Brandon Allbery allber...@gmail.com wrote: On Thu, Feb 7, 2013 at 1:46 PM, Tim Perry tim.v...@gmail.com wrote: Java did it. Swing just asks the OS for a window and draws in it. Works fairly well...except that a Java (Swing) It did indeed. I can tell you've not spent much time with the folks who have to deal with the result. AWT/Swing is exhibit A for why nobody else does it that way. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130207/2531cc24/attachment-0001.htm -- Message: 2 Date: Thu, 07 Feb 2013 20:04:17 +0100 From: Emanuel Koczwara poc...@emanuelkoczwara.pl Subject: Re: [Haskell-beginners] GUI library To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: 1360263857.2852.6.camel@emanuel-Dell-System-Vostro-3750 Content-Type: text/plain; charset=UTF-8 Hi, Dnia 2013-02-07, czw o godzinie 13:59 -0500, Brandon Allbery pisze: On Thu, Feb 7, 2013 at 1:46 PM, Tim Perry tim.v...@gmail.com wrote: Java did it. Swing just asks the OS for a window and draws in it. Works fairly well...except that a Java (Swing) It did indeed. I can tell you've not spent much time with the folks who have to deal with the result. AWT/Swing is exhibit A for why nobody else does it that way. And what about QML? Emanuel -- Message: 3 Date: Thu, 7 Feb 2013 12:02:08 -0800 From: Darren Grant therealklu...@gmail.com Subject: Re: [Haskell-beginners] Hackages that only depend on Haskell Platform To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: ca+jd6sju3ppxsprv7sqwhqynsvexvcbj1yk_ls8udnjx701...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 That's a good reference, but what I am exploring is a quick, draconian solution that will give me an extremely conservative set of packages that are not interdependent in any way. It seems that such a program does not yet exist, but should be straightforward to write, joining HackageDB dependencies against packages in the platform. The best I've got so far is to scrape results from cabal info, but I'm looking for a more efficient set of API's to solve the problem. Does the Haskell Platform come with modules that support this sort of API? Cheers, d On Thu, Feb 7, 2013 at 4:53 AM, Richard Norton rwtnor...@gmail.com wrote: On Feb 7, 2013, at 12:37 AM, Darren Grant therealklu...@gmail.com wrote: Is there a list of hackages available that *only* depend on the latest Haskell Platform? -or- Can such a list be reasonably generated? -or- Will there even be anything left after the hackages are filtered?
Beginners Digest, Vol 56, Issue 15
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: How do I perform things inside a Monad? (Daniel Trstenjak) 2. Re: interface/abstract class: what is the haskell way? (Mateusz Kowalczyk) 3. Re: interface/abstract class: what is the haskell way? (Daniel Trstenjak) 4. Mixed typeclasses (Mateusz Neumann) 5. Re: interface/abstract class: what is thehaskell way? (Emmanuel Touzery) 6. Re: interface/abstract class: what is thehaskell way? (Emmanuel Touzery) -- Message: 1 Date: Fri, 8 Feb 2013 12:01:04 +0100 From: Daniel Trstenjak daniel.trsten...@gmail.com Subject: Re: [Haskell-beginners] How do I perform things inside a Monad? To: beginners@haskell.org Message-ID: 20130208110104.GA11149@machine Content-Type: text/plain; charset=us-ascii Hi Martin, On Fri, Feb 08, 2013 at 07:18:38AM +0100, Martin Drautzburg wrote: The thing is, I tried to split this monster up into several functions. For this, my functions got quite a number of parameters. Passing bar baz to the toplevel function would add even more parameters. You might use the where clause: foo bar baz = withFoo doFoo where doFoo foo = do blub withOtherThing doOtherThing doOtherThing thing = do blah something bar baz Greetings, Daniel -- Message: 2 Date: Fri, 08 Feb 2013 10:58:51 + From: Mateusz Kowalczyk fuuze...@fuuzetsu.co.uk Subject: Re: [Haskell-beginners] interface/abstract class: what is the haskell way? To: beginners@haskell.org Message-ID: 5114da6b.9050...@fuuzetsu.co.uk Content-Type: text/plain; charset=ISO-8859-1 Greetings, I have recently asked for a difference between an interface as we know it from OOP and a type class in Haskell. Although it's not an answer to your question, you might find it useful. You can find the conversation archived on gmane at [1] [1] - http://comments.gmane.org/gmane.comp.lang.haskell.beginners/11341 On 08/02/13 09:50, Emmanuel Touzery wrote: Hello, i wrote two programs in haskell which have the same problem: they define a common datatype (let's say Event for instance), and they have several modules, each one importing a list of Event from a specific data source. So all these modules have a similar api: getEvents :: params - IO [Event] And maybe a couple extra functions, more or less the same for each module. In OO, I would make a base class, like EventProvider, with a couple abstract methods and in the main class of my app, I would have a list of EventProvider and loop over them. That way to add a new EventProvider, I would just add the import and an element in that list. Currently in haskell I duplicate the function calls for each provider. And because there is no interface constraint, each module has a slightly different API. The obvious way to do in haskell what I would do in OO would be through type classes. However I realize type classes are not quite interfaces. I'm wondering what would be the haskell way to solve this problem? For sure type classes do the job. But is it the idiomatic way of solving this problem? Thank you! Emmanuel ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- Message: 3 Date: Fri, 8 Feb 2013 12:43:50 +0100 From: Daniel Trstenjak daniel.trsten...@gmail.com Subject: Re: [Haskell-beginners] interface/abstract class: what is the haskell way? To: beginners@haskell.org Message-ID: 20130208114350.GA12726@machine Content-Type: text/plain; charset=us-ascii Hi Emmanuel, On Fri, Feb 08, 2013 at 10:50:30AM +0100, Emmanuel Touzery wrote: The obvious way to do in haskell what I would do in OO would be through type classes. However I realize type classes are not quite interfaces. I'm wondering what would be the haskell way to solve this problem? For sure type classes do the job. But is it the idiomatic way of solving this problem? The problem is, that without the use of extensions it's not possible to have something like: class EventProvider a where events :: a - IO [Event] instance EventProvider Prov1 where ... instance EventProvider Prov2 where ... -- won't compile, because Prov1 and Prov2 have different types providers :: EventProvider a = [a] providers = [Prov1, Prov2] To express
Beginners Digest, Vol 56, Issue 16
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: interface/abstract class: what is the haskell way? (Daniel Trstenjak) 2. Re: interface/abstract class: what is thehaskell way? (Emmanuel Touzery) 3. Re: Mixed typeclasses (Nikita Danilenko) 4. Re: interface/abstract class: what is the haskell way? (Daniel Trstenjak) 5. Re: Mixed typeclasses (Mateusz Neumann) 6. Re: interface/abstract class: what is thehaskell way? (Emmanuel Touzery) -- Message: 1 Date: Fri, 8 Feb 2013 14:24:02 +0100 From: Daniel Trstenjak daniel.trsten...@gmail.com Subject: Re: [Haskell-beginners] interface/abstract class: what is the haskell way? To: beginners@haskell.org Message-ID: 20130208132402.GA20752@machine Content-Type: text/plain; charset=us-ascii Hi Emmanuel, On Fri, Feb 08, 2013 at 01:51:26PM +0100, Emmanuel Touzery wrote: But that way I must still have public getEventProvider() function which returns the record, that I call by convention without some compiler enforcement, which doesn't sound right. In some way you have to tell your program the available providers. How should a compiler enforce this? I think what I am trying to achieve is a very common problem and I maybe suggested a bit too strongly how I would code it in OO languages, maybe it should be arranged completely differently in idiomatic haskell? I think that the 'record of functions' is quite idiomatic Haskell for this use case. Otherwise which Oleg as you talking about, maybe I would read that original post too. I had pretty much the same issue and Oleg gave pretty much the same answer. And there's really only one Oleg ;): http://okmij.org/ftp/ There's no way you could miss him hanging around in Haskell land for some time. Greetings, Daniel -- Message: 2 Date: Fri, 8 Feb 2013 14:31:58 +0100 From: Emmanuel Touzery etouz...@gmail.com Subject: Re: [Haskell-beginners] interface/abstract class: what is the haskell way? To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAC42Re=cAztO_CN=glu1fnrnuxuickoet5dcjeqbv2xocon...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 On Fri, Feb 08, 2013 at 01:51:26PM +0100, Emmanuel Touzery wrote: But that way I must still have public getEventProvider() function which returns the record, that I call by convention without some compiler enforcement, which doesn't sound right. In some way you have to tell your program the available providers. How should a compiler enforce this? It's already pretty good like that but, in an OO language basically if you write a new such module you know you must implement the interface, and that's all you need to know: the type of the interface. Then the compiler enforces all the names of methods and return and parameter types. So all you need to know is the name of the interface. Here there is an interface, the record of functions. But each module must basically define a function returning that record. Sure, the module must implement that function, the same as you must implement it in OO languages, but each module can also make up its mind for the name of the function. I mean it's basically nitpicking at this point, and it's because I'm used to one way. I'm just used that most of the time haskell is better in (almost) every way to OO languages, here I think it's maybe a bit less good, that's all. Emmanuel -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130208/75f9923a/attachment-0001.htm -- Message: 3 Date: Fri, 08 Feb 2013 15:23:51 +0100 From: Nikita Danilenko n...@informatik.uni-kiel.de Subject: Re: [Haskell-beginners] Mixed typeclasses To: beginners@haskell.org Message-ID: 51150a77.90...@informatik.uni-kiel.de Content-Type: text/plain; charset=iso-8859-1 Hi, what you are trying to accomplish is to derive a less specific instance from a more specific one (e.g. trying to derive Eq a, when you have Ord a). While this might seem natural from a mathematical point of view, in Haskell it is not. There are several possible solutions, one of those is given by the error message itself (turn on the language extension FlexibleInstances). Different instances of this general problem are discussed in [1], [2], [3].
Beginners Digest, Vol 56, Issue 17
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Please explain the $ \foo -do idiom (Martin Drautzburg) 2. Re: Please explain the $ \foo -do idiom (Stephen Tetley) -- Message: 1 Date: Sat, 9 Feb 2013 10:41:59 +0100 From: Martin Drautzburg martin.drautzb...@web.de Subject: Re: [Haskell-beginners] Please explain the $ \foo -do idiom To: beginners@haskell.org Message-ID: 201302091042.00215.martin.drautzb...@web.de Content-Type: Text/Plain; charset=iso-8859-15 On Friday, 8. February 2013 08:26:38 Henk-Jan van Tuyl wrote: On Wed, 06 Feb 2013 22:31:05 +0100, Martin Drautzburg martin.drautzb...@web.de wrote: Can someone please walk me through it and possibly show ways to avoid the massive nesting. dtz = do SndSeq.withDefault SndSeq.Block $ \h - do Client.setName (h :: SndSeq.T SndSeq.DuplexMode) Haskell-Melody Port.withSimple h out (Port.caps [Port.capRead, Port.capSubsRead, Port.capWrite]) (Port.types [Port.typeMidiGeneric, Port.typeApplication]) $ \p - do Queue.with h $ \q - do c - Client.getId h let me = Addr.Cons c p conn - parseDestArgs h me [20:0] Queue.control h q Event.QueueStart Nothing Queue.control h q (Event.QueueTempo (Event.Tempo 1000)) Nothing return () I like to divide large functions into several smaller ones: dtz = SndSeq.withDefault SndSeq.Block f1 where f1 h = do Client.setName (h :: SndSeq.T SndSeq.DuplexMode) Haskell-Melody Port.withSimple h out (Port.caps [Port.capRead, Port.capSubsRead, Port.capWrite]) (Port.types [Port.typeMidiGeneric, Port.typeApplication]) (f2 h) f2 h p = Queue.with h (f3 h p) f3 h p q = do c - Client.getId h let me = Addr.Cons c p conn - parseDestArgs h me [20:0] Queue.control h q Event.QueueStart Nothing Queue.control h q (Event.QueueTempo (Event.Tempo 1000)) Nothing return () I tried to do exactly this and I like it a bit better. But note how those functions get quite a number of parameters. In the nested do, evertything was in scope. Things get worse, when I try to run something in the innermost do. When I use individual functions, I need yet another parameter which needs to travel through all these functions. As Brent Yorgey suggested, the nested dos can accept another parameter in the topmost function and it will be automatically in scope all the way down. I really wish, someone could elaboreate on this $ \foo -do pattern, - when it is typically used, - what determines the depth of the nesting, - its pros and cons and the possible alternatives. It seems to be some kind of idiom, -- Martin -- Message: 2 Date: Sat, 9 Feb 2013 10:45:27 + From: Stephen Tetley stephen.tet...@gmail.com Subject: Re: [Haskell-beginners] Please explain the $ \foo -do idiom To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: cab2tprbajh_zofonygwnqscg4pfguspm09762nmpztpj7zm...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 I really wish, someone could elaborate on this $ \foo -do pattern, If you are using it in the IO monad consider it as using a handle (cf. a file handle or network connection) - as you go outside the IO monad you'll note that a handle is really quite a general thing. -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 56, Issue 17 *
Beginners Digest, Vol 56, Issue 18
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Type of a Group. (Robert Goss) 2. Re: Type of a Group. (Rustom Mody) 3. Re: Type of a Group. (Robert Goss) -- Message: 1 Date: Sat, 09 Feb 2013 13:05:12 + From: Robert Goss goss.rob...@gmail.com Subject: [Haskell-beginners] Type of a Group. To: beginners@haskell.org Message-ID: 51164988.1050...@gmail.com Content-Type: text/plain; charset=ISO-8859-1; format=flowed Dear all, Looking to learn a little haskell I tried to program up a little group theory but feel I am stuck on what the types should be. At first it seemed obvious (and the algebra package does this) that the type of a group should be given by: class Group g where mul :: g - g - g inv :: g - g unit :: g My problem is this seems to assume that the type of group you are in is encoded by the type system. I first ran into problems with this when I wanted to define a cyclic group. The only way I could define the type was either to define each cyclic group separately so have C2, C3, C4, ... or parametrise it over the class Nat. So a cyclic group would have the type Cyclic (Succ(Succ( ... Succ(Zero)) ... )) which would consistently define all cyclic groups but is hardly any better. For example a computation mod a large prime p is not going to be pleasant. I came up with a partial solution by realising that a group is defined as a set X and some operations on it to get class Group g x where mul :: g - x - x - x inv :: g- x - x unit :: g - x Making it easy to define cyclic groups and all my old groups carry over. But now to evaluate an expression I need to hang onto the group i am in and pass it around. As i am newish to haskell I wanted to know if I have missed a simpler more obvious way of doing things? All the best, Robert Goss -- Message: 2 Date: Sat, 9 Feb 2013 22:29:37 +0530 From: Rustom Mody rustompm...@gmail.com Subject: Re: [Haskell-beginners] Type of a Group. To: beginners@haskell.org Message-ID: caj+teodftzewu3r+ctprar0_ciba1d3rdwsmhbxsi9fvqhe...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 On Sat, Feb 9, 2013 at 6:35 PM, Robert Goss goss.rob...@gmail.com wrote: Dear all, Looking to learn a little haskell I tried to program up a little group theory but feel I am stuck on what the types should be. At first it seemed obvious (and the algebra package does this) that the type of a group should be given by: class Group g where mul :: g - g - g inv :: g - g unit :: g My problem is this seems to assume that the type of group you are in is encoded by the type system. I first ran into problems with this when I wanted to define a cyclic group. The only way I could define the type was either to define each cyclic group separately so have C2, C3, C4, ... or parametrise it over the class Nat. So a cyclic group would have the type Cyclic (Succ(Succ( ... Succ(Zero)) ... )) which would consistently define all cyclic groups but is hardly any better. For example a computation mod a large prime p is not going to be pleasant. I came up with a partial solution by realising that a group is defined as a set X and some operations on it to get class Group g x where mul :: g - x - x - x inv :: g- x - x unit :: g - x Making it easy to define cyclic groups and all my old groups carry over. But now to evaluate an expression I need to hang onto the group i am in and pass it around. As i am newish to haskell I wanted to know if I have missed a simpler more obvious way of doing things? All the best, Robert Goss Taking your first approach I could do this much: --- class Group g where mul :: g - g - g inv :: g - g unit :: g class Group g = CycGroup g where gen :: g class CycGroup g = FiniteCycGroup g where baseSet :: [g] -- I would have preferred to have order :: Int, to baseSet -- but ghc does not like that for some reason data G2 = A|B instance Group G2 where unit = A inv A = A inv B = B mul A A = A mul A B = B mul B A = B mul B B = A instance CycGroup G2 where gen = B instance FiniteCycGroup G2 where baseSet = [A, B] -- -- http://www.the-magus.in http://blog.languager.org -- next part -- An HTML attachment was scrubbed... URL:
Beginners Digest, Vol 56, Issue 19
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Haskell and Category Theory (Patrick Lynch) 2. Re: Haskell and Category Theory (KC) 3. Re: Haskell and Category Theory (amin...@gmail.com) 4. Re: Haskell and Category Theory (KC) 5. Effective use of nested Monads (David Hinkes) 6. Re: Effective use of nested Monads (Ozgur Akgun) 7. Re: Haskell and Category Theory (Brent Yorgey) 8. Re: Effective use of nested Monads (Brent Yorgey) -- Message: 1 Date: Sun, 10 Feb 2013 12:44:11 -0500 From: Patrick Lynch kmandpjly...@verizon.net Subject: [Haskell-beginners] Haskell and Category Theory To: beginners@haskell.org Message-ID: B3165B70B11F41C185B9F06B6C6E3A46@UserPC Content-Type: text/plain; charset=iso-8859-1 Good morning, I've tried to read 5 books on Category Theory and finally have admitted defeat. What I'm looking for is simply a book that is geared to Haskell and Category that can be understood by mere mortals. I was trained as an Electrical Engineer, so my math is quite good, but I just don't get Category Theory from these books. If anyone can recomment a book on Category Theory and Haskell, written by a Computer Scientest [no more Mathematicians for me], I welcome it. Thanks, Patrick -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130210/8f36a6de/attachment-0001.htm -- Message: 2 Date: Sun, 10 Feb 2013 09:58:18 -0800 From: KC kc1...@gmail.com Subject: Re: [Haskell-beginners] Haskell and Category Theory To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAMLKXy=+RJFBh5w3CAGYF6tKgzxuf43Jnib59axxaHN9Aks=s...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 Category Theory turns function like entities (e.g. procedures - functions with side effects) into functions so that they can be composed like mathematical functions. On Sun, Feb 10, 2013 at 9:44 AM, Patrick Lynch kmandpjly...@verizon.net wrote: Good morning, I've tried to read 5 books on Category Theory and finally have admitted defeat. What I'm looking for is simply a book that is geared to Haskell and Category that can be understood by mere mortals. I was trained as an Electrical Engineer, so my math is quite good, but I just don't get Category Theory from these books. If anyone can recomment a book on Category Theory and Haskell, written by a Computer Scientest [no more Mathematicians for me], I welcome it. Thanks, Patrick ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- -- Regards, KC -- Message: 3 Date: Sun, 10 Feb 2013 13:49:28 -0500 From: amin...@gmail.com Subject: Re: [Haskell-beginners] Haskell and Category Theory To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Cc: beginners@haskell.org beginners@haskell.org Message-ID: 4722d1d6-fc2c-4712-aa62-86b6469bb...@gmail.com Content-Type: text/plain; charset=us-ascii I'm a fan of Basic Category Theory for Computer Scientists, by Benjamin Pierce. I can't say it had an immediate payoff for learning Haskell, but it's been helpful longer-term. Tom On Feb 10, 2013, at 12:44 PM, Patrick Lynch kmandpjly...@verizon.net wrote: Good morning, I've tried to read 5 books on Category Theory and finally have admitted defeat. What I'm looking for is simply a book that is geared to Haskell and Category that can be understood by mere mortals. I was trained as an Electrical Engineer, so my math is quite good, but I just don't get Category Theory from these books. If anyone can recomment a book on Category Theory and Haskell, written by a Computer Scientest [no more Mathematicians for me], I welcome it. Thanks, Patrick ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130210/be484d35/attachment-0001.htm -- Message: 4 Date: Sun, 10 Feb 2013 11:46:42 -0800 From: KC kc1...@gmail.com Subject: Re: [Haskell-beginners] Haskell and
Beginners Digest, Vol 56, Issue 20
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Haskell and Category Theory (Rustom Mody) 2. Re: Haskell and Category Theory (Joe Fredette) 3. Re: Effective use of nested Monads (David Hinkes) -- Message: 1 Date: Mon, 11 Feb 2013 19:01:51 +0530 From: Rustom Mody rustompm...@gmail.com Subject: Re: [Haskell-beginners] Haskell and Category Theory To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAJ+Teoc=yn9awi-7onoclppiywz+rv__wiejhtgdvd_0bp_...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 On Mon, Feb 11, 2013 at 10:37 AM, Brent Yorgey byor...@seas.upenn.eduwrote: On Sun, Feb 10, 2013 at 12:44:11PM -0500, Patrick Lynch wrote: Good morning, I've tried to read 5 books on Category Theory and finally have admitted defeat. What I'm looking for is simply a book that is geared to Haskell and Category that can be understood by mere mortals. I was trained as an Electrical Engineer, so my math is quite good, but I just don't get Category Theory from these books. If anyone can recomment a book on Category Theory and Haskell, written by a Computer Scientest [no more Mathematicians for me], I welcome it. Thanks, Patrick Can you tell us which books you've tried to read? -Brent Well Brent is not going to say it I guess so someone needs to: Typeclassopedia http://www.haskell.org/haskellwiki/Typeclassopedia is required reading -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130211/b8a154b7/attachment-0001.htm -- Message: 2 Date: Mon, 11 Feb 2013 08:47:37 -0500 From: Joe Fredette jfred...@gmail.com Subject: Re: [Haskell-beginners] Haskell and Category Theory To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: e437ea88-0456-4669-bddc-feece93fd...@gmail.com Content-Type: text/plain; charset=iso-8859-1 While we await a reply, I will say that I found Benjamin Pierce's Basic Category Theory for Computer Scientists pretty readable, but will also readily admit my understanding of CT is not particularly deep or great. There are also some videos on youtube, particularly by [error792](1) which are worth watching, though they approach from a more math-oriented perspective (the video-author is a Mathematics Grad Student). One thing that helped me a lot was learning a bit about Combinatorial Species -- I come from a math background, so having something firmly abstract to grab onto wrt examples of CT in use was (and is) useful, Brent has a [nice suite of posts](2) on the matter, and I'm sure will have some book/paper recommendations, I linked to just one of the posts on his blog, I'm sure you can navigate to the others. The trick, I think, to learning CT is to realize it's a lot like Set theory -- there's a lot of abstract nonsense and definition shuffling (which error792's videos, iirc, note as Soft Theorems), and very little (immediate) connection to reality/more concrete tools. However, CT provides a framework of understanding which acts kind of like a highway-of-abstraction. When I can say, A combinatorial species _is_ an endofunctor on the category of Sets and their Bijections, I necessarily know that if I can translate that category into another thing, then I can use my knowledge of species to inform my knowledge of that thing. I'm probably telling this story wrong in some way, perhaps (if we don't mind a bit of thread hijacking) someone can improve my understanding of CT by correcting my likely and inevitable mistakes. /Joe (1) http://www.youtube.com/user/error792 (2) http://byorgey.wordpress.com/2012/11/20/combinatorial-species-definition/ On Mon, Feb 11, 2013 at 10:37 AM, Brent Yorgey byor...@seas.upenn.edu wrote: On Sun, Feb 10, 2013 at 12:44:11PM -0500, Patrick Lynch wrote: Good morning, I've tried to read 5 books on Category Theory and finally have admitted defeat. What I'm looking for is simply a book that is geared to Haskell and Category that can be understood by mere mortals. I was trained as an Electrical Engineer, so my math is quite good, but I just don't get Category Theory from these books. If anyone can recomment a book on Category Theory and Haskell, written by a
Beginners Digest, Vol 56, Issue 21
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Beginners Digest, Vol 56, Issue 20 (Patrick Lynch) 2. Re: Haskell and Category Theory (Simon Peter Nicholls) 3. Re: Beginners Digest, Vol 56, Issue 20 (Rustom Mody) -- Message: 1 Date: Tue, 12 Feb 2013 10:02:14 -0500 From: Patrick Lynch kmandpjly...@verizon.net Subject: Re: [Haskell-beginners] Beginners Digest, Vol 56, Issue 20 To: beginners@haskell.org Message-ID: D3629FB58C9746FC923A0DF55AA62456@UserPC Content-Type: text/plain; format=flowed; charset=iso-8859-1; reply-type=original Good morning, I've actually have 6 books in my library. They are: 1. Algebra Third Edition by MacLane and Birkhoff [I couldn't get anything out of this book] 2. Categories for the Working Mathemetician - Second Edition by Mac Lane [I could get through the first chapter and then gave up] 3. Conceptual Mathematics - A first introduction to categories by Lawvere and Schanuel [The first chapter was understandable but the following chapters were completely undecipherable] 4. Basic Category Theory for Computer Scientists by Pierce [I could get through all three chapters but couldn't do the exercies - and could not see how CT applies to Haskell {especially, Monoids, Monads and Functors}] 5. Categories and Computer Science by Walters [This one made me cry] 6. Category Theory by Awodey [Again, I could only get through the first chapter] I tried viewing the videos by Eugenia Cheng - but I just couldn't follow her presentation. I also viewed another video entitled Hasket and CT - but it was given by a mathematican and I couldn't follow this fellow - I'll have to get the link for this. I finally viewed a video by Brian Beckman in regard to FP [eg: F# and Haskell - and mentions C# as a comparison non-FP language], specifically, in regard to Monoids and it was great - however, he didn't go into CT - but he did recommend that the viewer pursue it. I'm really not interested in all of the categories in the world...I specifically am interested in how CT applies to Hask, Monoids, Monads and Functors. All of the Haskell authors that I've read have 'ducked' the CT issue - mentioning that it is not necessary to understand Haskell. I often was left with the thought: are they correct or do they simply not understand CT. If you know of a Computer Scientist [and, please, not a Mathematician] who has written in regard to Haskell and CT, please let me know. Hopefully, there is a reference that is available that will help me - if not, I plan on revisting my Haskell books [Learn You a Haskell for Great Good!... by Lipovaca and Real World Haskell by O'Sullivan, etal] and focus in on Functors, Monoids, Monads and Hask. I'll also view Brian Beckman's video again and see if I can really follow his example. Thank you - Original Message - From: beginners-requ...@haskell.org To: beginners@haskell.org Sent: Tuesday, February 12, 2013 6:00 AM Subject: Beginners Digest, Vol 56, Issue 20 Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Haskell and Category Theory (Rustom Mody) 2. Re: Haskell and Category Theory (Joe Fredette) 3. Re: Effective use of nested Monads (David Hinkes) -- Message: 1 Date: Mon, 11 Feb 2013 19:01:51 +0530 From: Rustom Mody rustompm...@gmail.com Subject: Re: [Haskell-beginners] Haskell and Category Theory To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAJ+Teoc=yn9awi-7onoclppiywz+rv__wiejhtgdvd_0bp_...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 On Mon, Feb 11, 2013 at 10:37 AM, Brent Yorgey byor...@seas.upenn.eduwrote: On Sun, Feb 10, 2013 at 12:44:11PM -0500, Patrick Lynch wrote: Good morning, I've tried to read 5 books on Category Theory and finally have admitted defeat. What I'm looking for is simply a book that is geared to Haskell and Category that
Beginners Digest, Vol 56, Issue 22
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Beginners Digest, Vol 56, Issue 20 (Brent Yorgey) 2. Re: f . g or f g or f $ g? (Martin Drautzburg) 3. Re: f . g or f g or f $ g? (Emanuel Koczwara) 4. Parsec simple question (Sean Cormican) 5. Re: f . g or f g or f $ g? (Patrick Mylund Nielsen) -- Message: 1 Date: Tue, 12 Feb 2013 14:14:15 -0500 From: Brent Yorgey byor...@seas.upenn.edu Subject: Re: [Haskell-beginners] Beginners Digest, Vol 56, Issue 20 To: beginners@haskell.org Message-ID: 20130212191415.ga5...@seas.upenn.edu Content-Type: text/plain; charset=utf-8 Hi Patrick, I would highly recommend Jeremy Gibbons, Calculating Functional Programs. In Roland Backhouse? Roy Crole and Jeremy Gibbons, editors, Algebraic and Coalgebraic Methods in the Mathematics of Program Construction. Vol. 2297 of Lecture Notes in Computer Science. Pages 148?203. Springer?Verlag. 2002. http://www.cs.ox.ac.uk/publications/publication2360-abstract.html From what you've said it sounds like this is exactly what you're looking for. -Brent On Tue, Feb 12, 2013 at 10:02:14AM -0500, Patrick Lynch wrote: Good morning, I've actually have 6 books in my library. They are: 1. Algebra Third Edition by MacLane and Birkhoff [I couldn't get anything out of this book] 2. Categories for the Working Mathemetician - Second Edition by Mac Lane [I could get through the first chapter and then gave up] 3. Conceptual Mathematics - A first introduction to categories by Lawvere and Schanuel [The first chapter was understandable but the following chapters were completely undecipherable] 4. Basic Category Theory for Computer Scientists by Pierce [I could get through all three chapters but couldn't do the exercies - and could not see how CT applies to Haskell {especially, Monoids, Monads and Functors}] 5. Categories and Computer Science by Walters [This one made me cry] 6. Category Theory by Awodey [Again, I could only get through the first chapter] I tried viewing the videos by Eugenia Cheng - but I just couldn't follow her presentation. I also viewed another video entitled Hasket and CT - but it was given by a mathematican and I couldn't follow this fellow - I'll have to get the link for this. I finally viewed a video by Brian Beckman in regard to FP [eg: F# and Haskell - and mentions C# as a comparison non-FP language], specifically, in regard to Monoids and it was great - however, he didn't go into CT - but he did recommend that the viewer pursue it. I'm really not interested in all of the categories in the world...I specifically am interested in how CT applies to Hask, Monoids, Monads and Functors. All of the Haskell authors that I've read have 'ducked' the CT issue - mentioning that it is not necessary to understand Haskell. I often was left with the thought: are they correct or do they simply not understand CT. If you know of a Computer Scientist [and, please, not a Mathematician] who has written in regard to Haskell and CT, please let me know. Hopefully, there is a reference that is available that will help me - if not, I plan on revisting my Haskell books [Learn You a Haskell for Great Good!... by Lipovaca and Real World Haskell by O'Sullivan, etal] and focus in on Functors, Monoids, Monads and Hask. I'll also view Brian Beckman's video again and see if I can really follow his example. Thank you - Original Message - From: beginners-requ...@haskell.org To: beginners@haskell.org Sent: Tuesday, February 12, 2013 6:00 AM Subject: Beginners Digest, Vol 56, Issue 20 Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Haskell and Category Theory (Rustom Mody) 2. Re: Haskell and Category Theory (Joe Fredette) 3. Re: Effective use of nested Monads (David Hinkes) -- Message: 1 Date: Mon, 11 Feb 2013 19:01:51 +0530 From: Rustom Mody rustompm...@gmail.com Subject: Re:
Beginners Digest, Vol 56, Issue 23
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: f . g or f g or f $ g? (mukesh tiwari) 2. Re: Parsec simple question (Brandon Allbery) 3. Re: f . g or f g or f $ g? (Paul Higham) 4. Re: Beginners Digest, Vol 56, Issue 20 (Michael Orlitzky) 5. Re: f . g or f g or f $ g? (Ertugrul S?ylemez) 6. Re: f . g or f g or f $ g? (Mateusz Kowalczyk) -- Message: 1 Date: Wed, 13 Feb 2013 03:14:32 +0530 From: mukesh tiwari mukeshtiwari.ii...@gmail.com Subject: Re: [Haskell-beginners] f . g or f g or f $ g? To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAFHZvE92uBT8OTnge4ZvB_ybRy-48dnujWM9UXSv=xqbfmm...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 You can write (f . g) x as f . g $ x so for me, it's avoiding extra parenthesis. Mukesh On Wed, Feb 13, 2013 at 2:53 AM, Emanuel Koczwara poc...@emanuelkoczwara.pl wrote: Hi, Dnia 2013-02-12, wto o godzinie 22:09 +0100, Martin Drautzburg pisze: On Friday, 1. February 2013 23:02:39 Ertugrul S?ylemez wrote: (f . g) x = f (g x) so (f . g) x = f $ g x right? That looks like the two are pretty interchangeable. When would I prefer one over the other? ($) has lower precedence (it was introduced for that reason I belive). Prelude :info ($) ($) :: (a - b) - a - b -- Defined in GHC.Base infixr 0 $ Please take a look at: http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.6.0.1/Prelude.html#v:-36- From the docs: Application operator. This operator is redundant, since ordinary application (f x) means the same as (f $ x). However, $ has low, right-associative binding precedence, so it sometimes allows parentheses to be omitted... Emanuel ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130213/787655cb/attachment-0001.htm -- Message: 2 Date: Tue, 12 Feb 2013 17:05:18 -0500 From: Brandon Allbery allber...@gmail.com Subject: Re: [Haskell-beginners] Parsec simple question To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: cakfcl4ujp0qrynj5p6wylju+ja_vnxffj_edkskuxeyejqk...@mail.gmail.com Content-Type: text/plain; charset=utf-8 On Tue, Feb 12, 2013 at 4:38 PM, Sean Cormican seancormic...@gmail.comwrote: name :: Expression name = ID string number :: Expression number = Num 123 whileParser :: Parser Expression whileParser = whiteSpace expr8 expr8 :: Parser Expression expr8 = name | number You have defined name to be an Expression. But | composes *parsers*, not expressions. To create a Parser Expression, you would be composing (Parser Expression)s, not simply (Expression)s; so you don't want name to be simply an Expression, but a Parser that parses an input String and produces an Expression, something like name :: Parser Expression name = ID * identifier -- parse an identifier, wrap it in an ID number :: Parser Expression number = Num * integer -- parse an integer, wrap it in a Num -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130212/664b/attachment-0001.htm -- Message: 3 Date: Tue, 12 Feb 2013 17:35:20 -0800 From: Paul Higham polyg...@mac.com Subject: Re: [Haskell-beginners] f . g or f g or f $ g? To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: d1a826a7-ffd3-472a-8350-b4592e7fb...@mac.com Content-Type: text/plain; charset=iso-8859-1 An example that helped me understand the utility of the $ operator is as follows: suppose that we have a list of functions fs :: [a - b] fs = [f1, f2, ..., fk] and a list of arguments as :: [a] as = [a1, a2, ..., ak] and we
Beginners Digest, Vol 56, Issue 24
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: f . g or f g or f $ g? (Ertugrul S?ylemez) -- Message: 1 Date: Wed, 13 Feb 2013 09:12:11 +0100 From: Ertugrul S?ylemez e...@ertes.de Subject: Re: [Haskell-beginners] f . g or f g or f $ g? To: beginners@haskell.org Message-ID: 20130213091211.094cb...@tritium.streitmacht.eu Content-Type: text/plain; charset=us-ascii Mateusz Kowalczyk fuuze...@fuuzetsu.co.uk wrote: A less obvious interpretation is to treat ($) as `id'. (f . g) x = f $ g x = f (id g x) = f (g x) This is not how you get from ($) to id. The correct path is: f $ x = ($) f x = f x = id f x = f `id` x This equivalence is indicated by the type of ($). It's a specialized instance of a - a: ($) :: (a - b) - (a - b) ($) f = f or equivalently: ($) :: (a - b) - a - b ($) f x = f x or equivalently: ($) :: (a ~ b - c) = a - a ($) = id Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -- next part -- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: http://www.haskell.org/pipermail/beginners/attachments/20130213/6d791810/attachment-0001.pgp -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 56, Issue 24 *
Beginners Digest, Vol 56, Issue 25
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Beginners Digest, Vol 56, Issue 22 (Patrick Lynch) 2. Re: Beginners Digest, Vol 56, Issue 22 (Brandon Allbery) 3. Re: Beginners Digest, Vol 56, Issue 22 (Brent Yorgey) -- Message: 1 Date: Wed, 13 Feb 2013 10:27:12 -0500 From: Patrick Lynch kmandpjly...@verizon.net Subject: Re: [Haskell-beginners] Beginners Digest, Vol 56, Issue 22 To: beginners@haskell.org Message-ID: 9F459825D3074088B9D06F5416B077B4@UserPC Content-Type: text/plain; format=flowed; charset=iso-8859-1; reply-type=original Good morning Brent. Thank you for your recomendation. I went to Amazon and checked the Table of Contents on the book you mentioned... It costs $90 and its not really what I'm looking for. I'm going to approach this from a different direction. It is: 1. I'm looking for a the Haskell definition of the category Hask...If you can help me out here, I'd appreciate it. 2. Functor, Monoid and Monad are all classes in Haskell...I'm going to try to determine how they are related to Hask and to each other. To do this, I'll review my two favorite Haskell books: Real World Haskell by O'Sullivan etal and Learn You a Haskell for Great Good!... by Lipovaca. I'll review Functor, Monoid and Monad in these two books and do the associated exercises [though Lipovaca book does not contain exercises]. Unfortunately, neither book contains an explanation of Hask [and all of the other Haskell books in my library also do not define Hask]. 3. If you know of an online course pertaining to Haskell and CT, I'd appreciate hearing about it. 4. I may, shudder, even consider going back to university and pick up two or three courses in regard to this. I'll let you know how I make out - I'm heading off on a long, long journey Good day, Patrick - Original Message - From: beginners-requ...@haskell.org To: beginners@haskell.org Sent: Tuesday, February 12, 2013 4:43 PM Subject: Beginners Digest, Vol 56, Issue 22 Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Beginners Digest, Vol 56, Issue 20 (Brent Yorgey) 2. Re: f . g or f g or f $ g? (Martin Drautzburg) 3. Re: f . g or f g or f $ g? (Emanuel Koczwara) 4. Parsec simple question (Sean Cormican) 5. Re: f . g or f g or f $ g? (Patrick Mylund Nielsen) -- Message: 1 Date: Tue, 12 Feb 2013 14:14:15 -0500 From: Brent Yorgey byor...@seas.upenn.edu Subject: Re: [Haskell-beginners] Beginners Digest, Vol 56, Issue 20 To: beginners@haskell.org Message-ID: 20130212191415.ga5...@seas.upenn.edu Content-Type: text/plain; charset=utf-8 Hi Patrick, I would highly recommend Jeremy Gibbons, Calculating Functional Programs. In Roland Backhouse? Roy Crole and Jeremy Gibbons, editors, Algebraic and Coalgebraic Methods in the Mathematics of Program Construction. Vol. 2297 of Lecture Notes in Computer Science. Pages 148?203. Springer?Verlag. 2002. http://www.cs.ox.ac.uk/publications/publication2360-abstract.html From what you've said it sounds like this is exactly what you're looking for. -Brent On Tue, Feb 12, 2013 at 10:02:14AM -0500, Patrick Lynch wrote: Good morning, I've actually have 6 books in my library. They are: 1. Algebra Third Edition by MacLane and Birkhoff [I couldn't get anything out of this book] 2. Categories for the Working Mathemetician - Second Edition by Mac Lane [I could get through the first chapter and then gave up] 3. Conceptual Mathematics - A first introduction to categories by Lawvere and Schanuel [The first chapter was understandable but the following chapters were completely undecipherable] 4. Basic Category Theory for Computer Scientists by Pierce [I could get through all three chapters but couldn't do the exercies - and could not see how CT applies to Haskell {especially, Monoids, Monads and Functors}] 5. Categories and Computer Science by Walters [This one made me cry] 6.
Beginners Digest, Vol 56, Issue 26
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: f . g or f g or f $ g? (Mateusz Kowalczyk) -- Message: 1 Date: Wed, 13 Feb 2013 17:50:14 + From: Mateusz Kowalczyk fuuze...@fuuzetsu.co.uk Subject: Re: [Haskell-beginners] f . g or f g or f $ g? To: beginners@haskell.org Message-ID: 511bd256.5060...@fuuzetsu.co.uk Content-Type: text/plain; charset=ISO-8859-1 Oops, you're right. Sorry for my oversight. On 13/02/13 08:12, Ertugrul S?ylemez wrote: Mateusz Kowalczyk fuuze...@fuuzetsu.co.uk wrote: A less obvious interpretation is to treat ($) as `id'. (f . g) x = f $ g x = f (id g x) = f (g x) This is not how you get from ($) to id. The correct path is: f $ x = ($) f x = f x = id f x = f `id` x This equivalence is indicated by the type of ($). It's a specialized instance of a - a: ($) :: (a - b) - (a - b) ($) f = f or equivalently: ($) :: (a - b) - a - b ($) f x = f x or equivalently: ($) :: (a ~ b - c) = a - a ($) = id Greets, Ertugrul ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 56, Issue 26 *
Beginners Digest, Vol 56, Issue 27
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Simple parser question (Martin Drautzburg) 2. Re: Simple parser question (Twan van Laarhoven) -- Message: 1 Date: Thu, 14 Feb 2013 13:59:58 +0100 From: Martin Drautzburg martin.drautzb...@web.de Subject: [Haskell-beginners] Simple parser question To: beginners@haskell.org Message-ID: 201302141359.58339.martin.drautzb...@web.de Content-Type: text/plain; charset=us-ascii Hello all, I just hit a sticking point when trying to parse something like data Exp = Lit Int -- literal integer | Plus Exp Exp where something like 1+2 should be parsed to Plus (Lit 1) (Lit 2). When I try to parse 1+2 my parser enters an infinite loop. I can understand why: it thinks hmm, this expression could be a plus, but then it must start with an expression, lets check. and it tries to parse expression again and again considers Plus. When I change the rules, so it first checks for Lit, it does parse the 1 just fine, but then gives up, because the remainder is not an expression anymore, but just a +2. My parser is written in the style shown in Graham Hutton's book: Parser a :: String - (a, String). I believe I am missing something obvious, but I can't see it. -- Martin -- Message: 2 Date: Thu, 14 Feb 2013 15:23:03 +0100 From: Twan van Laarhoven twa...@gmail.com Subject: Re: [Haskell-beginners] Simple parser question To: beginners@haskell.org Message-ID: 511cf347.9040...@gmail.com Content-Type: text/plain; charset=UTF-8; format=flowed Left-recursion is always a problem for recursive-descend parsers. The solution is to rewrite the parser as: * first always parse an expression without a Plus * followed by zero or more + exp parts. How exactly you write this depends on the combinators that the book defines for writing parsers. In Parsec you would write something like: parseExp = do lit - parseLit pluses - many (parsePlusToken * parseLit) return (combinePlusesWithLit lit pluses) combinePlusesWithLit = foldr Plus -- or foldl I hope you get the idea. Note that the parsec library has functions chainl and chainr that do something like this under the hood, so you would never actually write the above code. Twan On 14/02/13 13:59, Martin Drautzburg wrote: Hello all, I just hit a sticking point when trying to parse something like data Exp = Lit Int -- literal integer | Plus Exp Exp where something like 1+2 should be parsed to Plus (Lit 1) (Lit 2). When I try to parse 1+2 my parser enters an infinite loop. I can understand why: it thinks hmm, this expression could be a plus, but then it must start with an expression, lets check. and it tries to parse expression again and again considers Plus. When I change the rules, so it first checks for Lit, it does parse the 1 just fine, but then gives up, because the remainder is not an expression anymore, but just a +2. My parser is written in the style shown in Graham Hutton's book: Parser a :: String - (a, String). I believe I am missing something obvious, but I can't see it. -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 56, Issue 27 *
Beginners Digest, Vol 56, Issue 28
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Stack overflow folding a map (tcollin371) -- Message: 1 Date: Sat, 16 Feb 2013 04:13:14 -0500 (EST) From: tcollin371 tcollin...@earthlink.net Subject: [Haskell-beginners] Stack overflow folding a map To: Hask beginners@haskell.org Message-ID: 3549819.1361005995070.javamail.r...@elwamui-muscovy.atl.sa.earthlink.net Content-Type: text/plain; charset=UTF-8 I've been playing around with Haskell on and off for a while, and am getting a Stack space overflow that I can't seem to correct. I have a map containing about 2 million items. Actually, it's a map keyed off of an Int where the element is another map keyed off of a string that has three Ints as its data. The number of top level maps is pretty small ( 50), and the maps held by them hold a lot of entries. I want to walk through all of the entries and gather some statistics, but I keep getting the stack overflow. I worked down my test to an inner and outer fold that just counts the entries, and I still get the stack overflow. I added 'seq' calls to make sure that the count isn't building up a bunch of undone operations, and I'm using foldlWithKey, and have also tried foldlWithKey' with the same result. I get the count in my main function and immediately print it out. Here is the relevant code: outputIfNotFilteredCount1 :: Int - KeyMap - PuzzleMapRecord - Int outputIfNotFilteredCount1 inCount key entry = seq inCount (inCount + 1) outputDatabaseCount1 :: Int - Int - InnerDB - Int outputDatabaseCount1 inCount smndCount innerDB = seq inCount (inCount + outCount) where outCount = Map.foldlWithKey' outputIfNotFilteredCount1 0 innerDB main = do ... let count = Map.foldlWithKey' outputDatabaseCount1 0 resultDB putStrLn $ Database entries: ++ (show count) Any thoughts on why this is running out of stack space? -Truman -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 56, Issue 28 *
Beginners Digest, Vol 56, Issue 29
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Stack overflow folding a map (Mateusz Kowalczyk) -- Message: 1 Date: Sat, 16 Feb 2013 16:46:07 + From: Mateusz Kowalczyk fuuze...@fuuzetsu.co.uk Subject: Re: [Haskell-beginners] Stack overflow folding a map To: beginners@haskell.org Message-ID: 511fb7cf.4070...@fuuzetsu.co.uk Content-Type: text/plain; charset=ISO-8859-1 [1] might help you. [1] - http://www.haskell.org/haskellwiki/Foldr_Foldl_Foldl%27 Mateusz K. On 16/02/13 09:13, tcollin371 wrote: I've been playing around with Haskell on and off for a while, and am getting a Stack space overflow that I can't seem to correct. I have a map containing about 2 million items. Actually, it's a map keyed off of an Int where the element is another map keyed off of a string that has three Ints as its data. The number of top level maps is pretty small ( 50), and the maps held by them hold a lot of entries. I want to walk through all of the entries and gather some statistics, but I keep getting the stack overflow. I worked down my test to an inner and outer fold that just counts the entries, and I still get the stack overflow. I added 'seq' calls to make sure that the count isn't building up a bunch of undone operations, and I'm using foldlWithKey, and have also tried foldlWithKey' with the same result. I get the count in my main function and immediately print it out. Here is the relevant code: outputIfNotFilteredCount1 :: Int - KeyMap - PuzzleMapRecord - Int outputIfNotFilteredCount1 inCount key entry = seq inCount (inCount + 1) outputDatabaseCount1 :: Int - Int - InnerDB - Int outputDatabaseCount1 inCount smndCount innerDB = seq inCount (inCount + outCount) where outCount = Map.foldlWithKey' outputIfNotFilteredCount1 0 innerDB main = do ... let count = Map.foldlWithKey' outputDatabaseCount1 0 resultDB putStrLn $ Database entries: ++ (show count) Any thoughts on why this is running out of stack space? -Truman ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 56, Issue 29 *
Beginners Digest, Vol 56, Issue 30
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Stack overflow folding a map (tcollin371) -- Message: 1 Date: Sun, 17 Feb 2013 23:27:56 -0800 (GMT-08:00) From: tcollin371 tcollin...@earthlink.net Subject: Re: [Haskell-beginners] Stack overflow folding a map To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: 26727168.1361172476789.javamail.r...@elwamui-huard.atl.sa.earthlink.net Content-Type: text/plain; charset=UTF-8 It turns out that the problem isn't the counting code in the fold operations, but instead seems to be lazy evaluation that's happening as the map is built. If I run through the count operation every few thousand inserts, then I don't get the stack overflow operation. -Truman -Original Message- From: tcollin371 tcollin...@earthlink.net Sent: Feb 16, 2013 1:13 AM To: Hask beginners@haskell.org Subject: [Haskell-beginners] Stack overflow folding a map I've been playing around with Haskell on and off for a while, and am getting a Stack space overflow that I can't seem to correct. I have a map containing about 2 million items. Actually, it's a map keyed off of an Int where the element is another map keyed off of a string that has three Ints as its data. The number of top level maps is pretty small ( 50), and the maps held by them hold a lot of entries. I want to walk through all of the entries and gather some statistics, but I keep getting the stack overflow. I worked down my test to an inner and outer fold that just counts the entries, and I still get the stack overflow. I added 'seq' calls to make sure that the count isn't building up a bunch of undone operations, and I'm using foldlWithKey, and have also tried foldlWithKey' with the same result. I get the count in my main function and immediately print it out. Here is the relevant code: outputIfNotFilteredCount1 :: Int - KeyMap - PuzzleMapRecord - Int outputIfNotFilteredCount1 inCount key entry = seq inCount (inCount + 1) outputDatabaseCount1 :: Int - Int - InnerDB - Int outputDatabaseCount1 inCount smndCount innerDB = seq inCount (inCount + outCount) where outCount = Map.foldlWithKey' outputIfNotFilteredCount1 0 innerDB main = do ... let count = Map.foldlWithKey' outputDatabaseCount1 0 resultDB putStrLn $ Database entries: ++ (show count) Any thoughts on why this is running out of stack space? -Truman ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 56, Issue 30 *
Beginners Digest, Vol 56, Issue 31
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Simple parser question (Martin Drautzburg) 2. Building with shared libraries on OS X (James Nelson) -- Message: 1 Date: Mon, 18 Feb 2013 21:48:36 +0100 From: Martin Drautzburg martin.drautzb...@web.de Subject: Re: [Haskell-beginners] Simple parser question To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: 201302182148.36204.martin.drautzb...@web.de Content-Type: Text/Plain; charset=iso-8859-1 Thanks, that kind of worked. As long as I am only dealing with literal integers at the beginning of pluses is works fine. *Main parse (1+2+3) Plus (Lit 1) (Plus (Lit 2) (Lit 3)) But this fails already: *Main parse (1+2)+3 Error parse error There is no problem with expressions in parenthes, but my pluses can only start with an integer (even one in parentheses), but not with an expression, since I had to get rid of the expression at the left side, to avoid left- recursion. I am also confused that saying a plus expression is an integer followed by many plus somethings is not what the language says. So this requires a lot of paying attention to get right. I'd much rather say a plus expression is two expressions with a '+' in between. Any other ideas? On Thursday, 14. February 2013 15:23:03 Twan van Laarhoven wrote: Left-recursion is always a problem for recursive-descend parsers. The solution is to rewrite the parser as: * first always parse an expression without a Plus * followed by zero or more + exp parts. How exactly you write this depends on the combinators that the book defines for writing parsers. In Parsec you would write something like: parseExp = do lit - parseLit pluses - many (parsePlusToken * parseLit) return (combinePlusesWithLit lit pluses) combinePlusesWithLit = foldr Plus -- or foldl I hope you get the idea. Note that the parsec library has functions chainl and chainr that do something like this under the hood, so you would never actually write the above code. Twan On 14/02/13 13:59, Martin Drautzburg wrote: Hello all, I just hit a sticking point when trying to parse something like data Exp = Lit Int -- literal integer | Plus Exp Exp where something like 1+2 should be parsed to Plus (Lit 1) (Lit 2). When I try to parse 1+2 my parser enters an infinite loop. I can understand why: it thinks hmm, this expression could be a plus, but then it must start with an expression, lets check. and it tries to parse expression again and again considers Plus. When I change the rules, so it first checks for Lit, it does parse the 1 just fine, but then gives up, because the remainder is not an expression anymore, but just a +2. My parser is written in the style shown in Graham Hutton's book: Parser a :: String - (a, String). I believe I am missing something obvious, but I can't see it. ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- Martin -- Message: 2 Date: Tue, 19 Feb 2013 11:17:24 +0900 From: James Nelson zayd...@gmail.com Subject: [Haskell-beginners] Building with shared libraries on OS X To: beginners@haskell.org Message-ID: 17c8fed0-a1a9-4572-9e4b-603810b3a...@gmail.com Content-Type: text/plain; charset=us-ascii Hi, I've been trying to install Haskell in such a way that I can compile things with the -dynamic option on an OS X machine. It seems that with the standard Haskell Platform, the shared versions of libraries are not included, so enabling the shared option in ~/.cabal/config doesn't work. I've tried installing haskell-platform from scratch with homebrew (with and without --devel), and this hasn't worked either Finally, I've tried re-installing Haskell Platform with the provided .dmg from scratch, but I get errors like: - Perhaps you haven't installed the dyn libraries for package `text-0.11.2.3'? - Codec/Zlib.hs:47:8: Could not find module `Codec.Compression.Zlib' Perhaps you haven't installed the dyn libraries for package `zlib-0.5.4.0'? Is there any way to add the shared libraries to everything included in haskell platform for OS X? Regards, James --
Beginners Digest, Vol 56, Issue 32
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Is my understanding of = correct? (Martin Drautzburg) 2. Re: Is my understanding of = correct? (Bob Ippolito) -- Message: 1 Date: Tue, 19 Feb 2013 20:13:21 +0100 From: Martin Drautzburg martin.drautzb...@web.de Subject: [Haskell-beginners] Is my understanding of = correct? To: beginners@haskell.org Message-ID: 201302192013.21463.martin.drautzb...@web.de Content-Type: text/plain; charset=us-ascii Hello all, It took me quite some time to understand =. What confused me, was that the second operand is a function, not just a Monad. I believe I am beginning to see the light. First there is no way to sequence operations by just writing one after the other. However we can chain operations by passing the output of one operation to the next. But this does not not allow capturing the intermediate results. With = the output of one operation gets magically bound to the parameter of the function and remains in scope all the way through. I was confused by the signature m a - (a - mb) - mb because it looks like there is (as second parameter) a function which returns a Monad. But I doubt I ever saw such a function, in the sense that it does something intelligent. It is typically a function that does not do a whole lot with its parameter, but just returns another Monad, such that its parameter is bound to the result of the previous expression. But it could be done: do x - SomeMonad y - someCleverlyConstructedMonad x If I want to see the function of the = signature I have to read the do block right-left (following the arrow) and then diagonally to the lower right. The diagonal steps reveal the function. In the above example we have \x - someCleverlyConstructedMonad but many times I just see do x - SomeMonad y - someOtherMonad and the function does not do anything intelligent but just binds x and enforces the sequence of operations. is this about right? -- Martin -- Message: 2 Date: Tue, 19 Feb 2013 12:15:54 -0800 From: Bob Ippolito b...@redivi.com Subject: Re: [Haskell-beginners] Is my understanding of = correct? To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: cacwmpm_bzz3bsl40im9b_rusxbrp8j3hvmyxhzoq3utxteo...@mail.gmail.com Content-Type: text/plain; charset=utf-8 On Tue, Feb 19, 2013 at 11:13 AM, Martin Drautzburg martin.drautzb...@web.de wrote: Hello all, It took me quite some time to understand =. What confused me, was that the second operand is a function, not just a Monad. I believe I am beginning to see the light. First there is no way to sequence operations by just writing one after the other. However we can chain operations by passing the output of one operation to the next. But this does not not allow capturing the intermediate results. With = the output of one operation gets magically bound to the parameter of the function and remains in scope all the way through. Well, sequencing actions is a special case of chaining actions where you simply ignore the result of the previous action. This is the operator. It is defined as follows: m k = m = \_ - k There is no magic involved, just functions and lexically scoped variables. I was confused by the signature m a - (a - mb) - mb because it looks like there is (as second parameter) a function which returns a Monad. But I doubt I ever saw such a function, in the sense that it does something intelligent. It is typically a function that does not do a whole lot with its parameter, but just returns another Monad, such that its parameter is bound to the result of the previous expression. I think it's important to note that the signature is a - (a - m b) - m b. The space is significant. 'm' is a separate type variable from 'a' or 'b'. But it could be done: do x - SomeMonad y - someCleverlyConstructedMonad x If I want to see the function of the = signature I have to read the do block right-left (following the arrow) and then diagonally to the lower right. The diagonal steps reveal the function. In the above example we have \x - someCleverlyConstructedMonad but many times I just see do x - SomeMonad y - someOtherMonad and the function does not do anything intelligent but just binds x and enforces the sequence of
Beginners Digest, Vol 56, Issue 33
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. data, records and functions (Emanuel Koczwara) 2. Re: data, records and functions (Darren Grant) 3. Re: data, records and functions (Peter Hall) -- Message: 1 Date: Wed, 20 Feb 2013 22:18:28 +0100 From: Emanuel Koczwara poc...@emanuelkoczwara.pl Subject: [Haskell-beginners] data, records and functions To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: 1361395108.20925.4.camel@emanuel-Dell-System-Vostro-3750 Content-Type: text/plain; charset=UTF-8 Hi, I'm watching Philip Wadler Faith, Evolution, and Programming Languages (very cool by the way): http://www.youtube.com/watch?v=8frGknO8rIg At 00:24:14 there is strange thing on the slide: data Ord a = { less :: a - a - Bool } It's first time I see function type (and where is definition?) in record syntax. Can somebody explain this? Emanuel -- Message: 2 Date: Wed, 20 Feb 2013 14:00:03 -0800 From: Darren Grant therealklu...@gmail.com Subject: Re: [Haskell-beginners] data, records and functions To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: ca+jd6sihqhqkj+b8kmv-lflif+rfntjy+ror0t6othv21w4...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 This is just saying that the type of less is any function that takes two a's as parameters and returns a Bool result. This appears to be a formalization of the Ord (ordered) data type, where less would be used to compare two ordered values and return a Bool result, either True or False. Just a note that the data declaration above is missing a constructor name. It should probably be something like: data Ord a = *Ord* { less :: a - a - Bool } Cheers, Darren On Wed, Feb 20, 2013 at 1:18 PM, Emanuel Koczwara poc...@emanuelkoczwara.pl wrote: Hi, I'm watching Philip Wadler Faith, Evolution, and Programming Languages (very cool by the way): http://www.youtube.com/watch?v=8frGknO8rIg At 00:24:14 there is strange thing on the slide: data Ord a = { less :: a - a - Bool } It's first time I see function type (and where is definition?) in record syntax. Can somebody explain this? Emanuel ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130220/4824f6ed/attachment-0001.htm -- Message: 3 Date: Thu, 21 Feb 2013 02:48:17 + From: Peter Hall peter.h...@memorphic.com Subject: Re: [Haskell-beginners] data, records and functions To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAA6hAk56uSOEgkvCFn5f=uhc1yrqk_tawhax2xyqo7up1_d...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 It's first time I see function type (and where is definition?) in record syntax. Can somebody explain this? There's no definition, it's a parameter to the constructor, so the function can be anything. Taking a much simpler example, you'll be familiar with, if you do: data Foo a = Foo a then the first argument to the Foo constructor also doesn't have a definition. But when you use it to construct a value, then you provide one: myFoo = Foo 3 Likewise, when you construct an Ord value, you supply a function as the value for the 'less' parameter: numOrd = Ord { less = () } or you could use a different function for a different purpose: listLengthOrd = Ord { less = \ a b = length a length b } Hope that helps, Peter On 20 February 2013 21:18, Emanuel Koczwara poc...@emanuelkoczwara.plwrote: Hi, I'm watching Philip Wadler Faith, Evolution, and Programming Languages (very cool by the way): http://www.youtube.com/watch?v=8frGknO8rIg At 00:24:14 there is strange thing on the slide: data Ord a = { less :: a - a - Bool } It's first time I see function type (and where is definition?) in record syntax. Can somebody explain this? Emanuel ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part
Beginners Digest, Vol 56, Issue 35
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: How do I declare a set? (Patrick Mylund Nielsen) 2. The Book (Emanuel Koczwara) 3. Re: The Book (Karol Samborski) 4. Re: The Book (mukesh tiwari) 5. Re: The Book (Brandon Allbery) 6. Re: The Book (Emanuel Koczwara) 7. Re: The Book (Brandon Allbery) -- Message: 1 Date: Fri, 22 Feb 2013 12:12:29 +0100 From: Patrick Mylund Nielsen hask...@patrickmylund.com Subject: Re: [Haskell-beginners] How do I declare a set? To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAEw2jfxSb267ok4r=WAsNzQL1x=yfren1t1mp3sw-e4nqbb...@mail.gmail.com Content-Type: text/plain; charset=utf-8 It is implemented in GHC HEAD: http://hackage.haskell.org/trac/ghc/wiki/OverloadedLists On Fri, Feb 22, 2013 at 2:29 AM, David McBride toa...@gmail.com wrote: At the moment, no. There has been a small push toward an OverloadedLists extension, which would allow you to use list syntax for anything that has a fromList (there would probably be an IsList class similar to the IsString class). I'm not sure where that has gone. I know there were several competing implementations. On Thu, Feb 21, 2013 at 6:43 PM, Heinrich Ody heinrich@gmail.comwrote: Hi, with [1,2] I can declare a list. Is there a similar notation for sets? Currently the only way I know is 'Set.fromList [1,2]' which is unhandy... Regards, Heinrich ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130222/f314131f/attachment-0001.htm -- Message: 2 Date: Fri, 22 Feb 2013 15:29:49 +0100 From: Emanuel Koczwara poc...@emanuelkoczwara.pl Subject: [Haskell-beginners] The Book To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: 1361543389.12471.7.camel@emanuel-Dell-System-Vostro-3750 Content-Type: text/plain; charset=UTF-8 Hi, I'm looking for one book that explains programming in Haskell. Is there a book that explains everything? It appears that there are many books, but each book is ~200 pages and each explains only basics. I'm looking for one big complete book. (Something like Thinking in C++ or C++ How to program but in Haskell). Emanuel -- Message: 3 Date: Fri, 22 Feb 2013 15:37:32 +0100 From: Karol Samborski edv.ka...@gmail.com Subject: Re: [Haskell-beginners] The Book To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: cace2dtu8taxsrrwjohu2wqwkkj5be14yo6kbk+aj5+cmgue...@mail.gmail.com Content-Type: text/plain; charset=UTF-8 2013/2/22 Emanuel Koczwara poc...@emanuelkoczwara.pl: Hi, I'm looking for one book that explains programming in Haskell. Is there a book that explains everything? It appears that there are many books, but each book is ~200 pages and each explains only basics. I'm looking for one big complete book. (Something like Thinking in C++ or C++ How to program but in Haskell). I think that Real World Haskell (http://book.realworldhaskell.org/read/) is what you're looking for. Karol -- Message: 4 Date: Fri, 22 Feb 2013 20:14:05 +0530 From: mukesh tiwari mukeshtiwari.ii...@gmail.com Subject: Re: [Haskell-beginners] The Book To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: cafhzve8dwkycpazxam2gfux_z5v6yf-9q8emuzsxaobnyav...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Hi Emanuel I haven't read the Thinking in C++ so I can't compare it with any haskell resource but here are some links which you can use for learning 1. http://learnyouahaskell.com/chapters 2. http://book.realworldhaskell.org/ On Fri, Feb 22, 2013 at 7:59 PM, Emanuel Koczwara poc...@emanuelkoczwara.pl wrote: Hi, I'm looking for one book that explains programming in Haskell. Is
Beginners Digest, Vol 56, Issue 37
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. How to extend fuinctions? (Heinrich Ody) 2. Use a list as data for a data type? (Bryce Verdier) 3. Re: How to extend fuinctions? (Brent Yorgey) 4. Re: Use a list as data for a data type? (Brent Yorgey) 5. Re: Use a list as data for a data type? (Brent Yorgey) 6. Re: Use a list as data for a data type? (Bryce Verdier) 7. Re: Use a list as data for a data type? (Michael Orlitzky) 8. Re: Beginners Digest, Vol 56, Issue 33 (xiao Ling) -- Message: 1 Date: Fri, 22 Feb 2013 18:35:19 +0100 From: Heinrich Ody heinrich@gmail.com Subject: [Haskell-beginners] How to extend fuinctions? To: Beginners@haskell.org Message-ID: CAMc+G-=RU333QXTZCuqHs+J1hpsHHpO=lr9mqpa9_z7-kl0...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 Hi, I have a function Delta and two sets S and A. Delta maps some elements from (S x A) to S. How can I extend Delta to some Delta' such that it assigns to every pair in (S x A) that Delta is not defined for a value not occuring in S? Something like: Delta' = if (Delta s a) /= _Undefined_ then Delta s a else if () n where n is the new value. However Delta' should not assign values to pairs not in (S x A). Note: (S x A) is meant to be the set-crossprroduct. Background: I want to learn Haskell by building a small library for Finite State Automata, B?chi Automata etc. I need this extension of Delta for making automata complete. Regards and thanks for reading, Heinrich -- Message: 2 Date: Fri, 22 Feb 2013 10:43:32 -0800 From: Bryce Verdier bryceverd...@gmail.com Subject: [Haskell-beginners] Use a list as data for a data type? To: Beginners@haskell.org Message-ID: 5127bc54.40...@gmail.com Content-Type: text/plain; charset=ISO-8859-1; format=flowed Lets say I have a data type like so: data IpAddress = IpAddress {$ o1 :: !Int,$ o2 :: !Int,$ o3 :: !Int,$ o4 :: !Int$ } deriving (Show)$ which you can create by doing: IpAddress 192 168 1 1 Is there a way to do the same thing with the input data in a list? Like: IpAddress [192,168,1,1] or using some operator (or combination of operators):Like (I'm guessing () isn't in use): IpAddress [192,168,1,1] Thanks in advance, Bryce -- Message: 3 Date: Fri, 22 Feb 2013 14:06:36 -0500 From: Brent Yorgey byor...@seas.upenn.edu Subject: Re: [Haskell-beginners] How to extend fuinctions? To: beginners@haskell.org Message-ID: 20130222190636.ga2...@seas.upenn.edu Content-Type: text/plain; charset=us-ascii On Fri, Feb 22, 2013 at 06:35:19PM +0100, Heinrich Ody wrote: Hi, I have a function Delta and two sets S and A. Delta maps some elements from (S x A) to S. How can I extend Delta to some Delta' such that it assigns to every pair in (S x A) that Delta is not defined for a value not occuring in S? If your function delta is partial, then you should model this in Haskell by having it return a Maybe, i.e. delta :: S - Maybe A Then you can define delta' like this: delta' s a = case delta s a of Nothing - n Just x - x If your function delta really is partial in Haskell (i.e. it sometimes crashes or returns 'undefined') then you cannot implement delta', because there is no way to check whether a function returns undefined. It is not a good idea to have partial functions in Haskell anyway. -Brent -- Message: 4 Date: Fri, 22 Feb 2013 14:07:43 -0500 From: Brent Yorgey byor...@seas.upenn.edu Subject: Re: [Haskell-beginners] Use a list as data for a data type? To: beginners@haskell.org Message-ID: 20130222190743.gb2...@seas.upenn.edu Content-Type: text/plain; charset=us-ascii On Fri, Feb 22, 2013 at 10:43:32AM -0800, Bryce Verdier wrote: Lets say I have a data type like so: data IpAddress = IpAddress {$ o1 :: !Int,$ o2 :: !Int,$ o3 :: !Int,$ o4 :: !Int$ } deriving (Show)$ which you can create by doing: IpAddress 192 168 1 1 Is there a way to do the same thing with the input data in a list? Like: IpAddress [192,168,1,1] or using some operator (or combination of operators):Like (I'm guessing () isn't in use): IpAddress [192,168,1,1] No, there isn't. But you can make a function ipAddress :: [Int] - IpAddress ipAddress [a,b,c,d] = IpAddress a b c d -Brent
Beginners Digest, Vol 56, Issue 38
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Beginners Digest, Vol 56, Issue 33 (Brandon Allbery) 2. Re: Beginners Digest, Vol 56, Issue 33 (Brent Yorgey) 3. Re: Use a list as data for a data type? (Karl Voelker) -- Message: 1 Date: Fri, 22 Feb 2013 19:42:06 -0500 From: Brandon Allbery allber...@gmail.com Subject: Re: [Haskell-beginners] Beginners Digest, Vol 56, Issue 33 To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAKFCL4XKfsLQLKro61ey=_Kxa=j9taz7k_yo13s8akhvlpo...@mail.gmail.com Content-Type: text/plain; charset=utf-8 On Fri, Feb 22, 2013 at 7:27 PM, xiao Ling lingx...@seas.upenn.edu wrote: h :: M Int - M Int - M Int h x y = bind ( \x- g x y ) x where g is g :: Int - W Int - W Int g x y = y = (return . (+x)) for the monad: data M a = M a deriving Show Now I am a little confused, how can you put x in g if it takes an Int as first parameter but x is M Int? Because it's a different x. Lemme rewrite it slightly: h :: M Int - M Int - M Int h x y = bind ( \w - g w y ) x All I did was replace the inner x with w, to demonstrate that it has no relationship to the outer x; the \... - syntax introduces new local bindings unrelated to any outside of it, in this case for w (or what he had x, shadowing the original binding of x within the lambda). -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130222/8a72a12e/attachment-0001.htm -- Message: 2 Date: Fri, 22 Feb 2013 19:44:05 -0500 From: Brent Yorgey byor...@seas.upenn.edu Subject: Re: [Haskell-beginners] Beginners Digest, Vol 56, Issue 33 To: beginners@haskell.org Message-ID: 20130223004405.ga17...@seas.upenn.edu Content-Type: text/plain; charset=us-ascii On Fri, Feb 22, 2013 at 07:27:28PM -0500, xiao Ling wrote: Hi All: How do you define a function of signature h :: M Int - M Int - M Int so that h ( M x ) ( M y ) = M ( x + y ), but without unwrapping the value from the monad? This question is from the article Trivial Monad found at http://blog.sigfpe.com/2007/04/trivial-monad.html. The provided answer is h x y = x = (\x - g x y) Now I am a little confused, how can you put x in g if it takes an Int as first parameter but x is M Int? I think your confusion may stem from the fact that there are *two different* things named 'x' in the above code. The x's on the right hand side of the = shadow the x on the left hand side. This is confusing and poor style; a better way to write it would be h x y = x = (\i - g i y) If you study the type of = you will see that i indeed has type Int, as required for the first argument of g. -Brent -- Message: 3 Date: Fri, 22 Feb 2013 19:48:20 -0800 From: Karl Voelker ktvoel...@gmail.com Subject: Re: [Haskell-beginners] Use a list as data for a data type? To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAFfow0wzUMVne5=j1675ul0uujyw4a3vaaukahp9c86sjxa...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 On Fri, Feb 22, 2013 at 12:40 PM, Bryce Verdier bryceverd...@gmail.comwrote: Brent, Thank you for the responses. I appreciate it. Bummer about there not being some kind of built-in/generic shortcut. Bryce I am curious about what motivated your question, since it's hard to imagine a simpler alternative to writing IpAddress 1 2 3 4. -Karl Voelker -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130222/cd063ba5/attachment-0001.htm -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 56, Issue 38 *
Beginners Digest, Vol 56, Issue 39
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. First code review (Emanuel Koczwara) 2. Re: Beginners Digest, Vol 56, Issue 33 (Kim-Ee Yeoh) 3. GHC warnings (Emanuel Koczwara) 4. Re: GHC warnings (Patrick Mylund Nielsen) 5. Re: First code review (Brent Yorgey) 6. Re: First code review (Emanuel Koczwara) 7. Re: First code review (Brent Yorgey) -- Message: 1 Date: Sat, 23 Feb 2013 16:39:53 +0100 From: Emanuel Koczwara poc...@emanuelkoczwara.pl Subject: [Haskell-beginners] First code review To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: 1361633993.3205.15.camel@emanuel-Dell-System-Vostro-3750 Content-Type: text/plain; charset=UTF-8 Hi, Note: Following code is a solution for a problem from hackerrank.com (Category: Artifical Intelligence / Single Player Games / Bot saves princess). Here is my first Haskell code! Short explanation of the problem: it's standard path finding problem, we have a matrix where 'm' denotes the bot, 'p' denotes the princess and '-' is for empty space. Sample input (grid size followed by the grid itself, where each row is separated by new line): 3 --- -m- p-- Sample output: DOWN LEFT Here is the code: module Main where import Data.List import Data.Maybe type Size = Int type Grid = [String] type Path = [Move] type Heuristic = [[Int]] type Position = (Int,Int) data Move = LEFT | RIGHT | UP | DOWN deriving Show getSize :: IO Size getSize = readLn getGrid :: Size - IO Grid getGrid s = sequence $ replicate s getLine getHeuristic :: Size - Position - Heuristic getHeuristic s p = map (getHeuristic' s p) [0..s-1] getHeuristic' :: Size - Position - Int - [Int] getHeuristic' s p y = map (getHeuristic'' p y) [0..s-1] getHeuristic'' :: Position - Int - Int - Int getHeuristic'' (x2, y2) y1 x1 = abs (x1 - x2) + (abs (y1 - y2)) getPos :: Char - Size - Grid - Position getPos c s g = (i `mod` s, i `div` s) where g' = concat g i = fromJust $ elemIndex c g' getSteps :: Size - Heuristic - Position - Position - Path getSteps s h b p | b == p = [] | otherwise = let (m,b') = getStep s h b in m : (getSteps s h b' p) getStep :: Size - Heuristic - Position - (Move,Position) getStep s h b = head $ sortBy compareCost (getAvailableSteps s h b) where compareCost (_,(x1,y1)) (_,(x2,y2)) = compare (h !! y1 !! x1) (h !! y2 !! x2) getAvailableSteps :: Size - Heuristic - Position - [(Move,Position)] getAvailableSteps s h (x,y) = up ++ down ++ left ++ right where up = if y 0 then [(UP, (x, y - 1))] else [] down = if y (s - 1) then [(DOWN, (x, y + 1))] else [] left = if x 0 then [(LEFT, (x - 1, y))] else [] right = if x (s - 1) then [(RIGHT, (x + 1, y))] else [] main :: IO () main = do size - getSize grid - getGrid size let botPos = getPos 'm' size grid princessPos = getPos 'p' size grid heuristic = getHeuristic size princessPos result = getSteps size heuristic botPos princessPos mapM_ print result Please point out all my mistakes. Emanuel -- Message: 2 Date: Sat, 23 Feb 2013 22:58:55 +0700 From: Kim-Ee Yeoh k...@atamo.com Subject: Re: [Haskell-beginners] Beginners Digest, Vol 56, Issue 33 To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAPY+ZdRcxk7pX4V9O8a2H=gxpe-r5efx9hmpm2tafngxywf...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 On Sat, Feb 23, 2013 at 7:27 AM, xiao Ling lingx...@seas.upenn.edu wrote: How do you define a function of signature h :: M Int - M Int - M Int so that h ( M x ) ( M y ) = M ( x + y ), but without unwrapping the value from the monad? In addition to the fine points that Brent and Brandon have already made, I observe that there seems to be a reservation about unwrapping the value from the monad, which I don't get. Your code is equivalent to h = \mx my - do { x - mx; y - my; return $ x+y; }, which, I suspect, doesn't go well with you because of the unwrapping. Or are you aiming at syntactic compositionality, i.e. point-free style? Once you've hacked Haskell enough, you just reach for the liftM2 combinator and write h = liftM2 (+). -- Kim-Ee -- next part -- An HTML attachment was scrubbed... URL:
Beginners Digest, Vol 56, Issue 40
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: First code review (Erik de Castro Lopo) 2. Mutable variables in do block? (Emanuel Koczwara) 3. Re: Mutable variables in do block? (Ozgur Akgun) -- Message: 1 Date: Sun, 24 Feb 2013 18:29:22 +1100 From: Erik de Castro Lopo mle...@mega-nerd.com Subject: Re: [Haskell-beginners] First code review To: beginners@haskell.org Message-ID: 20130224182922.b14c8369f9b27308395b6...@mega-nerd.com Content-Type: text/plain; charset=US-ASCII Brent Yorgey wrote: Since both the Grid and Heuristic values are created once and then used in a read-only fasion, this is a perfect opportunity to use arrays: see http://hackage.haskell.org/packages/archive/array/latest/doc/html/Data-Array.html Using read-only arrays is really quite simple (as opposed to read/write arrays which require a monad of some sort). Brent, out of curiosity, why Array instead of Data.Vector? Cheers, Erik -- -- Erik de Castro Lopo http://www.mega-nerd.com/ -- Message: 2 Date: Sun, 24 Feb 2013 11:41:00 +0100 From: Emanuel Koczwara poc...@emanuelkoczwara.pl Subject: [Haskell-beginners] Mutable variables in do block? To: beginners@haskell.org Message-ID: 1361702460.3205.32.camel@emanuel-Dell-System-Vostro-3750 Content-Type: text/plain; charset=UTF-8 Hi, 1 main = do 2 line - getLine 3 putStrLn line 4 line - getLine 5 putStrLn line Here I have 'line' first bounded with a value at line 2, and then at line 4. It looks like I can set (or bind) a variable in 'do' block more than once, and it looks like it's a destructive update. But as I'm thinking about this more and more, it appears that the first and second 'line' are just an ordinary immutable variables. Line 4 just hides the 'line' from line 2 (outer lambda). Am I right? Emanuel -- Message: 3 Date: Sun, 24 Feb 2013 10:44:59 + From: Ozgur Akgun ozgurak...@gmail.com Subject: Re: [Haskell-beginners] Mutable variables in do block? To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: calzazpb6t7ues-hmug6mmer_k4zohurhppseotj8uyp3l2r...@mail.gmail.com Content-Type: text/plain; charset=utf-8 Hi, On 24 February 2013 10:41, Emanuel Koczwara poc...@emanuelkoczwara.plwrote: it appears that the first and second 'line' are just an ordinary immutable variables. Line 4 just hides the 'line' from line 2 (outer lambda). Am I right? Exactly. You can try desugaring the do notation to see what's going on even more clearly. Best, Ozgur -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130224/b1f87d15/attachment-0001.htm -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 56, Issue 40 *
Beginners Digest, Vol 56, Issue 41
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Beginners Digest, Vol 56, Issue 33 (Kim-Ee Yeoh) 2. Re: First code review (Brent Yorgey) 3. Re: First code review (Erik de Castro Lopo) -- Message: 1 Date: Sun, 24 Feb 2013 20:16:48 +0700 From: Kim-Ee Yeoh k...@atamo.com Subject: Re: [Haskell-beginners] Beginners Digest, Vol 56, Issue 33 To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAPY+ZdS=6idhnehu+qsl2soor_sgvhsx9uly0wvargtgqft...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 On Sat, Feb 23, 2013 at 10:58 PM, Kim-Ee Yeoh k...@atamo.com wrote: On Sat, Feb 23, 2013 at 7:27 AM, xiao Ling lingx...@seas.upenn.eduwrote: How do you define a function of signature h :: M Int - M Int - M Int so that h ( M x ) ( M y ) = M ( x + y ), but without unwrapping the value from the monad? there seems to be a reservation about unwrapping the value from the monad, which I don't get. It's been pointed out to me that I've completely missed OP's question (which is really about variable names and their scope), my bad. OP linked to sigfpe's article, which is what I should have been critiquing. Dan has contributed a lot of good material about Haskell, and I follow his blog closely. But the Trivial Monad article really isn't one of his best, and he perpetuates the faulty wrapping metaphor that seriously hampers Haskell productivity. I'll write later explaining why and provide a better substitute. -- Kim-Ee -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130224/81343b3b/attachment-0001.htm -- Message: 2 Date: Sun, 24 Feb 2013 09:31:44 -0500 From: Brent Yorgey byor...@seas.upenn.edu Subject: Re: [Haskell-beginners] First code review To: beginners@haskell.org Message-ID: 20130224143144.ga14...@seas.upenn.edu Content-Type: text/plain; charset=us-ascii On Sun, Feb 24, 2013 at 06:29:22PM +1100, Erik de Castro Lopo wrote: Brent Yorgey wrote: Since both the Grid and Heuristic values are created once and then used in a read-only fasion, this is a perfect opportunity to use arrays: see http://hackage.haskell.org/packages/archive/array/latest/doc/html/Data-Array.html Using read-only arrays is really quite simple (as opposed to read/write arrays which require a monad of some sort). Brent, out of curiosity, why Array instead of Data.Vector? No reason other than that I'm more familiar with Array. Upon inspection of Data.Vector it looks like that would indeed be a better choice. -Brent -- Message: 3 Date: Mon, 25 Feb 2013 09:09:32 +1100 From: Erik de Castro Lopo mle...@mega-nerd.com Subject: Re: [Haskell-beginners] First code review To: beginners@haskell.org Message-ID: 20130225090932.2fb82d270dc89101dd13c...@mega-nerd.com Content-Type: text/plain; charset=US-ASCII Brent Yorgey wrote: Brent, out of curiosity, why Array instead of Data.Vector? No reason other than that I'm more familiar with Array. Upon inspection of Data.Vector it looks like that would indeed be a better choice. Thank Brent. That confirms my own choice :-). Erik -- -- Erik de Castro Lopo http://www.mega-nerd.com/ -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 56, Issue 41 *
Beginners Digest, Vol 56, Issue 42
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. unix-2.6.0.1 fails to build on the current haskell platform on the mac (Miguel Negrao) -- Message: 1 Date: Wed, 27 Feb 2013 10:35:26 + From: Miguel Negrao miguel.negrao-li...@friendlyvirus.org Subject: [Haskell-beginners] unix-2.6.0.1 fails to build on the current haskell platform on the mac To: beginners@haskell.org Message-ID: ff0783a0-4600-4959-b190-7a4e53f0f...@friendlyvirus.org Content-Type: text/plain; charset=windows-1252 Hi I?m trying to install iCalendar which depends on some package which depends on unix-2.6.0.1. unix-2.6.0.1 does not build on the mac with ghc 7.4. The issue has been reported at http://hackage.haskell.org/trac/ghc/ticket/7359, but I don?t think it?s fixed yet. It appears unix-2.6.0.1 works fine with ghc 7.6.1 but the current haskell platform comes with 7.4. What are my options ? Should I install ghc 7.6 ? If I do that what else do I have to install/update to make everything functional again ? best, Miguel http://www.friendlyvirus.org/miguelnegrao/ -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 56, Issue 42 *
Beginners Digest, Vol 56, Issue 43
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. System.USB.writeInterrupt -- confused by error message from type system (emacstheviking) 2. Re: System.USB.writeInterrupt -- confused by error message from type system (Karol Samborski) 3. Re: System.USB.writeInterrupt -- confused by error message from type system (Alexander Polakov) 4. Re: System.USB.writeInterrupt -- confused by error message from type system (Alexander Polakov) 5. Re: System.USB.writeInterrupt -- confused by error message from type system (emacstheviking) -- Message: 1 Date: Wed, 27 Feb 2013 11:46:47 + From: emacstheviking obji...@gmail.com Subject: [Haskell-beginners] System.USB.writeInterrupt -- confused by error message from type system To: beginners@haskell.org Message-ID: caeieuukefsdkoyr8ywihkrspggsxsgbfxs_uj6m53axmamt...@mail.gmail.com Content-Type: text/plain; charset=utf-8 Hello, I am building a USB gadget with a HexWax ExpandIO-USB chip, here: http://hexwax.com/Products/expandIO-USB/ The device is working fine (lsusb shows it) and so I thought that in the name of continued training and doing things the hard way, that I would use Haskell to talk to it! I have only ever done USB with 'C' in the past and I am now stuck fighting the type checker. Here is my full code so far, it works in so far as it finds the device, opens and closes a connection and prints out some stuff. I then wanted to send four NUL bytes which elicits the same as a response according to the documentation but I cannot get it to compile. Apologies for it in advance, it's the journey you know, not the arrival, anyway, here it is... module Main where import Data.ByteString.Char8 as BS hiding (putStrLn) import Data.Word (Word16) import Data.Vector as V (filterM, null, (!)) --as V hiding ((++)) import System.USB import System.Environment -- hexwax expandIO-USB default code: 0b40:0132 main :: IO () main = do findHexWax (0xb40,0x132) = \hw - case hw of Just dev - hexwaxGo dev Nothing - putStrLn HexWax device not found findHexWax :: (Word16,Word16) - IO (Maybe Device) findHexWax (cVendor, cProd) = do usbCtx - newCtx usbDevs - getDevices usbCtx setDebug usbCtx PrintWarnings boards - V.filterM (isTarget (cVendor, cProd)) usbDevs case V.null boards of True - return Nothing False - return $ Just $ boards!0 where isTarget :: (Word16, Word16) - Device - IO Bool isTarget (cVendor, cProd) dev = do info - getDeviceDesc dev let vid = deviceVendorId info let vpr = deviceProductId info return $ ((vid, vpr) == (cVendor, cProd)) hexwaxGo :: Device - IO () hexwaxGo dev = withDeviceHandle dev (testBoard dev) testBoard :: Device - DeviceHandle - IO () testBoard dev handle = do putStrLn $ Inspecting device: \ ++ (show dev) ++ \\n -- write 0x00 0x00 0x00 0x00, get back same... let payload = pack \x00\x00\x00\x00 let endPoint = EndpointAddress 0 Out action - writeInterrupt handle endPoint (size, status) - action payload 1000 return () And the error message: Prelude :r [1 of 1] Compiling Main ( usb1.hs, interpreted ) usb1.hs:60:13: Couldn't match expected type `IO t0' with actual type `WriteAction' In the return type of a call of `writeInterrupt' Probable cause: `writeInterrupt' is applied to too few arguments In a stmt of a 'do' block: action - writeInterrupt handle endPoint In the expression: do { putStrLn $ Inspecting device: \ ++ (show dev) ++ \; let payload = pack \NUL\NUL\NUL\NUL; let endPoint = EndpointAddress 0 Out; action - writeInterrupt handle endPoint; } Failed, modules loaded: none. I have spent a few hours trying this and that, my Haskell is improving but not much good if I can't compile my program now is it! So, can anybody point out the error of my ways here please as I just can't see it! Thanks, Sean Charles. PS: Code style comments, alternative ways of making it more concise (but still readable and understandable mind you) are also welcome. -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130227/aa1faeb1/attachment-0001.htm -- Message: 2 Date: Wed, 27 Feb 2013 13:07:29 +0100 From: Karol Samborski edv.ka...@gmail.com Subject: Re: [Haskell-beginners]
Beginners Digest, Vol 56, Issue 45
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: System.USB.writeInterrupt -- confused by error message from type system (emacstheviking) 2. Re: System.USB.writeInterrupt -- confused by error message from type system (David McBride) -- Message: 1 Date: Wed, 27 Feb 2013 21:06:30 + From: emacstheviking obji...@gmail.com Subject: Re: [Haskell-beginners] System.USB.writeInterrupt -- confused by error message from type system To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: caeieuuljty3buvcqmfajif_dnq6u76-cp7erbn0k_5jcdjo...@mail.gmail.com Content-Type: text/plain; charset=utf-8 HURRAH! I have finally got it to compile... I manually deleted the broken packages (I play too much anyway so a tidy up was in order) and it still failed with: [1 of 1] Compiling Main ( usb1.hs, usb1.o ) usb1.hs:64:28: Couldn't match expected type `bytestring-0.9.2.1:Data.ByteString.Internal.ByteString' with actual type `ByteString' In the first argument of `action', namely `payload' In a stmt of a 'do' block: (size, status) - action payload 1000 In the expression: do { putStrLn $ Inspecting device: \ ++ (show dev) ++ \; let payload = BS.replicate 64 '\NUL'; let endPoint = EndpointAddress 0 Out; let action = writeInterrupt handle endPoint; } And I suddenly remembered that despite the clean up I still had two bytestring packages: sean@sean-Dimension-4700 ~/Documents/haskell/usb $ ghc-pkg list bytestring /var/lib/ghc/package.conf.d bytestring-0.9.2.1 /home/sean/.ghc/i386-linux-7.4.2/package.conf.d bytestring-0.10.0.2 So, on the basis that the system is always right and I am always wrong I removed the local one in my home folder: sean@sean-Dimension-4700 ~/Documents/haskell/usb $ ghc-pkg unregister bytestring-0.10.0.2 and then tried again: sean@sean-Dimension-4700 ~/Documents/haskell/usb $ ghc --make usb1.hs Linking usb1 ... sean@sean-Dimension-4700 ~/Documents/haskell/usb $ sudo ./usb1 Inspecting device: Bus 005 Device 002 libusbx: error [submit_bulk_transfer] submiturb failed error -1 errno=2 usb1: IOException * * For me that *is* *success*, it fails because since I wrote it I read the USB docs again and I have to claim the device before I can talk to the endpoint but at least I am now focused on my goal of USB interaction with the Hexwax chip again. A big thanks to everybody, this list is once again proving to be awesome, another happy user walks away :) Thanks everybody, especially Karol, Alexander and David. Sean Charles. *PS: Yes, I am using a a Dell from 2004 because as much as I'd love to but a shiny new iMac I cant bring myself to part with my trusty friend. Hell, I even wrote my own computer language system with it and it's good enough. Shameless plug (http://feltweb.info, site written in FELT!) Still under-way, doing Java with it of late, not finished yet because USB and hardware is more fun right now! * On 27 February 2013 19:21, David McBride toa...@gmail.com wrote: You have this line in your code, but that doesn't correlate to the imports you listed. BS.replicate 64 '\0' import qualified Data.ByteString as B ( ByteString, packCStringLen, drop, length ) import qualified Data.ByteString.Internal as BI ( createAndTrim, createAndTrim' ) import qualified Data.ByteString.Unsafe as BU ( unsafeUseAsCStringLen ) So you must have imported Data.ByteString.Lazy as BS somewhere. Change that to B.replicate and it will probably work. On Wed, Feb 27, 2013 at 11:41 AM, emacstheviking obji...@gmail.comwrote: Karol, Alexander, Thanks for your feedback... I am still a little confused as I shall explain... first of all let's look at the prototype for 'writeInterrupt', writeInterrupt :: DeviceHandle - EndpointAddress - WriteAction To me, that reads a takes a device handle and an endpoint address and returns a WriteAction, and to quote the WriteAction help text verbatim so there is no confusion: type WriteAction = ByteString - Timeout - IO (Size, Status)Source Handy type synonym for write transfers. A WriteAction is a function which takes a ByteString to write and a Timeout. The function returns an IO action which, when exectued(sic), returns the number of bytes that
Beginners Digest, Vol 56, Issue 46
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: System.USB.writeInterrupt -- confused by error message from type system (Brent Yorgey) 2. Re: System.USB.writeInterrupt -- confused by error message from type system (emacstheviking) -- Message: 1 Date: Wed, 27 Feb 2013 16:24:29 -0500 From: Brent Yorgey byor...@seas.upenn.edu Subject: Re: [Haskell-beginners] System.USB.writeInterrupt -- confused by error message from type system To: beginners@haskell.org Message-ID: 20130227212429.ga30...@seas.upenn.edu Content-Type: text/plain; charset=us-ascii On Wed, Feb 27, 2013 at 09:06:30PM +, emacstheviking wrote: HURRAH! I have finally got it to compile... I manually deleted the broken packages (I play too much anyway so a tidy up was in order) and it still failed with: [1 of 1] Compiling Main ( usb1.hs, usb1.o ) usb1.hs:64:28: Couldn't match expected type `bytestring-0.9.2.1:Data.ByteString.Internal.ByteString' with actual type `ByteString' Glad you got it to work! For future reference, the fact that the error message includes a package name and version number (bytestring-0.9.2.1:Data.ByteString.Internal.ByteString instead of just Data.ByteString.Internal.ByteString) is usually a very strong indication that the real problem is multiple versions of the package interfering with one another. -Brent -- Message: 2 Date: Wed, 27 Feb 2013 21:30:21 + From: emacstheviking obji...@gmail.com Subject: Re: [Haskell-beginners] System.USB.writeInterrupt -- confused by error message from type system To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAEiEuUKh+EFHpGfk6NGM2=_z-Bh8HkO=i9pu15gnyo_fmjj...@mail.gmail.com Content-Type: text/plain; charset=utf-8 Thanks for assist Brent!(Always wanted to say that etc). Well, this was the first time that it has ever happened to me and so I guess I didn't appreciate the underlying cause once bitten and all that. Thanks again everybody! :) On 27 February 2013 21:24, Brent Yorgey byor...@seas.upenn.edu wrote: On Wed, Feb 27, 2013 at 09:06:30PM +, emacstheviking wrote: HURRAH! I have finally got it to compile... I manually deleted the broken packages (I play too much anyway so a tidy up was in order) and it still failed with: [1 of 1] Compiling Main ( usb1.hs, usb1.o ) usb1.hs:64:28: Couldn't match expected type `bytestring-0.9.2.1:Data.ByteString.Internal.ByteString' with actual type `ByteString' Glad you got it to work! For future reference, the fact that the error message includes a package name and version number (bytestring-0.9.2.1:Data.ByteString.Internal.ByteString instead of just Data.ByteString.Internal.ByteString) is usually a very strong indication that the real problem is multiple versions of the package interfering with one another. -Brent ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130227/4b7aab08/attachment-0001.htm -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 56, Issue 46 *
Beginners Digest, Vol 57, Issue 1
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Parsec lexeme parsers and whitespace/eol characters (Sean Cormican) 2. Re: Parsec lexeme parsers and whitespace/eol characters (Brent Yorgey) -- Message: 1 Date: Sat, 2 Mar 2013 16:57:14 + From: Sean Cormican seancormic...@gmail.com Subject: [Haskell-beginners] Parsec lexeme parsers and whitespace/eol characters To: beginners@haskell.org Message-ID: caf6xeqcmqhr_mz4e1p0cp_uowkqaw1rcrsbb1pctcvrwoaw...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Hi, I'm working with expressions in which I use parsec libraries lexeme parsers: identifier, integer, whiteSpace etc. I am attempting to parse haskell declarations and I am facing some difficulty when trying to delimit the declarations which span multiple lines using eol character for some reason ( I am led to believe is due to the removal of whitespace with lexemes ) data Express = Seq [Express] | ID String | Num Integer | BoolConst Bool | EmptyList String seqOfExpr8 = do list - (sepBy1 expr8 eol) return $ if length list == 1 then head list else Seq list where Seq list is a data declaration for a list of expression8's The parser works correctly unless trying to parse a lexeme parser token such as an identifier. Upon reading a lexeme token the parser will stop and output all tokens up until and including that token but no tokens past it. Also when trying to separate declarations that span multiple lines, does anyone have an idea on how to achieve this? I have been thinking that the parser should ignore any end line characters that are followed by whitespace ( as whitespace is used in Haskell layout rules ) Any thoughts on how I might solve this would be greatly appreciated! Se?n -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130302/0223749a/attachment-0001.htm -- Message: 2 Date: Sat, 2 Mar 2013 12:33:20 -0500 From: Brent Yorgey byor...@seas.upenn.edu Subject: Re: [Haskell-beginners] Parsec lexeme parsers and whitespace/eol characters To: beginners@haskell.org Message-ID: 20130302173320.ga7...@seas.upenn.edu Content-Type: text/plain; charset=iso-8859-1 Hi Sean, I haven't read your entire message carefully, but I read I am attempting to parse Haskell declarations and I would like to ask: is there a reason you cannot/do not want to use the 'haskell-src-exts' package? -Brent On Sat, Mar 02, 2013 at 04:57:14PM +, Sean Cormican wrote: Hi, I'm working with expressions in which I use parsec libraries lexeme parsers: identifier, integer, whiteSpace etc. I am attempting to parse haskell declarations and I am facing some difficulty when trying to delimit the declarations which span multiple lines using eol character for some reason ( I am led to believe is due to the removal of whitespace with lexemes ) data Express = Seq [Express] | ID String | Num Integer | BoolConst Bool | EmptyList String seqOfExpr8 = do list - (sepBy1 expr8 eol) return $ if length list == 1 then head list else Seq list where Seq list is a data declaration for a list of expression8's The parser works correctly unless trying to parse a lexeme parser token such as an identifier. Upon reading a lexeme token the parser will stop and output all tokens up until and including that token but no tokens past it. Also when trying to separate declarations that span multiple lines, does anyone have an idea on how to achieve this? I have been thinking that the parser should ignore any end line characters that are followed by whitespace ( as whitespace is used in Haskell layout rules ) Any thoughts on how I might solve this would be greatly appreciated! Se?n ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 57, Issue 1
Beginners Digest, Vol 57, Issue 2
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Help with some heavy lifting... (emacstheviking) 2. Re: Help with some heavy lifting... (Bob Ippolito) 3. Re: Help with some heavy lifting... (David McBride) 4. Re: Help with some heavy lifting... (emacstheviking) -- Message: 1 Date: Sun, 3 Mar 2013 18:28:16 + From: emacstheviking obji...@gmail.com Subject: [Haskell-beginners] Help with some heavy lifting... To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: caeieuu+86qp8ekz2xpmr-5+qq5kxs18phxumyn67et6i9rz...@mail.gmail.com Content-Type: text/plain; charset=utf-8 I now have a working USB application that can find, locate and switch LED-s on and off on my Hexwax board, for which I thank all those that helped me out last week. I am now trying to Haskell-ise my code i.e. make it less amateurish with respect to some of its inner workings in a constant drive for inner cleanliness and warm fuzziness etc. When attempting to find the device, I use the System.USB.getDevices function which returns me IO (Vector Device), a list of everything that's currently plugged in and available and I then use Data.Vector.filterM like so: *handleFor ctx (cVendor, cProd) = do usbDevs - getDevices ctx matches - V.filterM (isTarget (cVendor, cProd)) usbDevs case V.null matches of True - return Nothing False - return $ Just $ matches!* *isTarget :: (Word16, Word16) - Device - IO Bool isTarget (vid, pid) dev = do getDeviceDesc dev = \info - return $ (deviceVendorId info, deviceProductId info) == (vid, pid) * but... that is not as efficient as it could be because I could have N devices and then I just throw all but the first. Tut tut. Could do better. If I knew how... well I kind of do but I can't figure it out by myself yet! In the Data.Vector there is Data.Vector.find which is *exactly* what I want with small dent in the bodywork, the predicate function is pure: *find :: (a - Boolhttp://hackage.haskell.org/packages/archive/base/4.6.0.0/doc/html/Data-Bool.html#t:Bool) - Vectorhttp://hackage.haskell.org/packages/archive/vector/0.10.0.1/doc/html/Data-Vector.html#t:Vectora - Maybehttp://hackage.haskell.org/packages/archive/base/4.6.0.0/doc/html/Data-Maybe.html#t:Maybea * So my question is, how do I make it work? I know (but don't yet feel comfortable with) about liftM and all that but in this case I can't see how and where it would work. I know (like Spiderman knows there is danger) that it's crying out for something and the return type is perfect too as it would just match. SO...how can I do it chaps? And as usual... .any comments, style notes, idiomatic pointers(!) etc. are always welcome. Thanks, Sean Charles. -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130303/7e43cfc4/attachment-0001.htm -- Message: 2 Date: Sun, 3 Mar 2013 10:44:07 -0800 From: Bob Ippolito b...@redivi.com Subject: Re: [Haskell-beginners] Help with some heavy lifting... To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: cacwmpm-ax_ajma0ph8wgmsh8rfgjdkgelx6j1zqz8xdrk4x...@mail.gmail.com Content-Type: text/plain; charset=utf-8 I don't know what the performance would look like, but you can freeze the mutable Vector and then just use find. Here's an example: import qualified Data.Vector.Mutable as M import qualified Data.Vector as V main :: IO () main = do v - M.replicate 10 'a' M.write v 2 'b' V.freeze v = print . V.find (=='b') On Sun, Mar 3, 2013 at 10:28 AM, emacstheviking obji...@gmail.com wrote: I now have a working USB application that can find, locate and switch LED-s on and off on my Hexwax board, for which I thank all those that helped me out last week. I am now trying to Haskell-ise my code i.e. make it less amateurish with respect to some of its inner workings in a constant drive for inner cleanliness and warm fuzziness etc. When attempting to find the device, I use the System.USB.getDevices function which returns me IO (Vector Device), a list of everything that's currently plugged in and available and I then use Data.Vector.filterM like so: *handleFor ctx (cVendor, cProd) = do usbDevs - getDevices ctx matches -
Beginners Digest, Vol 57, Issue 4
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Help with some heavy lifting... (emacstheviking) 2. Re: Help with some heavy lifting... (emacstheviking) -- Message: 1 Date: Mon, 4 Mar 2013 10:08:44 + From: emacstheviking obji...@gmail.com Subject: Re: [Haskell-beginners] Help with some heavy lifting... To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAEiEuULRSkkXeshk9pFOXtajU5oYab=iytC=P+xfBEz=fkk...@mail.gmail.com Content-Type: text/plain; charset=utf-8 For the record... by using Control.Monad.MissingM I have achieved two things... * more concise code * yet more stuff to learn! Here is what i ended up with and I am happy that for me at my current level, that this is clean enough whilst still readable! handleFor :: Ctx - (Word16,Word16) - IO (Maybe Device) handleFor ctx (cVendor, cProd) = do getDevices ctx = \devs - M.findM (isTarget (cVendor, cProd)) $ V.toList devs handlesFor :: Ctx - (Word16, Word16) - IO (Vector Device) handlesFor ctx (vendorId, productId) = do getDevices ctx = \devs - V.filterM (isTarget (vendorId, productId)) devs isTarget :: (Word16, Word16) - Device - IO Bool isTarget (vid, pid) dev = do info - getDeviceDesc dev return $ (deviceVendorId info, deviceProductId info) == (vid, pid)* * If I feel braver later I may try to convert some of it to point-free style just to see if I can but to be honest I find that hard to read in all but the simplest and most obvious compositions. Once again a big thank-you to everybody for their time. Sean. On 4 March 2013 02:04, David McBride toa...@gmail.com wrote: Hoogle only indexes some small subset of libraries, while hayoo indexes everything on hackage. Unfortunately it seems like peoples' first inclination is to visit hoogle because hey, it's like google right? But in fact hayoo is far better unless you know what you are looking for something in the core libraries. I think there is some technical merit behind hoogle, like being able to search for function prototypes, and I do know you can make your own hoogle command line searcher to search libraries installed on your machine. But usually you are searching for something you don't already have. An actual google search comes up with http://hackage.haskell.org/packages/archive/MissingM/0.0.4/doc/html/Control-Monad-MissingM.htmlwhich actually has findM proving my point that others have felt its absense in the standard library. On Sun, Mar 3, 2013 at 5:24 PM, emacstheviking obji...@gmail.com wrote: David, Hoogle doesn't appear to have any matches for findM that I could find. Your code is pretty close to what I came up with this morning except yours is clever with monads and mine was just boring recursing through the list till I hit a match. This solution of yours looks like it is in the spirit of what I think I saw in my mind so I am going to study it very hard and understand it! Sometimes you just have to grind it out! Thanks. On 3 March 2013 19:46, David McBride toa...@gmail.com wrote: I would probably go (untested): ... usbDevs - ... matches - findM (isTarget foo) $ V.toList usbDevs ... where findM :: Monad m = (a - m Boolean) - [a] - m (Maybe a) findM _ [] = return Nothing findM f (x:xs) = do b - f x return $ if b then Just x else findM f xs I can almost guarantee you there is a findM already out there somewhere to use, but hayoo is down right now so I can't search for it. On Sun, Mar 3, 2013 at 1:28 PM, emacstheviking obji...@gmail.comwrote: I now have a working USB application that can find, locate and switch LED-s on and off on my Hexwax board, for which I thank all those that helped me out last week. I am now trying to Haskell-ise my code i.e. make it less amateurish with respect to some of its inner workings in a constant drive for inner cleanliness and warm fuzziness etc. When attempting to find the device, I use the System.USB.getDevices function which returns me IO (Vector Device), a list of everything that's currently plugged in and available and I then use Data.Vector.filterM like so: *handleFor ctx (cVendor, cProd) = do usbDevs - getDevices ctx matches - V.filterM (isTarget (cVendor, cProd)) usbDevs case V.null matches of True - return Nothing False -
Beginners Digest, Vol 57, Issue 6
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Parsec lexeme parsers and whitespace/eol characters (Brent Yorgey) 2. Converting a function to - Writer w a (Franco) 3. Re: Converting a function to - Writer w a (David McBride) 4. Re: System.USB.writeInterrupt -- confused by error message from type system (Bas van Dijk) -- Message: 1 Date: Wed, 6 Mar 2013 15:17:47 -0500 From: Brent Yorgey byor...@seas.upenn.edu Subject: Re: [Haskell-beginners] Parsec lexeme parsers and whitespace/eol characters To: beginners@haskell.org Cc: Sean Cormican seancormic...@gmail.com Message-ID: 20130306201747.gb20...@seas.upenn.edu Content-Type: text/plain; charset=us-ascii On Mon, Mar 04, 2013 at 10:13:37AM +, Sean Cormican wrote: Hi Brent, I have been trying to use Parsec because there is more documentation and tutorials on using it. I am extremely limited as a functional programmer and just as bad as an actual programmer. I am currently 18 days away from the due date for this project and I have made little or no progress due to my lack of ability, would src-exts be difficult to pick up and use? haskell-src-exts works extremely well, and it's not too hard to find your way around it using the Haddock documentation. Start here: http://hackage.haskell.org/packages/archive/haskell-src-exts/1.13.5/doc/html/Language-Haskell-Exts.html Use one of the functions listed on that page to parse the file, and then click on the types to take you to pages explaining what you get back. For example, if you use parseFile you can see that you get back a (ParseResult Module). Clicking on ParseResult, you can see that a (ParseResult Module) is either (ParseOk m) where m is a Module, or ParseFailed containing an error message. So you can pattern-match to find out which. Then clicking on Module, you can see all the stuff contained in a value of type Module. Keep clicking on types to learn what they are. The biggest difficulty is that since this is a parser for *all of* Haskell, there will be *lots* of stuff that you don't care about. But it might still be easier than trying to write your own parser; I am not sure. -Brent -- Message: 2 Date: Wed, 6 Mar 2013 21:22:09 + From: Franco franc...@gmx.com Subject: [Haskell-beginners] Converting a function to - Writer w a To: beginners@haskell.org Message-ID: 20130306212209.GA31213@efikamx Content-Type: text/plain; charset=us-ascii I am trying to get comfortble with the various monads, just to hone my tools for a better tomorrow. import Control.Monad.Writer import Data.Char ( toLower ) import Text.Regex.Posix ( (=~) ) So I decided to code a very small example to 'get into it'. The following code is extremely simple. Given a string, it will find all occourences of a specific regexp, replace them, and return the changed string back. replaceStuff :: String - String replaceStuff = replaceStuff cs = let (pre, found, post) = cs =~ pattern in pre ++ transf found ++ replaceStuff post where pattern = [A-E] -- some regExp pattern transf = map toLower -- placeholder function main :: IO () main = putStrLn $ replaceStuff this is thE Story of peter Yay, it works! Now let's talk about the Writer monad. I would like to have a mini log via the writer monad (could be anything , probably x found and replaced with y) type Log = String But after that I have no idea how to add the writer monad to my simple but recursive function. Type sig will be something like replaceCols :: String - Writer Log String but I don't know how to replace this part of the non monadic code pre ++ transf found ++ replaceStuff post I wrote this before giving up writer ((pre ++ found ++ ??whathere??), (found ++ found\n)) Probably I am no getting it, so any help is appreciated! Thanks -F -- Message: 3 Date: Wed, 6 Mar 2013 16:51:19 -0500 From: David McBride toa...@gmail.com Subject: Re: [Haskell-beginners] Converting a function to - Writer w a To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: can+tr43nzfchnibzvzxjf2bct0hgk15oargn+ntbru+a6y-...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 It is a little bit roundabout, but here's how you would do a direct translation: import
Beginners Digest, Vol 57, Issue 7
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. FRP (Emanuel Koczwara) 2. Re: FRP (Tom Davie) 3. Re: FRP (Miguel Negrao) 4. Re: [Haskell] Newbie (Brandon Allbery) -- Message: 1 Date: Thu, 07 Mar 2013 19:13:15 +0100 From: Emanuel Koczwara poc...@emanuelkoczwara.pl Subject: [Haskell-beginners] FRP To: beginners@haskell.org Message-ID: 1362679995.3446.2.camel@emanuel-Dell-System-Vostro-3750 Content-Type: text/plain; charset=UTF-8 Hi, I've tried to understund functional reactive programming. No luck so far. Please help. Emanuel -- Message: 2 Date: Thu, 7 Mar 2013 19:27:53 + From: Tom Davie tom.da...@gmail.com Subject: Re: [Haskell-beginners] FRP To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: e72c9e4e-510d-4ab8-9ea3-738760a38...@gmail.com Content-Type: text/plain; charset=us-ascii On 7 Mar 2013, at 18:13, Emanuel Koczwara poc...@emanuelkoczwara.pl wrote: Hi, I've tried to understund functional reactive programming. No luck so far. Please help. Can you explain which part you are struggling to understand? Thanks Tom Davie -- Message: 3 Date: Thu, 7 Mar 2013 21:41:18 + From: Miguel Negrao miguel.negrao-li...@friendlyvirus.org Subject: Re: [Haskell-beginners] FRP To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: cd2678ea-408f-4536-b93d-36ad93747...@friendlyvirus.org Content-Type: text/plain; charset=iso-8859-1 A 07/03/2013, ?s 18:13, Emanuel Koczwara escreveu: Hi, I've tried to understund functional reactive programming. No luck so far. Please help. Emanuel Which type ? Classic FRP, Arrowized FRP, etc ? Also, did you try a specific library (reactive-banana, Yampa, etc) ? best, Miguel -- Message: 4 Date: Thu, 7 Mar 2013 19:56:22 -0500 From: Brandon Allbery allber...@gmail.com Subject: Re: [Haskell-beginners] [Haskell] Newbie To: Dan Lior sitipo...@gmail.com, Haskell Beginners Beginners@haskell.org Cc: hask...@haskell.org Message-ID: cakfcl4vzlmy+n2o9lnriswl3+be8efptdjsc+murjokrqja...@mail.gmail.com Content-Type: text/plain; charset=utf-8 On Thu, Mar 7, 2013 at 7:45 PM, Dan Lior sitipo...@gmail.com wrote: 1) Is this the right place for newbies to post questions about Haskell? This is most a list for announcements; beginners@haskell.org is better for these kinds of questions, and haskell-c...@haskell.org for general discussion. pred :: Int - Int pred 0 = 0 pred n+1 = n n+k patterns were part of Haskell '98, but removed from Haskell 2010. You may be able to use the pragma {-# LANGUAGE NPlusKPatterns #-} to turn them back on. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130307/cf8372ef/attachment-0001.htm -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 57, Issue 7
Beginners Digest, Vol 57, Issue 8
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Performance problem with Haskell/OpenGL/GLFW (Jesper S?rnesj?) 2. Create new value for given type (Heinrich Ody) 3. Re: Create new value for given type (Mateusz Kowalczyk) -- Message: 1 Date: Fri, 8 Mar 2013 23:25:34 +1100 From: Jesper S?rnesj? sarne...@gmail.com Subject: [Haskell-beginners] Performance problem with Haskell/OpenGL/GLFW To: beginners@haskell.org Message-ID: CALex+WhKvebqL4KJnvm3tfwSFByGJ1cSkMAm=upvkf7_w5s...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 Hi there! My first post here. :) I have a curious performance problem with a Haskell/OpenGL/GLFW program that I just can't figure out. The program's CPU usage is quite high in general, and increases with the number of pixels redrawn per frame. It uses OpenGL 3.2, does most of its work on the GPU, and should do a constant amount of work per frame on the CPU, so this makes little sense. I've created a smaller program (still 91 lines, though), which renders a single triangle, but still reproduces this problem. If I make the triangle smaller (by editing vertexData), CPU usage goes down, and if I make it bigger, CPU usage goes up. [1] I've also created a C program which does the same thing (as far as possible), but which does not exhibit this problem. CPU usage is far lower, and stays constant regardless of the number of pixels redrawns per frame. [2] The library functions I use (from OpenGLRaw-1.3.0.0 and GLFW-b-0.1.0.5) are only thin wrappers around their C counterparts, so I strongly believe the problem is in my program. Any thoughts? -- Jesper S?rnesj? http://jesper.sarnesjo.org/ [1] https://gist.github.com/sarnesjo/5116084#file-test-hs [2] https://gist.github.com/sarnesjo/5116084#file-test-c -- Message: 2 Date: Sat, 9 Mar 2013 01:25:17 +0100 From: Heinrich Ody heinrich@gmail.com Subject: [Haskell-beginners] Create new value for given type To: beginners@haskell.org Message-ID: CAMc+G-nZ4tPxhPs=Eg=NjkraBp4=yo79j8zpmurprnvtmgf...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Hi, I'm given a type 'a' (lets assume the type is infinite) and a set finite 'xs'. Now I want to create a new value of type 'a' that does not occur in 'xs' and return a set 'ys' that consists of 'xs' and also contains the new value. How can I do this??? The types are known at compile time, so I would think it is possible in Haskell.. Greetings, Heinrich -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130309/620573fe/attachment-0001.htm -- Message: 3 Date: Sat, 09 Mar 2013 02:10:29 + From: Mateusz Kowalczyk fuuze...@fuuzetsu.co.uk Subject: Re: [Haskell-beginners] Create new value for given type To: beginners@haskell.org Message-ID: 513a9a15.9090...@fuuzetsu.co.uk Content-Type: text/plain; charset=windows-1252 On 09/03/13 00:25, Heinrich Ody wrote: Hi, I'm given a type 'a' (lets assume the type is infinite) and a set finite 'xs'. Now I want to create a new value of type 'a' that does not occur in 'xs' and return a set 'ys' that consists of 'xs' and also contains the new value. How can I do this??? The types are known at compile time, so I would think it is possible in Haskell.. Greetings, Heinrich ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners I just typed out a massive reply after which point I re-read your question and concluded that I misunderstood you? Here's my second shot at it. Note that by no means am I an expert. Long message ahead. The gist of it is: you can't for general case. Well, given just the information you've written down, it's impossible. First of all, we need means of testing whether ?xs? (I'm assuming that ?xs :: Set a?) contains any value of type ?a? we might throw at it. At the very minimum we need the type ?a? to have an instance of the ?Eq?[1] class. Regular caveats of comparing potentially infinite values apply but that's fine as far as the type system is concerned. So your function was called ?generateNewUnique? then we end up taking genBiggerSet :: Set a - Set a to genBiggerSet :: (Eq a) = Set a - Set a I'd like to mention that your ?Set? type might already have such constraint on it: after all, it has to compare the
Beginners Digest, Vol 57, Issue 9
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Performance problem with Haskell/OpenGL/GLFW (Jesper S?rnesj?) 2. Re: Performance problem with Haskell/OpenGL/GLFW (Jesper S?rnesj?) -- Message: 1 Date: Sun, 10 Mar 2013 16:46:58 +1100 From: Jesper S?rnesj? sarne...@gmail.com Subject: Re: [Haskell-beginners] Performance problem with Haskell/OpenGL/GLFW To: beginners@haskell.org Message-ID: calex+wgnlfgepmh4zrzqobuqh4qdvu6+4mo49o5ggybu8ur...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 On Fri, Mar 8, 2013 at 11:25 PM, Jesper S?rnesj? sarne...@gmail.com wrote: The program's CPU usage is quite high in general, and increases with the number of pixels redrawn per frame. It uses OpenGL 3.2, does most of its work on the GPU, and should do a constant amount of work per frame on the CPU, so this makes little sense. I've created a smaller program (still 91 lines, though), which renders a single triangle, but still reproduces this problem. If I make the triangle smaller (by editing vertexData), CPU usage goes down, and if I make it bigger, CPU usage goes up. [1] I've also created a C program which does the same thing (as far as possible), but which does not exhibit this problem. CPU usage is far lower, and stays constant regardless of the number of pixels redrawns per frame. [2] I've figured out what the problem is: the Haskell program is using a software implementation of OpenGL, so rendering *does* in fact happen on the CPU. This seems to happen because I request a renderer conforming to the OpenGL 3.2 Core profile, while running on Mac OS X 10.8.2 [3]. If I remove those lines from displayOptions, the program receives a hardware-accelerated renderer. Of course, then I can't use features from OpenGL 3.2, so that's hardly a solution. It would appear that there is in fact some relevant difference between the Haskell [1] and C [2] versions of my program, or possibly some way in which the bindings from the GLFW-b package are different from the C library. I've updated my programs to check for hardware acceleration and also print the GLFW and OpenGL versions. [4] -- Jesper S?rnesj? http://jesper.sarnesjo.org/ [1] https://gist.github.com/sarnesjo/5116084#file-test-hs [2] https://gist.github.com/sarnesjo/5116084#file-test-c [3] http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_pixelformats/opengl_pixelformats.html [4] https://gist.github.com/sarnesjo/5116084/revisions -- Message: 2 Date: Sun, 10 Mar 2013 20:38:07 +1100 From: Jesper S?rnesj? sarne...@gmail.com Subject: Re: [Haskell-beginners] Performance problem with Haskell/OpenGL/GLFW To: beginners@haskell.org Message-ID: calex+wi0p2ag2fdiangrcafhbm43gz3n5zwzfcmfvgpfi80...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 On Sun, Mar 10, 2013 at 4:46 PM, Jesper S?rnesj? sarne...@gmail.com wrote: I've figured out what the problem is: the Haskell program is using a software implementation of OpenGL, so rendering *does* in fact happen on the CPU. It would appear that there is in fact some relevant difference between the Haskell and C versions of my program, or possibly some way in which the bindings from the GLFW-b package are different from the C library. To remove any possibility of the problem being in GLFW-b or OpenGLRaw, I created two new programs, one in Haskell [1] and one in C [2], that don't import or include anything related to OpenGL, and that simply create a context, check if it is hardware accelerated, and then exit. That is all. And still, the Haskell program receives a software renderer, while the C program receives a hardware one: $ ghc -O2 Test2.hs -lglfw -framework OpenGL -fforce-recomp ./Test2 [1 of 1] Compiling Main ( Test2.hs, Test2.o ) Linking Test2 ... software (2,7,7) (3,2,0) $ gcc -O2 test2.c -lglfw -framework OpenGL ./a.out hardware 2.7.7 3.2.0 I haven't had the chance to run these programs on any OS other than Mac OS X 10.8.2, so I don't know if this problem is Mac-specific. Still, it's really weird that the system would differentiate between Haskell and C programs in this way. If anyone has any ideas about what's going on here, I'd very much like to hear them. -- Jesper S?rnesj? http://jesper.sarnesjo.org/ [1] https://gist.github.com/sarnesjo/5116084#file-test2-hs [2]
Beginners Digest, Vol 57, Issue 11
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Performance problem with Haskell/OpenGL/GLFW (Brandon Allbery) 2. Re: Performance problem with Haskell/OpenGL/GLFW (Hollister Herhold) 3. Re: Create new value for given type (Kim-Ee Yeoh) 4. Re: Performance problem with Haskell/OpenGL/GLFW (Brandon Allbery) 5. Re: Performance problem with Haskell/OpenGL/GLFW (Hollister Herhold) 6. Re: Performance problem with Haskell/OpenGL/GLFW (Hollister Herhold) -- Message: 1 Date: Sun, 10 Mar 2013 13:09:24 -0400 From: Brandon Allbery allber...@gmail.com Subject: Re: [Haskell-beginners] Performance problem with Haskell/OpenGL/GLFW To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: cakfcl4weuya58ic7blbs5v_qdaktx0h9a5lfarj9boxnyfa...@mail.gmail.com Content-Type: text/plain; charset=utf-8 On Sun, Mar 10, 2013 at 5:38 AM, Jesper S?rnesj? sarne...@gmail.com wrote: To remove any possibility of the problem being in GLFW-b or OpenGLRaw, I created two new programs, one in Haskell [1] and one in C [2], that don't import or include anything related to OpenGL, and that simply create a context, check if it is hardware accelerated, and then exit. That is all. And still, the Haskell program receives a software renderer, while the C program receives a hardware one: Check whether the Haskell OpenGL binding is using the X11 libraries instead of native GUI. My (possibly incorrect) understanding is that XQuartz does not yet support OpenGL 3.x directly, so it falls back to software rendering. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130310/87c8d748/attachment-0001.htm -- Message: 2 Date: Sun, 10 Mar 2013 12:27:39 -0500 From: Hollister Herhold hollis...@fafoh.com Subject: Re: [Haskell-beginners] Performance problem with Haskell/OpenGL/GLFW To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: d958f1fc-75e7-476d-9f71-e563fbac8...@fafoh.com Content-Type: text/plain; charset=iso-8859-1 Digging... Is that a configurable thing? On Mar 10, 2013, at 12:09 PM, Brandon Allbery wrote: On Sun, Mar 10, 2013 at 5:38 AM, Jesper S?rnesj? sarne...@gmail.com wrote: To remove any possibility of the problem being in GLFW-b or OpenGLRaw, I created two new programs, one in Haskell [1] and one in C [2], that don't import or include anything related to OpenGL, and that simply create a context, check if it is hardware accelerated, and then exit. That is all. And still, the Haskell program receives a software renderer, while the C program receives a hardware one: Check whether the Haskell OpenGL binding is using the X11 libraries instead of native GUI. My (possibly incorrect) understanding is that XQuartz does not yet support OpenGL 3.x directly, so it falls back to software rendering. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130310/d572c2f2/attachment-0001.htm -- Message: 3 Date: Mon, 11 Mar 2013 01:33:10 +0700 From: Kim-Ee Yeoh k...@atamo.com Subject: Re: [Haskell-beginners] Create new value for given type To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: capy+zdrhncpovuvz1pq1vjelpo_ltf3ognxu_fupfxzfox7...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 On Sat, Mar 9, 2013 at 7:25 AM, Heinrich Ody heinrich@gmail.com wrote: I'm given a type 'a' (lets assume the type is
Beginners Digest, Vol 57, Issue 12
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Create new value for given type (Kim-Ee Yeoh) 2. Re: Performance problem with Haskell/OpenGL/GLFW (Jesper S?rnesj?) 3. Re: Performance problem with Haskell/OpenGL/GLFW (Jesper S?rnesj?) 4. Re: Performance problem with Haskell/OpenGL/GLFW (Hollister Herhold) 5. Trouble in (Fast)CGI land: matching `CGIT IO a0' with actual type `IO ()' (emacstheviking) 6. Re: Trouble in (Fast)CGI land: matching `CGIT IO a0' with actual type `IO ()' (David McBride) -- Message: 1 Date: Mon, 11 Mar 2013 03:48:33 +0700 From: Kim-Ee Yeoh k...@atamo.com Subject: Re: [Haskell-beginners] Create new value for given type To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAPY+ZdRYVFG=z=aACXJQ7p4t39Cc_dx6c4M_zKq8uiBSxF1=7...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 On Mon, Mar 11, 2013 at 1:33 AM, Kim-Ee Yeoh k...@atamo.com wrote: class MyTheory a where someKindOfChoice :: a - [a] - [a] Whoops, that should be [a] - [a], or perhaps more usefully [a] - a. In a way, such a function constructively /proves/ that the type is infinite. Of course, it has to satisfy a bunch of conditions. You can sort of see how going down this path leads naturally to Coq and Agda. -- Kim-Ee -- Message: 2 Date: Mon, 11 Mar 2013 08:11:36 +1100 From: Jesper S?rnesj? sarne...@gmail.com Subject: Re: [Haskell-beginners] Performance problem with Haskell/OpenGL/GLFW To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: calex+wiznqhryvatoaeencmoecnfmyg56+h2ak0uvdkd+l-...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 On Mon, Mar 11, 2013 at 1:31 AM, Andrey Yankin yankin...@gmail.com wrote: AFAIK glfw-b uses its own version of glfw which is built during setup. There is a makefile inside the package. GLFW-b does indeed bundle its own version of the GLFW C library [1], version 2.7.3 as of right now. This is why it can be installed without first installing the C library on your system. However, this is not the library that Test2.hs (nor test2.c) links against. In fact, that program does not use GLFW-b at all, but rather simply declares a few entry points with C calling convention that should be there at linking time. I did this only to be able to rule out any problem with GLFW-b. Can't reproduce this error on Arch. I got the change to run my code on a Windows 7 machine, and didn't see the problem there either. This seems to be specific to Haskell on Mac OS X. -- Jesper S?rnesj? http://jesper.sarnesjo.org/ [1] https://github.com/bsl/GLFW-b/tree/master/glfw -- Message: 3 Date: Mon, 11 Mar 2013 08:23:01 +1100 From: Jesper S?rnesj? sarne...@gmail.com Subject: Re: [Haskell-beginners] Performance problem with Haskell/OpenGL/GLFW To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CALex+Wh2n6=92v1wngpuxzxju855pglwaw3rrxau+nlrcrq...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 On Mon, Mar 11, 2013 at 7:17 AM, Hollister Herhold hollis...@fafoh.com wrote: Okay, I think I just figured this out. Well, HOW to get it working with the accelerated renderer. I was wondering a simple way to check renderer info so I ran glxinfo. This (automatically) fired up X11, and then on a hunch I re-ran Test2 with X11 running and got this: hhmacbook:~/Development/haskell/OpenGL:57 ./Test2 hardware (2,7,7) (3,2,0) hhmacbook:~/Development/haskell/OpenGL:58 AH HA! I then quit X11 and re-ran Test2, and got this: hhmacbook:~/Development/haskell/OpenGL:58 ./Test2 software (2,7,7) (3,2,0) hhmacbook:~/Development/haskell/OpenGL:59 SO- If you want the accelerated renderer, you need to have X11 running. Now, I have no idea WHY this is the case, but there you go. Hope this helps. This lead me down an interesting path. First, I should explain that my machine, like most newish Macs, has two graphics cards. In my case, a discrete Nvidia GeForce GT 330M, and an integrated Intel chip. The former is better, but the latter uses less power, and the system is supposed to switch between them automatically. I used
Beginners Digest, Vol 57, Issue 13
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Beginners Digest, Vol 57, Issue 12 (Francisco Guti?rrez) 2. Re: Trouble in (Fast)CGI land: matching `CGIT IO a0' with actual type `IO ()' (emacstheviking) -- Message: 1 Date: Sun, 10 Mar 2013 18:08:49 -0500 From: Francisco Guti?rrez fgutiers2...@yahoo.com Subject: Re: [Haskell-beginners] Beginners Digest, Vol 57, Issue 12 To: beginners@haskell.org beginners@haskell.org Message-ID: 6a76f254-e63a-4a8e-8bbf-20aafa560...@yahoo.com Content-Type: text/plain; charset=utf-8 Enviado desde mi iPhone El 10/03/2013, a las 18:00, beginners-requ...@haskell.org escribi?: Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Create new value for given type (Kim-Ee Yeoh) 2. Re: Performance problem with Haskell/OpenGL/GLFW (Jesper S?rnesj?) 3. Re: Performance problem with Haskell/OpenGL/GLFW (Jesper S?rnesj?) 4. Re: Performance problem with Haskell/OpenGL/GLFW (Hollister Herhold) 5. Trouble in (Fast)CGI land: matching `CGIT IOa0' with actual type `IO ()' (emacstheviking) 6. Re: Trouble in (Fast)CGI land: matching `CGIT IO a0' with actual type `IO ()' (David McBride) -- Message: 1 Date: Mon, 11 Mar 2013 03:48:33 +0700 From: Kim-Ee Yeoh k...@atamo.com Subject: Re: [Haskell-beginners] Create new value for given type To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAPY+ZdRYVFG=z=aACXJQ7p4t39Cc_dx6c4M_zKq8uiBSxF1=7...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 On Mon, Mar 11, 2013 at 1:33 AM, Kim-Ee Yeoh k...@atamo.com wrote: class MyTheory a where someKindOfChoice :: a - [a] - [a] Whoops, that should be [a] - [a], or perhaps more usefully [a] - a. In a way, such a function constructively /proves/ that the type is infinite. Of course, it has to satisfy a bunch of conditions. You can sort of see how going down this path leads naturally to Coq and Agda. -- Kim-Ee -- Message: 2 Date: Mon, 11 Mar 2013 08:11:36 +1100 From: Jesper S?rnesj? sarne...@gmail.com Subject: Re: [Haskell-beginners] Performance problem with Haskell/OpenGL/GLFW To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: calex+wiznqhryvatoaeencmoecnfmyg56+h2ak0uvdkd+l-...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 On Mon, Mar 11, 2013 at 1:31 AM, Andrey Yankin yankin...@gmail.com wrote: AFAIK glfw-b uses its own version of glfw which is built during setup. There is a makefile inside the package. GLFW-b does indeed bundle its own version of the GLFW C library [1], version 2.7.3 as of right now. This is why it can be installed without first installing the C library on your system. However, this is not the library that Test2.hs (nor test2.c) links against. In fact, that program does not use GLFW-b at all, but rather simply declares a few entry points with C calling convention that should be there at linking time. I did this only to be able to rule out any problem with GLFW-b. Can't reproduce this error on Arch. I got the change to run my code on a Windows 7 machine, and didn't see the problem there either. This seems to be specific to Haskell on Mac OS X. -- Jesper S?rnesj? http://jesper.sarnesjo.org/ [1] https://github.com/bsl/GLFW-b/tree/master/glfw -- Message: 3 Date: Mon, 11 Mar 2013 08:23:01 +1100 From: Jesper S?rnesj? sarne...@gmail.com Subject: Re: [Haskell-beginners] Performance problem with Haskell/OpenGL/GLFW To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CALex+Wh2n6=92v1wngpuxzxju855pglwaw3rrxau+nlrcrq...@mail.gmail.com
Beginners Digest, Vol 57, Issue 14
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Performance problem with Haskell/OpenGL/GLFW (Brandon Allbery) 2. Re: Trouble in (Fast)CGI land: matching `CGIT IO a0' with actual type `IO ()' (David McBride) 3. OpenGLRaw Tutorial (Michael Baker) 4. Using stack inside a function without declaring it as input (doaltan) 5. Re: OpenGLRaw Tutorial (Emanuel Koczwara) 6. Re: OpenGLRaw Tutorial (Mateusz Kowalczyk) -- Message: 1 Date: Sun, 10 Mar 2013 19:44:38 -0400 From: Brandon Allbery allber...@gmail.com Subject: Re: [Haskell-beginners] Performance problem with Haskell/OpenGL/GLFW To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAKFCL4XtTgNUUR9OXhG_2Pw7ZdUd+-i=uv7kygqrbman4ts...@mail.gmail.com Content-Type: text/plain; charset=utf-8 On Sun, Mar 10, 2013 at 6:27 PM, Hollister Herhold hollis...@fafoh.comwrote: I guess running X11 forces use of the NVidia chip. Interesting. Yes; you can see some discussion about it on Apple's X11-Users list, if you care. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130310/e2700f68/attachment-0001.htm -- Message: 2 Date: Sun, 10 Mar 2013 23:31:06 -0400 From: David McBride toa...@gmail.com Subject: Re: [Haskell-beginners] Trouble in (Fast)CGI land: matching `CGIT IO a0' with actual type `IO ()' To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: can+tr40awqq_uvrrcxnwv3zh7550jq2367a9ubwq6g+kk_3...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 Let me put it plainly. I'm not going to explain the theory, just cold hard practicality of how to do what you want to do when you see this in the wild, which you will if you haven't already. Let's call this a pattern in haskell. It is the monad transformer pattern, which you'll see many (possibly even most) libraries use at one time or another once they get past a certain amount of complexity. When you don't understand it, you feel like you can't quite do anything in haskell, at least not without copy paste or lots of random fiddling. But then once you know it, suddenly most of the libraries in the language open up to you. At least that is how it was for me. Whenever you see a library that has a runBlah function which will have a type: Blah a - IO b. Examples: shelly :: MonadIO m = Sh a - m a (from the shelly library) runStateT :: StateT s m a - s - m (a, s) (from control.monad.state) runInputT :: MonadException m = Settings m - InputT m a - m a (from haskeline) runResourceT :: MonadBaseControl IO m = ResourceT m a - m a (from the resourceT package) atomically :: STM a - IO a (from base, from the shared transactional memory related functions) runParserT :: Stream s m t = ParsecT s u m a - u - SourceName - s - m (Either ParseError a) (from parsec) runFastCGI :: CGI CGIResult - IO () (from the fastcgi library) So as you can see they are different, but they all have some similarities in that they all return either IO a, or possibly m a where m has some class restrictions on it. IO will almost always meet those restrictions if you try it. Sometimes they have special arguments to get their environments set up so that they have the info they need to work. Sometimes they don't. What they all have in common is that they all take an argument that sort of lives in a specific type (InputT, ResourceT, ParsecT, Sh, STM, StateT, etc.). Sometimes there are several alternatives with slightly different functionality. If you find a function that returns one of those types, then it was meant to be run as an argument to a function like one of these. Sometimes the types are simplified with type aliases so you don't always recognize them off the bat. Parser a aliases to Parsec String () a which is an alias for ParsecT String () Identity a. In your original message it was the case that CGI CGIResult is an alias for CGIT IO CGIResult, so the base monad was in that case CGIT, and not CGI.
Beginners Digest, Vol 57, Issue 15
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Using stack inside a function without declaring it as input (Krzysztof Skrz?tnicki) 2. Re: Using stack inside a function without declaring it as input (Emanuel Koczwara) -- Message: 1 Date: Mon, 11 Mar 2013 11:15:32 +0100 From: Krzysztof Skrz?tnicki gte...@gmail.com Subject: Re: [Haskell-beginners] Using stack inside a function without declaring it as input To: doaltan doal...@yahoo.co.uk, The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: cam7aevhagkboornwmsu-ghym5sjixxg3haojtdjnya_x72t...@mail.gmail.com Content-Type: text/plain; charset=utf-8 There are some things clearly missing in your description. I think you need to read your problem more carefully and perhaps consult some accompanying materials too. Other than that I see no way one can sensibly answer your question without more information. Best regards, Krzysztof Skrz?tnicki On Mon, Mar 11, 2013 at 10:36 AM, doaltan doal...@yahoo.co.uk wrote: Hi I have a function like this : myfunc :: [Char] - [Char] It is supposed to work pretty much like this : 1. Take a string 2. Put some elements of this input string to output string and put others to stack. 3. Pop elements to that output string too. 4. Do 2 and 3 recursively until stack is empty. 5. Print the output string when stack is empty. I couldn't figure out where to define stack and output string. Can you help me with that? I'm new to Haskell so I can't think in Haskell's logic very well. ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130311/b504dd28/attachment-0001.htm -- Message: 2 Date: Mon, 11 Mar 2013 11:29:27 +0100 From: Emanuel Koczwara poc...@emanuelkoczwara.pl Subject: Re: [Haskell-beginners] Using stack inside a function without declaring it as input To: doaltan doal...@yahoo.co.uk, The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: 1362997767.13571.11.camel@emanuel-Dell-System-Vostro-3750 Content-Type: text/plain; charset=UTF-8 Hi, Dnia 2013-03-11, pon o godzinie 09:36 +, doaltan pisze: Hi I have a function like this : myfunc :: [Char] - [Char] It is supposed to work pretty much like this : 1. Take a string 2. Put some elements of this input string to output string and put others to stack. 3. Pop elements to that output string too. 4. Do 2 and 3 recursively until stack is empty. 5. Print the output string when stack is empty. I couldn't figure out where to define stack and output string. Can you help me with that? I'm new to Haskell so I can't think in Haskell's logic very well. You can try to define a second function inside myfunc with the stack as an argument: myfunc :: String - String myfunc str = myfunc' [] str where myfunc' stack str = ... myfunc' can take the stack as an argument, myfunc can call myfunc' passing the empty stack. You should describe your problem more precisely to get more accurate answers. Emanuel -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 57, Issue 15 *
Beginners Digest, Vol 57, Issue 19
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Developing Web Applications with Haskell and Yesod (KMandPJLynch) 2. Checking if a Stack is Empty (doaltan) 3. Re: Checking if a Stack is Empty (Brandon Allbery) -- Message: 1 Date: Tue, 12 Mar 2013 10:47:30 -0400 From: KMandPJLynch kmandpjly...@verizon.net Subject: [Haskell-beginners] Developing Web Applications with Haskell and Yesod To: beginners@haskell.org Message-ID: 6980b99b-e272-4bdf-ba32-742e8e37e...@verizon.net Content-Type: text/plain; charset=us-ascii Good morning, I sent a previous email to you in regard to this - if my request is rejected, will I be notified? I'm reading the book Developing Web Applications with Haskell and Yesod. It is a very interesting read and I'm hoping to be able to be able to put up a simple web app using it as a result. I was wondering if anyone has had experience with it. Thank you On Mar 12, 2013, at 9:21 AM, beginners-requ...@haskell.org wrote: Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Writing a custom pop function for a stack data type (doaltan) 2. Re: Writing a custom pop function for a stack data type (Brent Yorgey) 3. Re: Suspend/resume computation using Cont monad and callCC (Ertugrul S?ylemez) 4. Re: Writing a custom pop function for a stack data type (Emanuel Koczwara) 5. Re: Performance problem with Haskell/OpenGL/GLFW (Jesper S?rnesj?) -- Message: 1 Date: Tue, 12 Mar 2013 11:06:35 + (GMT) From: doaltan doal...@yahoo.co.uk Subject: Re: [Haskell-beginners] Writing a custom pop function for a stack data type To: divyanshu ranjan idivyanshu.ran...@gmail.com Cc: beginners@haskell.org beginners@haskell.org Message-ID: 1363086395.38137.yahoomail...@web171402.mail.ir2.yahoo.com Content-Type: text/plain; charset=iso-8859-1 Actually I'm getting the error with this : data Stack = Empty | Elem Char Stack deriving Show pophead :: Stack - Char pophead Empty = Empty pophead (Elem x stack) = x From: divyanshu ranjan idivyanshu.ran...@gmail.com To: doaltan doal...@yahoo.co.uk; The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Sent: Tuesday, 12 March 2013, 12:53 Subject: Re: [Haskell-beginners] Writing a custom pop function for a stack data type You have declared new data type mystack not Stack, so haskell compiler could not find Stack data type and its constructors. Secondly data type in Haskell need to be start with?capital?letters like data Mystack = Empty | Elem Char Mystack deriving Show then correct Function?definition is? pophead :: Mystack - Char Regards Divyanshu? On Tue, Mar 12, 2013 at 4:12 PM, doaltan doal...@yahoo.co.uk wrote: Hi I have such a stack data structure:? datamystack =Empty |Elem Char mystack derivingShow I'm trying to get the head of the stack using this: pophead :: Stack - Char pophead Empty = Empty pophead (Element x stack) = x And I'm getting this error for the last sentence of the function : Not in scope: data constructor `Stack' Can you tell me how to fix it? Thanks. ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130312/90aa5548/attachment-0001.htm -- Message: 2 Date: Tue, 12 Mar 2013 07:13:01 -0400 From: Brent Yorgey byor...@seas.upenn.edu Subject: Re: [Haskell-beginners] Writing a custom pop function for a stack data type To: beginners@haskell.org Message-ID: 20130312111301.ga17...@seas.upenn.edu Content-Type: text/plain; charset=iso-8859-1 On Tue, Mar 12, 2013
Beginners Digest, Vol 57, Issue 20
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Checking if a Stack is Empty (Emanuel Koczwara) 2. Re: Developing Web Applications with Haskell and Yesod (Kim-Ee Yeoh) 3. Re: Developing Web Applications with Haskell and Yesod (Bryce Verdier) 4. Re: Suspend/resume computation using Cont monad and callCC (Stephen Tetley) 5. Re: Checking if a Stack is Empty (Tom Murphy) 6. Re: Suspend/resume computation using Cont monad and callCC (Dmitriy Matrosov) -- Message: 1 Date: Tue, 12 Mar 2013 16:05:19 +0100 From: Emanuel Koczwara poc...@emanuelkoczwara.pl Subject: Re: [Haskell-beginners] Checking if a Stack is Empty To: doaltan doal...@yahoo.co.uk, The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: 1363100719.4767.3.camel@emanuel-Dell-System-Vostro-3750 Content-Type: text/plain; charset=UTF-8 Hi, Dnia 2013-03-12, wto o godzinie 14:48 +, doaltan pisze: Hello, I have this stack data structure : data Stack = Empty | Element Char Stack deriving Show I want to check if it is equal to Empty When I try something like this : a = Empty or a = (Empty) in a haskell file and then write this on ghci : a = Empty I get this : interactive:1:0: No instance for (Eq Stack) arising from a use of `==' at interactive:1:0-11 Possible fix: add an instance declaration for (Eq Stack) In the expression: a == (Empty) In the definition of `it': it = a == (Empty) I don't know how to fix this. Can you help me so that I can check if a stack is Empty without getting this error? First, it looks like you should read 2 or 3 times this book: http://learnyouahaskell.com/ Second, you should use a function like this: isEmpty :: Stack - Bool isEmpty Empty = True isEmpty _ = False Emanuel -- Message: 2 Date: Tue, 12 Mar 2013 22:11:10 +0700 From: Kim-Ee Yeoh k...@atamo.com Subject: Re: [Haskell-beginners] Developing Web Applications with Haskell and Yesod To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: capy+zdqfmvkjl9uvrugjtjgphoo4ygz0nhwzh3ve5pspj6g...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Hey Patrick, On Tue, Mar 12, 2013 at 9:47 PM, KMandPJLynch kmandpjly...@verizon.netwrote: I sent a previous email to you in regard to this - if my request is rejected, will I be notified? Typically, if no one responds to your post, either they are too busy or they don't feel they can add constructively to the list (which is skimmed, if not actually read by hundreds or thousands -- yep, every single email). I'm reading the book Developing Web Applications with Haskell and Yesod. It is a very interesting read and I'm hoping to be able to be able to put up a simple web app using it as a result. I was wondering if anyone has had experience with it. There's a google group dedicated to yesod, I believe. The yesod website has links to community resources specially dedicated to the web framework. And you're always welcome to post specific queries about general haskell here! Your previous questions about learning category theory generated pretty useful discussion. :) -- Kim-Ee -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130312/fddacacd/attachment-0001.htm -- Message: 3 Date: Tue, 12 Mar 2013 09:53:09 -0700 From: Bryce Verdier bryceverd...@gmail.com Subject: Re: [Haskell-beginners] Developing Web Applications with Haskell and Yesod To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: 513f5d75.7000...@gmail.com Content-Type: text/plain; charset=iso-8859-1; Format=flowed Hey Patrick, I have very limited expirence with Yesod. I too have read the book but I found that the dead tree version isn't as up to date as the online version. If code examples don't work from book, I would look online instead, you can find it here: http://www.yesodweb.com/book shameless plugGoing back to what I said about my minimal expirence with it, I actually have a 2 part blog post where I perform a small web project in both Flask and Yeson. Here is the
Beginners Digest, Vol 57, Issue 21
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Performance problem with Haskell/OpenGL/GLFW (Jesper S?rnesj?) 2. Re: Performance problem with Haskell/OpenGL/GLFW (Hollister Herhold) 3. WORLDCOMP Strikes Again for the Last Time (chrisrogersrog...@aol.com) -- Message: 1 Date: Thu, 14 Mar 2013 00:32:22 +1100 From: Jesper S?rnesj? sarne...@gmail.com Subject: Re: [Haskell-beginners] Performance problem with Haskell/OpenGL/GLFW To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: calex+wgch7qmf+kjsu_iiczvwu+cja2fnz84qqa5ctjtf8q...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 Now that I have a better idea of what the underlying problem is, I am going to rephrase and repost this on haskell-cafe. Hollister, Andrey and Brandon, I really appreciate you helping me narrow it down. -- Jesper S?rnesj? http://jesper.sarnesjo.org/ -- Message: 2 Date: Wed, 13 Mar 2013 10:49:02 -0400 From: Hollister Herhold hollis...@fafoh.com Subject: Re: [Haskell-beginners] Performance problem with Haskell/OpenGL/GLFW To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: 5bd25ca3-0183-4040-a9b6-13a0687be...@fafoh.com Content-Type: text/plain; charset=iso-8859-1 I'm very interested to hear how it turns out - please let us know if you learn anything new. -Hollister On Mar 13, 2013, at 9:32 AM, Jesper S?rnesj? wrote: Now that I have a better idea of what the underlying problem is, I am going to rephrase and repost this on haskell-cafe. Hollister, Andrey and Brandon, I really appreciate you helping me narrow it down. -- Jesper S?rnesj? http://jesper.sarnesjo.org/ ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- Message: 3 Date: Wed, 13 Mar 2013 14:37:28 -0400 (EDT) From: chrisrogersrog...@aol.com Subject: [Haskell-beginners] WORLDCOMP Strikes Again for the Last Time To: beginners@haskell.org Message-ID: 8cfee30f2b99feb-708-13...@webmail-d108.sysops.aol.com Content-Type: text/plain; charset=utf-8 I graduated from University of Florida (UFL) and am currently running a computer firm in Florida. I have attended WORLDCOMP http://www.world-academy-of-science.org in 2010. Except for few keynote speeches and presentations, the conference was very disappointing due to a large number of poor quality papers and cancellation of some sessions. I was instantly suspicious of this conference. Me and my UFL and UGA friends started a study on WORLDCOMP. We submitted a paper to WORLDCOMP 2011 and again (the same paper with a modified title) to WORLDCOMP 2012. This paper had numerous fundamental mistakes. Sample statements from that paper include: (1). Binary logic is fuzzy logic and vice versa (2). Pascal developed fuzzy logic (3). Object oriented languages do not exhibit any polymorphism or inheritance (4). TCP and IP are synonyms and are part of OSI model (5). Distributed systems deal with only one computer (6). Laptop is an example for a super computer (7). Operating system is an example for computer hardware Also, our paper did not express any conceptual meaning. However, it was accepted both the times without any modifications (and without any reviews) and we were invited to submit the final paper and a payment of $500+ fee to present the paper. We decided to use the fee for better purposes than making Prof. Hamid Arabnia (Chairman of WORLDCOMP) rich. After that, we received few reminders from WORLDCOMP to pay the fee but we never responded. We MUST say that you should look at the website http://sites.google.com/site/worlddump1 if you have any thoughts to submit a paper to WORLDCOMP. DBLP and other indexing agencies have stopped indexing WORLDCOMP?s proceedings since 2011 due to its fakeness. The status of your WORLDCOMP papers can be changed from ?scientific? to ?other? (i.e., junk or non-technical) at anytime. See the comments http://www.mail-archive.com/tccc@lists.cs.columbia.edu/msg05168.html of a respected researcher on this. Better not to have a paper than having it in WORLDCOMP and spoil the resume and peace of mind forever! Our study
Beginners Digest, Vol 57, Issue 22
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. type hierarchies / records (R?zvan Rotaru) 2. Re: type hierarchies / records (Kim-Ee Yeoh) 3. Confused about lazy IO (Jacek Dudek) 4. Re: Confused about lazy IO (Gesh hseG) 5. Re: Confused about lazy IO (Kim-Ee Yeoh) -- Message: 1 Date: Thu, 14 Mar 2013 17:58:52 +0200 From: R?zvan Rotaru razvan.rot...@gmail.com Subject: [Haskell-beginners] type hierarchies / records To: beginners@haskell.org Message-ID: CAP33cnagv24_pQEDDJifo-4phz1BndQA3NVi4aKA7sa=hsx...@mail.gmail.com Content-Type: text/plain; charset=utf-8 Dear Haskelleers, I suspect my problem has been discussed many times and under many forms, so please don't shoot me for asking. I could not find an acceptable solution yet, and beeing as stubborn as i am, I still hope the solution is eluding me because of my poor haskell knowlegde. So here I am posting my question on this mailing list. Basically I am trying to GUI Widgets using haskell types (Buttons, Textfields, etc.). 1/ Using Records is not acceptable because of the name clashes between attribute names. I could use prefixes and write functions in typeclasses for accessor, but it's ugly and a lot of work. 2/ I decided to keep the attributes in Maps, so basically a textfield would be data Textfield = Textfield (Map.Map TextfieldProps String) The problem is: how to define TextfieldProps? It should be something like: data TextfieldProps = Id | Label | Value But then, buttons also have Id's and labels. So following is not accepted anymore: data ButtonProps = Id | Label | OnClick Ideas and suggestions are much appreciated. Thank You, R?zvan -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130314/e23ecbc0/attachment-0001.htm -- Message: 2 Date: Fri, 15 Mar 2013 00:58:59 +0700 From: Kim-Ee Yeoh k...@atamo.com Subject: Re: [Haskell-beginners] type hierarchies / records To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: capy+zdqkvlqm4tnjkynsy80arpui6nrdhwkgrjynpj3xqtw...@mail.gmail.com Content-Type: text/plain; charset=utf-8 On Thu, Mar 14, 2013 at 10:58 PM, R?zvan Rotaru razvan.rot...@gmail.comwrote: 2/ I decided to keep the attributes in Maps, so basically a textfield would be data Textfield = Textfield (Map.Map TextfieldProps String) Is defining data here even necessary? Even newtype seems superfluous. A plain shorthand type synonym surely fits the bill? The problem is: how to define TextfieldProps? It should be something like: data TextfieldProps = Id | Label | Value But then, buttons also have Id's and labels. So following is not accepted anymore: data ButtonProps = Id | Label | OnClick Perhaps data TextfieldProps = TextId | TextLabel | TextValue -- and similarly for ButtonProps? I confess to not fully understanding the GUI modelling attempted here, which isn't to say that you aren't on the right track. To help you and help us help you better, one approach known to be successful is to sketch out the code (better yet, the type signatures!) of what you'd like to write, e.g. how are TextfieldProps and ButtonProps used? What functions act on them? -- Kim-Ee -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130315/4a73ac74/attachment-0001.htm -- Message: 3 Date: Thu, 14 Mar 2013 18:52:43 -0400 From: Jacek Dudek jzdu...@gmail.com Subject: [Haskell-beginners] Confused about lazy IO To: beginners@haskell.org Message-ID: cajxg2_fhaecdentzs4gbl7jgk3qozgvpbcaghtl_tfzxff1...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 Q: When trying to compose the following IO actions: readFile fileName = \ contents - writeFile fileName (f contents) I get an exception: openFile: permission denied. However the following works: readFile fileName = \ contents - (mapM_ putStrLn . lines) contents writeFile fileName (f contents) I'm assuming it has something to do with lazy IO, and the second action in the second version forces fileName to be read completely and to be closed. Why do I need to do that? I thought lazy IO was implemented in such a way that you were safe to INTERPRET the IO action as having been fully performed. (And so I would have
Beginners Digest, Vol 57, Issue 23
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Beginners Digest, Vol 57, Issue 22 (R?zvan Rotaru) 2. Re: Beginners Digest, Vol 57, Issue 22 (Mateusz Kowalczyk) 3. Beginners Code - Comments on Style (Heinrich Ody) -- Message: 1 Date: Fri, 15 Mar 2013 15:00:44 +0200 From: R?zvan Rotaru razvan.rot...@gmail.com Subject: Re: [Haskell-beginners] Beginners Digest, Vol 57, Issue 22 To: beginners@haskell.org Message-ID: cap33cnb_okkabr0rog1-o3ygho5murkk2ga6xuyfst1icf5...@mail.gmail.com Content-Type: text/plain; charset=utf-8 Thanks for the reply. On 15 March 2013 13:00, beginners-requ...@haskell.org wrote: Perhaps data TextfieldProps = TextId | TextLabel | TextValue -- and similarly for ButtonProps? I confess to not fully understanding the GUI modelling attempted here, which isn't to say that you aren't on the right track. To help you and help us help you better, one approach known to be successful is to sketch out the code (better yet, the type signatures!) of what you'd like to write, e.g. how are TextfieldProps and ButtonProps used? What functions act on them? -- Kim-Ee I don't have any code to show you, since I just started trying to write the types. I'll try to explain what I'm trying to do. So, I want model some GUI widgets. This means I should have type for each widget (or a type synomym), holding it's data, or state if you like. A textfield must have an id, a label and the entered text as value. A button must have an id, a label and a function to call when the button is clicked. As previously said, records are not an acceptable solution because of the name clash of properties, and I don't want to prefix each property to avoid this. Next best thing is to use a map to hold the properties. I could use strings as keys, in which case my map would look like this (written as a list of tuples): [ (id, name_textfield), (label, Name:), (value, Please enter name here ...)] but then is no checking for the property names (e.g. if I mispelled id, or I used onclick for textfields). I want to find a way to use the type system to check these properties. My idea was to use new types as keys for these maps. I would then have: data TextfieldProperties = Id | Label | Value type Textfield = Map TextfieldProperties String But then I get into the same name clash, because all widgets have Ids, most have labels, etc. And here I got stuck. Then, how to create widgets? Record syntax would have been fine, but since I'm not using records I would have to write some make-... functions, which will receive a list of key value pairs and insert them into the map to create the widget. Also here I can put the default values of properties (for. example if id is not specified, one is generated, or use empty strings for unspecified textfield values). How to use widgets? Well there will be functions to draw them on the screen. I could use a typeclass here. Then their properties must be accessed somehow, and this should be also polymorphic of course: I want one function to get the id of a widget, no matter of what type. Typeclasses can help here as well. Then there would be methods to search the GUI tree for certain widgets... you know, standard stuff you would want to do with GUI widgets. Currently, my blocking point is how to define the types. And I don't want to flatten it all out, and use (Map String String) for any widget. I'm missing out on the type system if I do this. Cheers, R?zvan -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130315/4c5da489/attachment-0001.htm -- Message: 2 Date: Fri, 15 Mar 2013 14:00:16 + From: Mateusz Kowalczyk fuuze...@fuuzetsu.co.uk Subject: Re: [Haskell-beginners] Beginners Digest, Vol 57, Issue 22 To: beginners@haskell.org Message-ID: 51432970.2080...@fuuzetsu.co.uk Content-Type: text/plain; charset=UTF-8 On 15/03/13 13:00, R?zvan Rotaru wrote: Thanks for the reply. On 15 March 2013 13:00, beginners-requ...@haskell.org mailto:beginners-requ...@haskell.org wrote: Perhaps data TextfieldProps = TextId | TextLabel | TextValue -- and similarly for ButtonProps? I confess to not fully understanding the GUI modelling attempted here, which isn't to say that you aren't on the right track. To help you and help us help you better, one approach known to be successful is to sketch
Beginners Digest, Vol 57, Issue 26
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Simpler than lifting (Adrian May) 2. Re: Simpler than lifting (Brandon Allbery) 3. Re: Simpler than lifting (Brent Yorgey) 4. Re: Simpler than lifting (Daniel Trstenjak) 5. Re: Simpler than lifting (Adrian May) 6. newtype with a typclass (R?zvan Rotaru) 7. A good data structure for representing a tic-tac-toe board? (Costello, Roger L.) 8. Re: newtype with a typclass (Brandon Allbery) -- Message: 1 Date: Mon, 18 Mar 2013 21:59:28 +0800 From: Adrian May adrian.alexander@gmail.com Subject: [Haskell-beginners] Simpler than lifting To: beginners@haskell.org Message-ID: cad-ubzfbftutgwqh5baodxofvhjiwmqao3khxsin0mr5s95...@mail.gmail.com Content-Type: text/plain; charset=utf-8 Hi All, I have this in my code: infixl 6 ~+, ~- f ~+ g = \p - f p + g p f ~- g = \p - f p - g p but I feel that the prelude must have already taken care of such things. What's the proper way to do it? Thanks in advance, Adrian. -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130318/849bae5a/attachment-0001.htm -- Message: 2 Date: Mon, 18 Mar 2013 10:15:53 -0400 From: Brandon Allbery allber...@gmail.com Subject: Re: [Haskell-beginners] Simpler than lifting To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAKFCL4UYjTz-U3ne1BJPuNQBpF6_BBgj5E5VC6F=-ek0yy5...@mail.gmail.com Content-Type: text/plain; charset=utf-8 On Mon, Mar 18, 2013 at 9:59 AM, Adrian May adrian.alexander@gmail.comwrote: infixl 6 ~+, ~- f ~+ g = \p - f p + g p f ~- g = \p - f p - g p but I feel that the prelude must have already taken care of such things. What's the proper way to do it? Not in the Prelude (which is specified by the Haskell Language Report and difficult to change), but I think you want to look at Control.Applicative. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130318/0917a8c0/attachment-0001.htm -- Message: 3 Date: Mon, 18 Mar 2013 10:17:44 -0400 From: Brent Yorgey byor...@seas.upenn.edu Subject: Re: [Haskell-beginners] Simpler than lifting To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: 20130318141743.ga12...@seas.upenn.edu Content-Type: text/plain; charset=us-ascii On Mon, Mar 18, 2013 at 10:15:53AM -0400, Brandon Allbery wrote: On Mon, Mar 18, 2013 at 9:59 AM, Adrian May adrian.alexander@gmail.comwrote: infixl 6 ~+, ~- f ~+ g = \p - f p + g p f ~- g = \p - f p - g p but I feel that the prelude must have already taken care of such things. What's the proper way to do it? Not in the Prelude (which is specified by the Haskell Language Report and difficult to change), but I think you want to look at Control.Applicative. In particular, (~+) = liftA2 (+), and similarly for (~-). This uses the ((-) e) instance of Applicative. -Brent -- Message: 4 Date: Mon, 18 Mar 2013 16:23:13 +0100 From: Daniel Trstenjak daniel.trsten...@gmail.com Subject: Re: [Haskell-beginners] Simpler than lifting To: beginners@haskell.org Message-ID: 20130318152313.GA28800@machine Content-Type: text/plain; charset=us-ascii In particular, (~+) = liftA2 (+), and similarly for (~-). This uses the ((-) e) instance of Applicative. Or by using '$' and '*', which is a bit more general: (+) $ f * g funcWith3Args $ f * g * h Greetings, Daniel -- Message: 5 Date: Mon, 18 Mar 2013 23:27:01 +0800 From: Adrian May adrian.alexander@gmail.com Subject: Re: [Haskell-beginners] Simpler than lifting To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: cad-ubzhpezn7x68ky6bgxujhzxvujrfsj__6fycft4vokuf...@mail.gmail.com Content-Type: text/plain; charset=utf-8 Thanks everyone! I knew it would be in
Beginners Digest, Vol 57, Issue 32
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Programming with Arrows (Michael Baker) 2. Re: Programming with Arrows (Ertugrul S?ylemez) -- Message: 1 Date: Fri, 22 Mar 2013 16:39:07 -0500 From: Michael Baker michaeltba...@gmail.com Subject: [Haskell-beginners] Programming with Arrows To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CACwW0Uby9CYW445Bc10iTt9z=zs2ntekuialaodbupynfrf...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 I'm reading through http://www.cse.chalmers.se/~rjmh/afp-arrows.pdf I was following it up until this example in the section about flip-flops: class Arrow arr = ArrowLoop arr where loop :: arr (a,c) (b,c) - arr a b instance ArrowLoop (-) where loop f a = b where (b,c) = f (a,c) Although I've never seen a function declaration like this, but I think I get it. Because f :: (a, c) - (b, c) then then loop f :: ((a, c) - (b, c)) - (a - b) which is the same as ((a, c) - (b, c)) - a - b. However, I don't see where the c comes from in f (a,c). Is this a mistake or am I missing something? A friend of mine realized that this is just a recursive definition so f (a, c) == f (a, snd $ f (a, snd $ f (a, ...))). I don't really understand this definition. I can see how it compiles, but I don't see how it would ever produce a legitimate value. Do I have to assume that f never evaluates the second element in the pair and just passes it through? -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130322/65e8448f/attachment-0001.htm -- Message: 2 Date: Sat, 23 Mar 2013 05:49:02 +0100 From: Ertugrul S?ylemez e...@ertes.de Subject: Re: [Haskell-beginners] Programming with Arrows To: beginners@haskell.org Message-ID: 20130323054902.7990d...@tritium.ertes.de Content-Type: text/plain; charset=us-ascii Michael Baker michaeltba...@gmail.com wrote: class Arrow arr = ArrowLoop arr where loop :: arr (a,c) (b,c) - arr a b instance ArrowLoop (-) where loop f a = b where (b,c) = f (a,c) Although I've never seen a function declaration like this, but I think I get it. Because f :: (a, c) - (b, c) then then loop f :: ((a, c) - (b, c)) - (a - b) which is the same as ((a, c) - (b, c)) - a - b. However, I don't see where the c comes from in f (a,c). Is this a mistake or am I missing something? This is indeed legitimate and you are missing something. This confusion is the reason I prefer to call this feedback. Part of the result is fed back as input, which of course requires laziness to work. ArrowLoop is the arrow version of MonadFix: class (Monad m) = MonadFix m where mfix :: (a - m a) - m a In fact the ArrowLoop instance of Kleisli is defined in terms of MonadFix (I leave reproducing this as an exercise for you). Of course all this doesn't help understanding the purpose of ArrowLoop, so let me introduce an arrow commonly used in FRP, the automaton arrow: newtype Auto a b = Auto { stepAuto :: a - (b, Auto a b) } You can read this type literally: It is basically a function from input to result, but along with the result it returns a new version of itself. Calling such a function I call 'stepping'. Here is a counter automaton that ignores its input: countFrom :: Integer - Auto a Integer countFrom x = Auto (const (x, countFrom (x + 1))) The automaton 'countFrom 10', when stepped, will return 10 and a new version of itself, namely 'countFrom 11'. When you step that one it will return 11 and a new version of itself, namely 'countFrom 12': stepAuto (countFrom 10) () = (10, countFrom 11) stepAuto (countFrom 11) () = (11, countFrom 12) {- ... -} To make a use case for ArrowLoop let's write a slightly more interesting version: sumFrom :: Integer - Auto Integer Integer sumFrom x = Auto (\dx - (x, sumFrom (x + dx))) This one uses its input value: stepAuto (sumFrom 10) 5= (10, sumFrom (10 + 5)) stepAuto (sumFrom 15) 2= (15, sumFrom (15 + 2)) stepAuto (sumFrom 17) (-1) = (17, sumFrom (17 - 1)) {- ... -} It uses its input value as a delta, so it really corresponds to a running sum or in Haskell terms to a 'scanl (+)'. What makes sumFrom more powerful than scanl (+) is that you can easily use sumFrom's result as its own
Beginners Digest, Vol 57, Issue 34
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. hiding members of a data,separate accessors instead (Emmanuel Touzery) 2. How to design functions so they can be part of other larger systems? (Costello, Roger L.) 3. Re: hiding members of a data, separate accessors instead (Gabriel Gonzalez) 4. Re: How to design functions so they can be part of other larger systems? (Gabriel Gonzalez) 5. Re: hiding members of a data, separate accessors instead (Daniel Trstenjak) 6. Re: stack overflow summing numbers read from a big file (Axel Wegen) -- Message: 1 Date: Sun, 24 Mar 2013 17:14:11 +0100 From: Emmanuel Touzery etouz...@gmail.com Subject: [Haskell-beginners] hiding members of a data, separate accessors instead To: beginners@haskell.org beginners@haskell.org Message-ID: CAC42Remd29UtHo8biDJmkTh1qrS-xJ8zD4y7G+97k=_pmox...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 hi, i was looking at the response type in http-streams: http://hackage.haskell.org/packages/archive/http-streams/0.4.0.0/doc/html/Network-Http-Client.html#t:Response I'm used that simply the data type and all its members are visible -- the functions to access its contents. But in this case on the HTML documentation the response type looks like it has no members. And the author has defined like public accessors later in the code: getStatusCode :: Response - StatusCode getStatusCode = pStatusCode So I'm not even sure how he achieved that the members are not visible, the data are exported with (..) as is usually done... And the other thing is why would you do that.. You could name the member getStatusCode in the first place, but then it might increase encapsulation to hide it (depending on how he managed to hide the members).. But did you then make it impossible to deconstruct a Response through pattern matching? That sounds like a minus... Although pattern matching on a data with 6 fields is always going to be a pain and decreasing the chances for modifying the data type without breaking compatibility. These members are also causing me problems in other situations, for instance I have some cases when I use a data type only a few times and with -Wall the compiler tells me I don't use the accessor; in fact I read that value from the data, but through pattern matching/deconstruction only, not through that particular function. I'm thinking to try to hide the warning as I think my code is correct. Anyway I'm curious on the mechanism used by that library... I've already noticed a few nice tricks in this library, like a small state monad to take optional parameters, much more elegant than any other mechanism i've seen so far to achieve the same effect. Thank you! Emmanuel -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130324/ab8aab46/attachment-0001.htm -- Message: 2 Date: Sun, 24 Mar 2013 17:30:46 + From: Costello, Roger L. coste...@mitre.org Subject: [Haskell-beginners] How to design functions so they can be part of other larger systems? To: beginners@haskell.org beginners@haskell.org Message-ID: b5fee00b53cf054aa8439027e8fe17751ef43...@imcmbx04.mitre.org Content-Type: text/plain; charset=us-ascii Hi Folks, I read this statement by Tim Berners-Lee [1]: It is not only necessary to make sure your own system is designed to be made of modular parts. It is also necessary to realize that your own system, no matter how big and wonderful it seems now, should always be designed to be a part of another larger system. Recently I have been working hard to learn how to better modularize. But now TBL says that I must do more - I must not only modularize well, but I must also build the modules so that they can be part of other larger systems. How do I design modules so that they may be part of other larger systems? Are there any articles that give guidelines on how to do this? What are your thoughts on how to do this? /Roger [1] http://www.w3.org/DesignIssues/Principles.html -- Message: 3 Date: Sun, 24 Mar 2013 10:34:29 -0700 From: Gabriel Gonzalez gabriel...@gmail.com Subject: Re: [Haskell-beginners] hiding members of a data, separate accessors instead To: The Haskell-Beginners Mailing List - Discussion of primarily
Beginners Digest, Vol 57, Issue 35
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: How to design functions so they can be part of other larger systems? (Darren Grant) 2. Re: hiding members of a data,separate accessors instead (Emmanuel Touzery) 3. Re: hiding members of a data, separate accessors instead (Gabriel Gonzalez) -- Message: 1 Date: Sun, 24 Mar 2013 12:15:26 -0700 From: Darren Grant therealklu...@gmail.com Subject: Re: [Haskell-beginners] How to design functions so they can be part of other larger systems? To: Haskell Beginners beginners@haskell.org Message-ID: CA+jD6SjjYdxc-WDbg4RZY7-ikRKxjAkjqvXGY=mefe7us7u...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 This is a great bridge article, thanks! On 2013-03-24 10:45 AM, Gabriel Gonzalez gabriel...@gmail.com wrote: On 03/24/2013 10:30 AM, Costello, Roger L. wrote: Hi Folks, I read this statement by Tim Berners-Lee [1]: It is not only necessary to make sure your own system is designed to be made of modular parts. It is also necessary to realize that your own system, no matter how big and wonderful it seems now, should always be designed to be a part of another larger system. Recently I have been working hard to learn how to better modularize. But now TBL says that I must do more - I must not only modularize well, but I must also build the modules so that they can be part of other larger systems. How do I design modules so that they may be part of other larger systems? Are there any articles that give guidelines on how to do this? What are your thoughts on how to do this? I recommend that you read the following post I wrote: http://www.haskellforall.com/**2012/08/the-category-design-**pattern.htmlhttp://www.haskellforall.com/2012/08/the-category-design-pattern.html It introduces category theory in the context of designing modular and resuable components. Category theory differentiates itself from other vague notions of modularity by providing an elegant and precise definition of what it means for something to be modular. /Roger [1] http://www.w3.org/**DesignIssues/Principles.htmlhttp://www.w3.org/DesignIssues/Principles.html __**_ Beginners mailing list Beginners@haskell.org http://www.haskell.org/**mailman/listinfo/beginnershttp://www.haskell.org/mailman/listinfo/beginners __**_ Beginners mailing list Beginners@haskell.org http://www.haskell.org/**mailman/listinfo/beginnershttp://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130324/e5531382/attachment-0001.htm -- Message: 2 Date: Sun, 24 Mar 2013 20:24:55 +0100 From: Emmanuel Touzery etouz...@gmail.com Subject: Re: [Haskell-beginners] hiding members of a data, separate accessors instead To: beginners@haskell.org beginners@haskell.org Message-ID: CAC42Re=+smehuasjsyplrzxa5oqlu7ukptpr0_rirxnadyb...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 But then since the library is using (..) that would mean everything is exported? For instance testing on the Request data: http://hackage.haskell.org/packages/archive/http-streams/0.4.0.0/doc/html/src/Network-Http-Types.html#Request module Network.Http.Types (Request(..), data Request= Request {qMethod :: !Method,qHost :: Maybe ByteString,qPath:: !ByteString,qBody :: !EntityBody,qExpect :: !ExpectMode,qHeaders :: !Headers} {-# LANGUAGE OverloadedStrings #-} import Network.Http.Client main = do q - buildRequest $ do http GET / setAccept text/html print q print $ qMethod q --- test-hs.hs:11:17: Not in scope: `qMethod' With regards to what Daniel wrote, I realize my email was confusing. When I was talking about warnings I was talking of another problem entirely, that i probably should not have mentioned in this context. In that other context I had data declarations for types that I would instanciate only from Data.Aeson parsing from JSON. I would then only use pattern matching on the instances, never call the accessor functions by themselves, then I get a warning that they're unused which annoys me. But it's quite unrelated to this mail...
Beginners Digest, Vol 57, Issue 36
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: hiding members of a data,separate accessors instead (Emmanuel Touzery) 2. Re: How to design functions so they can be part of other larger systems? (Kim-Ee Yeoh) 3. Re: stack overflow summing numbers read from a big file (Chadda? Fouch?) 4. Re: stack overflow summing numbers read from a big file (Axel Wegen) -- Message: 1 Date: Sun, 24 Mar 2013 21:03:54 +0100 From: Emmanuel Touzery etouz...@gmail.com Subject: Re: [Haskell-beginners] hiding members of a data, separate accessors instead To: beginners@haskell.org beginners@haskell.org Message-ID: cac42rekd6wkavrf9eyzqxu6s8k7jhkqlso8ga1rakgptysq...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Yes, exactly I just was typing a mail on that. I just realized that myself. And the Network.Http.Types module is not available because the author has not exported it through cabal. exposed-modules: Network.Http.Client other-modules: Network.Http.Types, Network.Http.Connection, Network.Http.RequestBuilder, Network.Http.ResponseParser, Network.Http.Inconvenience It's the first time I realise that this pattern exists. So he has effectively returned the data types, but in an opaque way, and users must use his accessors and pattern matching is impossible. Thank you! Emmanuel On Sun, Mar 24, 2013 at 9:00 PM, Gabriel Gonzalez gabriel...@gmail.comwrote: ** On 03/24/2013 12:24 PM, Emmanuel Touzery wrote: But then since the library is using (..) that would mean everything is exported? It only means that those fields are exported from that specific module. Downstream modules that use Network.Http.Types internally may or may not re-export everything. Your example below doesn't import Network.Http.Types; it imports Network.Http.Client. If you look at the source for Network.Http.Client you will see that it does not re-export everything it imported from Network.Http.Types: http://hackage.haskell.org/packages/archive/http-streams/0.4.0.0/doc/html/src/Network-Http-Client.html When you import Network.Http.Client, `ghc` only uses whatever is in the export list of Network.Http.Client. For instance testing on the Request data: http://hackage.haskell.org/packages/archive/http-streams/0.4.0.0/doc/html/src/Network-Http-Types.html#Request module Network.Http.Types (Request(..), data Request= Request {qMethod :: !Method,qHost:: Maybe ByteString,qPath:: !ByteString,qBody:: !EntityBody,qExpect :: !ExpectMode,qHeaders :: !Headers} {-# LANGUAGE OverloadedStrings #-} import Network.Http.Client main = do q - buildRequest $ do http GET / setAccept text/html print q print $ qMethod q --- test-hs.hs:11:17: Not in scope: `qMethod' With regards to what Daniel wrote, I realize my email was confusing. When I was talking about warnings I was talking of another problem entirely, that i probably should not have mentioned in this context. In that other context I had data declarations for types that I would instanciate only from Data.Aeson parsing from JSON. I would then only use pattern matching on the instances, never call the accessor functions by themselves, then I get a warning that they're unused which annoys me. But it's quite unrelated to this mail... Emmanuel On Sun, Mar 24, 2013 at 6:34 PM, Gabriel Gonzalez gabriel...@gmail.comwrote: Assume you have the following type: data Type = T { field1 :: String, field2 :: Double } ... and you want to export the type `Type` and the acessors `field1` and `field2`, but not the constructor `T`, then you would write: module MyModule ( Type(field1, field2) ) where Another way to do this is like so: module MyModule ( Type, field1, field2 ) where That's perfectly legal, too. Normally, when you write something like: module MyModule ( Type(..) ) where the .. expands out to: module MyModule ( Type(T, field1, field2) ) where All the first solution does is just leave out the T constructor from those exports. On 03/24/2013 09:14 AM, Emmanuel Touzery wrote: hi, i was looking at the response type in http-streams:
Beginners Digest, Vol 57, Issue 38
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: cabal install local troubles (osx) (Miro Karpis) -- Message: 1 Date: Wed, 27 Mar 2013 10:57:16 +0100 From: Miro Karpis miroslav.kar...@gmail.com Subject: Re: [Haskell-beginners] cabal install local troubles (osx) To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: cajnnbxhzvpghy2dxwwcmzopbi+y921_qkpr-cpxcyfoy6dn...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 so, after 1) removing ~/.cabal, 2) fresh haskell package install (most probably this was not necessary) 3) cabal install cabal-install I got finally: mac-2:~ miro$ cabal -V *cabal-install version 1.16.0.2* * * /bin is still not in ~/.cabal directory, but most probably that does not need to be there..or? cheers, m. On Wed, Mar 27, 2013 at 10:39 AM, Miro Karpis miroslav.kar...@gmail.comwrote: I did a bit more checking and I can see in ~/.cabal only config.platform and config files. No bin folder. I just did a fresh haskell package install. After that I run: mac-2:.cabal miro$ cabal -V *cabal-install version 0.14.0* using version 1.14.0 of the Cabal library mac-2:.cabal miro$ cabal update Downloading the latest package list from hackage.haskell.org *Note: there is a new version of cabal-install available.* To upgrade, run: cabal install cabal-install mac-2:.cabal miro$ cabal install cabal-install Resolving dependencies... ... ... ... Installing executable(s) in */Users/miro/Library/Haskell/ghc-7.4.2/lib/cabal-install-1.16.0.2/bin* Updating documentation index /Users/miro/Library/Haskell/doc/index.html mac-2:.cabal miro$ cabal -V *cabal-install version 0.14.0* * * * * mac-2:.cabal miro$ ls ~/.cabal config config.platform mac-2:bin miro$ cd /Library/Haskell/bin mac-2:bin miro$ ls -l total 5712 lrwxr-xr-x 1 miro wheel 26 Mar 27 10:17 alex - ../lib/alex-3.0.2/bin/alex lrwxr-xr-x 1 miro wheel 10 Mar 27 10:17 cabal - cabal.wrap lrwxr-xr-x 1 miro wheel 37 Mar 27 10:17 *cabal.real - ../lib/cabal-install-0.14.0/bin/cabal* -rwxr-xr-x 1 root admin 4328 Nov 5 03:44 cabal.wrap lrwxr-xr-x 1 miro wheel 30 Mar 27 10:17 happy - ../lib/happy-1.18.10/bin/happy -rwxr-xr-x 1 root admin 1295976 Nov 5 03:44 patch-ghc-settings -rwxr-xr-x 1 root admin 1598500 Nov 5 03:44 uninstall-hs so it seems that the cabal update does not update the link in bin,...this should be working, or? Do I need to always update the link after each new version of cabal? m. On Wed, Mar 27, 2013 at 7:49 AM, Miro Karpis miroslav.kar...@gmail.comwrote: many thanks, but this is my output: mac-2:~ miro$ cd $HOME/.cabal/bin -bash: cd: /Users/miro/.cabal/bin: No such file or directory mac-2:~ miro$ cheers, m. On Wed, Mar 27, 2013 at 7:44 AM, Emmanuel Touzery etouz...@gmail.comwrote: Hello, On linux and windows I add this folder to the path and then it works: $HOME/.cabal/bin emmanuel On Wed, Mar 27, 2013 at 7:16 AM, Miro Karpis miroslav.kar...@gmail.comwrote: please, can you help me with following. I have installed haskell on mac from the package. When I check cabal -V I can see 1.14.0 That is because the cabal is loading from /Library/Haskell/bin. After that I run 'cabal install cabal-install', I get following output: Installing executable(s) in /Users/miro/Library/Haskell/ghc-7.4.2/lib/cabal-install-1.16.0.2/bin Updating documentation index /Users/miro/Library/Haskell/doc/index.html So the new version of cabal is installed in another place. When I install new package via cabal, it uses the 1.14.0 version. I have tried to copy the new 1.16.0.2 version to bin, but that just didn't help because the new packages have been installed somewhere else. Please what is the proper way to fix this? many thanks, miro ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130327/2702b09f/attachment-0001.htm -- ___ Beginners mailing
Beginners Digest, Vol 57, Issue 39
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: cabal install local troubles (osx) (Brandon Allbery) -- Message: 1 Date: Wed, 27 Mar 2013 09:44:37 -0400 From: Brandon Allbery allber...@gmail.com Subject: Re: [Haskell-beginners] cabal install local troubles (osx) To: miroslav.kar...@gmail.com, The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: cakfcl4w5yx3poop97qpjqbbbahiu1pvf+mfb8s4udny+oo4...@mail.gmail.com Content-Type: text/plain; charset=utf-8 On Wed, Mar 27, 2013 at 2:16 AM, Miro Karpis miroslav.kar...@gmail.comwrote: So the new version of cabal is installed in another place. When I install new package via cabal, it uses the 1.14.0 version. I have tried to copy the new 1.16.0.2 version to bin, but that just didn't help because the new packages have been installed somewhere else. cabal-install installs to your user package database; you want this, it means you don't have to wipe out the entire installation if you get conflicting libraries installed. If you are not finding libraries because you're installing stuff the old runhaskell Setup.hs configure etc. way, just run cabal install (with no package name) instead of the Setup.hs stuff. Also note that, while ~/.cabal/bin is used on linux, it's ~/Library/Haskell/bin on OS X. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130327/c66768db/attachment-0001.htm -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 57, Issue 39 *
Beginners Digest, Vol 57, Issue 41
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: (no subject) (Jamie F Olson) 2. Re: (no subject) (Brandon Allbery) 3. Re: can't make distribution, requires rerunning ./configure (Karl Voelker) 4. Re: (no subject) (Daniel Trstenjak) -- Message: 1 Date: Thu, 28 Mar 2013 22:34:26 + (UTC) From: Jamie F Olson jamie.f.ol...@gmail.com Subject: Re: [Haskell-beginners] (no subject) To: beginners@haskell.org Message-ID: loom.20130328t233341-...@post.gmane.org Content-Type: text/plain; charset=us-ascii David McBride toad3k at gmail.com writes: data JSValue = ... | JSObject (JSObject JSValue) | ... Thank you! I think the two strange things as an outsider particularly from more OO languages are that types aren't objects, and then the strangeness of the naming convention. Would it have been legal to define data JSValue as something like this instead? data JSValue = JSValue | JSValue !Bool | JSValue !Rational | JSValue JSString | JSValue[JSValue] | JSValue (JSObject JSValue) -- Message: 2 Date: Thu, 28 Mar 2013 18:38:41 -0400 From: Brandon Allbery allber...@gmail.com Subject: Re: [Haskell-beginners] (no subject) To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAKFCL4XMO_r=pvsykpct08vyb8ap5za3enjvams1levzdgo...@mail.gmail.com Content-Type: text/plain; charset=utf-8 On Thu, Mar 28, 2013 at 6:34 PM, Jamie F Olson jamie.f.ol...@gmail.comwrote: Would it have been legal to define data JSValue as something like this instead? data JSValue = JSValue | JSValue !Bool | JSValue !Rational | JSValue JSString | JSValue[JSValue] | JSValue (JSObject JSValue) No; the data constructor used tells it what to expect afterward. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130328/4258f873/attachment-0001.htm -- Message: 3 Date: Fri, 29 Mar 2013 00:05:07 -0700 From: Karl Voelker ktvoel...@gmail.com Subject: Re: [Haskell-beginners] can't make distribution, requires rerunning ./configure To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAFfow0y4eMGdVTAVgAdj0FNh0qo2L1dVjwAu=Ro6AnX7Hw=o...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 This isn't exactly an answer to your question, but have you considered using the Haskell Platform (which is recommended for most purposes) or a GHC binary package? http://www.haskell.org/platform/ http://www.haskell.org/ghc/download_ghc_7_6_2#binaries -Karl On Thu, Mar 28, 2013 at 9:37 AM, Josh Stratton strattonbra...@gmail.comwrote: I recently downloaded the ghc distribution for Linux (x86_64) and had difficulty installing to my machine. The configure step seems to have completed successfully, but when I run the followup make install, it fails suggesting that I haven't run the configure command yet. atlas = ./configure --prefix=/opt/ghc checking for path to top of build tree... /tmp/ghc-7.6.2 Build platform inferred as: x86_64-unknown-linux Host platform inferred as: x86_64-unknown-linux Target platform inferred as: x86_64-unknown-linux GHC build : x86_64-unknown-linux GHC host : x86_64-unknown-linux GHC target : x86_64-unknown-linux checking for perl... /rel/map/generic-2012.18.last/bin/perl checking if your perl works in shell scripts... yes checking for a BSD-compatible install... /usr/bin/install -c checking whether ln -s works... yes checking for gsed... sed checking for gcc... /usr/bin/gcc checking for gcc... /usr/bin/gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether /usr/bin/gcc accepts -g... yes checking for /usr/bin/gcc option to accept ISO C89...
Beginners Digest, Vol 57, Issue 43
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. point-free + IO Monad (Ovidiu D) 2. Re: point-free + IO Monad (Franco) 3. Re: point-free + IO Monad (Ovidiu D) 4. Re: point-free + IO Monad (Tony Morris) -- Message: 1 Date: Sun, 31 Mar 2013 09:55:24 +0300 From: Ovidiu D ovidiud...@gmail.com Subject: [Haskell-beginners] point-free + IO Monad To: beginners@haskell.org Message-ID: cakvse7t0+tv_f1dkpnbto1w3i_v83-r5yi-icrgp6+j2jpo...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 I have the following code: f1 :: String - String f2 :: IO String - IO () f2 a = do b - a putStr $ f1 b How can I write the function f2 in a point-free style? I have tried this: f2 = return.f1 = putStr ...but it doesn't work. Thanks! -- Message: 2 Date: Sun, 31 Mar 2013 08:08:30 + (UTC) From: Franco franc...@gmx.com Subject: Re: [Haskell-beginners] point-free + IO Monad To: beginners@haskell.org Message-ID: loom.20130331t100051-...@post.gmane.org Content-Type: text/plain; charset=us-ascii Ovidiu D ovidiudeac at gmail.com writes: I have the following code: f1 :: String - String f2 :: IO String - IO () f2 a = do b - a putStr $ f1 b How can I write the function f2 in a point-free style? maybe f2 = (=) (putStrLn . f1) I still prefer the non point-free but clearer f2 = a = (putStrLn . f1) -- Message: 3 Date: Sun, 31 Mar 2013 12:27:49 +0300 From: Ovidiu D ovidiud...@gmail.com Subject: Re: [Haskell-beginners] point-free + IO Monad To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: cakvse7v1f9asc0ev+5uabocq_kwev9kccyxgnersouvajz+...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 That's good enough. Thanks! On Sun, Mar 31, 2013 at 11:08 AM, Franco franc...@gmx.com wrote: Ovidiu D ovidiudeac at gmail.com writes: I have the following code: f1 :: String - String f2 :: IO String - IO () f2 a = do b - a putStr $ f1 b How can I write the function f2 in a point-free style? maybe f2 = (=) (putStrLn . f1) I still prefer the non point-free but clearer f2 = a = (putStrLn . f1) ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130331/04de00ec/attachment-0001.htm -- Message: 4 Date: Sun, 31 Mar 2013 19:59:25 +1000 From: Tony Morris tmor...@tmorris.net Subject: Re: [Haskell-beginners] point-free + IO Monad To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: cajf6usiwlxh1c-mej-z+g+9qk5acxlpf8twudxow20j5y_o...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 You can drop the parens if you like. f2 a = putStrLn . f1 = a -- my preference f2 a = a = putStrLn . f1 On 31/03/2013 7:29 PM, Ovidiu D ovidiud...@gmail.com wrote: That's good enough. Thanks! On Sun, Mar 31, 2013 at 11:08 AM, Franco franc...@gmx.com wrote: Ovidiu D ovidiudeac at gmail.com writes: I have the following code: f1 :: String - String f2 :: IO String - IO () f2 a = do b - a putStr $ f1 b How can I write the function f2 in a point-free style? maybe f2 = (=) (putStrLn . f1) I still prefer the non point-free but clearer f2 = a = (putStrLn . f1) ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130331/a15237f4/attachment-0001.htm -- ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 57, Issue 43 *
Beginners Digest, Vol 57, Issue 45
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: Quickcheck2 - writing a modifier for test data (Nathan H?sken) 2. Re: [IO String] to IO [String] (Brent Yorgey) 3. Re: [IO String] to IO [String] (Ovidiu D) 4. Re: [IO String] to IO [String] (Kim-Ee Yeoh) 5. Re: [IO String] to IO [String] (Lyndon Maydwell) 6. finding the cause of an error (here head: empty list) (Nathan H?sken) -- Message: 1 Date: Sun, 31 Mar 2013 13:13:18 +0200 From: Nathan H?sken nathan.hues...@posteo.de Subject: Re: [Haskell-beginners] Quickcheck2 - writing a modifier for test data To: beginners@haskell.org Message-ID: 51581a4e.8070...@posteo.de Content-Type: text/plain; charset=ISO-8859-1; format=flowed That was it. Thanks! On 03/31/2013 12:30 PM, Brent Yorgey wrote: On Sun, Mar 31, 2013 at 12:21:48PM +0200, Nathan H?sken wrote: No instance for (QuickCheck-2.4.2:Test.QuickCheck.Arbitrary.Arbitrary ValidPos) The fact that it actually lists the package and version number in the error message strongly suggests that the problem is conflicting versions of the QuickCheck package. Do 'ghc-pkg list QuickCheck' to see if you have multiple versions installed, and unregister all but one of them. -Brent ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- Message: 2 Date: Sun, 31 Mar 2013 07:30:08 -0400 From: Brent Yorgey byor...@seas.upenn.edu Subject: Re: [Haskell-beginners] [IO String] to IO [String] To: beginners@haskell.org Message-ID: 20130331113008.ga9...@seas.upenn.edu Content-Type: text/plain; charset=iso-8859-1 To elaborate a bit: you originally said I don't like that the line processing I'm doing will have to be in the IO monad -- but since you want the processing of the list of Strings to be interleaved with IO operations, you have no choice. Pure functions of type [String] - [String] cannot have their evaluation interleaved with IO operations. Note that functions using lazy I/O such as getContents, readFile, etc. can create exceptions to this -- but these use unsafeInterleaveIO under the hood and are widely regarded as problematic. So you could try using unsafeInterleaveIO, but it is unsafe for a reason. I do not actually know what is required to ensure you are using it safely; perhaps someone else could elaborate on this. -Brent On Sun, Mar 31, 2013 at 01:48:23PM +0300, Ovidiu D wrote: Right. I definitely want the lazy behavior. Thanks On Sun, Mar 31, 2013 at 1:29 PM, Brent Yorgey byor...@seas.upenn.eduwrote: Unfortunately, with the definition f = getLine : f this will not work. 'sequence f' has to do *ALL* the IO before you can process even the first String in the resulting list. Since it is infinite, it will just sit there reading lines forever but never letting you process them. I think in this case using [IO String] is actually a good solution. -Brent On Sun, Mar 31, 2013 at 12:24:33PM +0200, Nathan H?sken wrote: Try sequence :: Monad m = [m a] - m [a] I thinkg sequence f :: IO [String] should be what you want. On 03/31/2013 12:19 PM, Ovidiu D wrote: I have the function f which reads lines form the stdin and looks like this: f :: [IO String] f = getLine : f What I don't like is the fact that the line processing I'm doing will have to be in the IO Monad I would like to make this function to have the signature f : IO [String] ...such that I can get rid of the IO monad and pass the pure string list to the processing function. Can I do this? Thanks ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- Message: 3 Date: Sun, 31 Mar 2013 14:42:40 +0300 From: Ovidiu
Beginners Digest, Vol 58, Issue 2
Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than Re: Contents of Beginners digest... Today's Topics: 1. Re: lazy mapM (Kim-Ee Yeoh) 2. Re: lazy mapM (Ovidiu D) 3. Re: lazy mapM (David McBride) 4. Re: lazy mapM (Ovidiu D) 5. Re: lazy mapM (David McBride) -- Message: 1 Date: Mon, 1 Apr 2013 07:29:54 +0700 From: Kim-Ee Yeoh k...@atamo.com Subject: Re: [Haskell-beginners] lazy mapM To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: capy+zdtoch6rdthcduksucqspunrt14axma_uvuoxxtbbl-...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 On Mon, Apr 1, 2013 at 6:26 AM, Ovidiu D ovidiud...@gmail.com wrote: 1. Make f behave lazy Its input list is made of lines read from stdin and I want it to process lines one by one as they are entered by the user. Eschewing laziness (which adds only complexity in this case), here's something that'll work, if a little ugly: import System.Exit f :: String - IO () f exit = exitSuccess f a = putStrLn $ you entered: ++ a main = do s - getLine f s main Going down this path would involve IORef's, among others from the sin bin. Something more pure and haskell-y would typically involve an analysis of the DSL abstract syntax and state space and implementation using a combination of State and Free monads. -- Kim-Ee -- Message: 2 Date: Mon, 1 Apr 2013 03:49:07 +0300 From: Ovidiu D ovidiud...@gmail.com Subject: Re: [Haskell-beginners] lazy mapM To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: CAKVsE7uFUQ6Nvwht5XvcTg0fePFkcgy5nm9=qsozkcgu8k4...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 Thanks. Since this is an exercise I would be really curious what is the idiomatic Haskell approach. On Mon, Apr 1, 2013 at 3:29 AM, Kim-Ee Yeoh k...@atamo.com wrote: On Mon, Apr 1, 2013 at 6:26 AM, Ovidiu D ovidiud...@gmail.com wrote: 1. Make f behave lazy Its input list is made of lines read from stdin and I want it to process lines one by one as they are entered by the user. Eschewing laziness (which adds only complexity in this case), here's something that'll work, if a little ugly: import System.Exit f :: String - IO () f exit = exitSuccess f a = putStrLn $ you entered: ++ a main = do s - getLine f s main Going down this path would involve IORef's, among others from the sin bin. Something more pure and haskell-y would typically involve an analysis of the DSL abstract syntax and state space and implementation using a combination of State and Free monads. -- Kim-Ee ___ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -- next part -- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20130401/89531d6f/attachment-0001.htm -- Message: 3 Date: Sun, 31 Mar 2013 20:53:04 -0400 From: David McBride toa...@gmail.com Subject: Re: [Haskell-beginners] lazy mapM To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell beginners@haskell.org Message-ID: can+tr40a6mxmm6cqxptnxw_kujsexzbqleimgyhoy07vsvk...@mail.gmail.com Content-Type: text/plain; charset=iso-8859-1 I know you have the best intentions in writing this, but there are pitfalls. Unexpected things happen when you interleave IO in this manner, but nonetheless, here's how you would do it. myGetLine = do x - getLine if (x == exit) then return [] else do xs - unsafeInterleaveIO myGetLine return (x:xs) main = do x - myGetLine print x Just know that at some point you should learn to use conduits or pipes for a much better approach to modeling things like this. On Sun, Mar 31, 2013 at 7:26 PM, Ovidiu D ovidiud...@gmail.com wrote: Hi again, Given the following code: g :: IO String - IO String f :: [IO String] - IO [ String ] f = mapM g The implementation of f is wrong because I would like to: 1. Make f behave lazy Its input list is made of lines read from stdin and I want it to process lines one by one as they are entered by the user. 2. Implement f such that it stops consuming items from the input list when the input item meets some condition. For