[Haskell-cafe] Haskell showcase in 5 minutes - follow-up
Hello Cafe, Thanks to all of you who provided ideas and suggestions for introducing Haskell. I finally went the simple way, presenting the knapsack problem slightly reframed using tapas (spanish dishes). This problem is small enough to fit in the 5 minutes time-frame and it actually illustrates some of the salient points of the langauge: laziness of course, list-comprehensions, monadic computations (replicateM), first-class and higher-order functions, the REPL, integration with emacs, command-line compiling. Here is the code https://gist.github.com/1948301 I got a lot of positive feedback during the evening as I did some more live coding on simple problems (fizz-buzz, fibonacci) and I ended up showing some code I wrote doing real stuff, notably the simple music synthesizer I wrote (https://github.com/abailly/haskell-synthesizer) for presenting Haskell to Paris Scala user Group and inspired of course by Paul Hudak's book and Joao Pizani's blog ( http://joaopizani.hopto.org/en/2012/01/haskell-synth/). The meeting ended with an impromptu panel on the disadvantages of the languages presented by each speaker which was really hard for me given the sheer perfection of Haskell. One advantage I mentionned somewhat indirectly which I should stress here is the Haskell community: reactive, vibrant and kind are a few adjectives that spring to my mind. Thanks again for your support, Arnaud Bailly ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Records in Haskell
Evan Laforge qdunkan at gmail.com writes: [ ccing the list because the wiki page was flawed and I made a bunch of changes, hope you don't mind ] Thanks Evan, I've had a quick read through. It's a bit difficult to compare to the other proposals. I can't see discussion of extracting higher-ranked functions and applying them in polymorphic contexts. (This is SPJ's `rev` example.) Putting h-r fields into records is the standard way of emulating object- oriented style. SPJ's view is that requirement is very important in practice. (No proposal has a good answer to updating h-r's, which you do discuss.) Re the cons 1. Still can't have two records with the same field name in the same module since it relies on modules for namespacing. Did you see the DORF precursor page ? http://hackage.haskell.org/trac/ghc/wiki/Records/DeclaredOverloadedRecordFields /NoMonoRecordFields I tried to figure out if that would help, but I suspect not. (Looking at the desugar for `deriving (Lens)`, you need the H98 field selector functions.) Then for me, cons 1. is a show-stopper. (I know you think the opposite.) I also don't see whether you can 'hide' or make abstract the representation of a record type, but still allow read-access to (some of) its fields. Suppose a malicious client declares a record with field #a. Can you stop them reading and/or updating your field #a whilst still letting them see field #b of your record type? With SDNR, is it possibly to define a polymorphic field selector function? I suspect no looking at the desugar for `deriving (Lens)`, but perhaps I've mis- understood. I mean: get_a r = ?? #a r -- gets the #a field from any record r This mechanism then supports the idea of 'virtual' fields -- SPJ's example of fullName, built from polymorphic firstName and lastName. [By the way, did you mean to post to the cafe only? Most of the discussion is going on on ghc-users.] AntC ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] need help with monad transformers
If I'm running register outside runWriterT everything will work. Maybe just lift $ register $ print freed2 or I didn't catch something? 2012/3/1 Alexander V Vershilov alexander.vershi...@gmail.com Hello. I'm trying to add monad stack into network-conduit, and everything works except some details [1]. I've run runReaderT $ runTCPServer (wrapper around runResourceT) and inside conduit I want to run writer to gather results of inner computation. In inner computation I want to use IO, data from outter stack (ReaderT) so I'm running {-1-}: (k,t) - lift $ runWriterT $ ask = \x - tell [x] {- 1 -} and {-2-} (k,t) - lift $ runWriterT $ do {- 2 -} x - ask liftIO $ print $x+1 tell [x] and that will work (except I've thought I should not lift runWriterT, but calling functions inside. And finally in computation that will run once I want to register cleaning function (for example register $ putStrLn cleaned) ({-3-}) (k,t) - lift $ runWriterT $ do {- 3 -} x - ask liftIO $ print $x+1 register $ print freed2 tell [x] but I've got type error. If I'm running register outside runWriterT everything will work. I would apperated if there will be any suggestions how to make this code better or use register in internal computation (runWriterT) [1] https://gist.github.com/1941151 -- Best regards, Alexander V Vershilov ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] need help with monad transformers
It will not work due: gistfile1.hs:29:36: Could not deduce (m ~ ResourceT m0) from the context (Base m ~ IO, MonadReader SInit m, MonadIO m, IsSource src, Resource m) bound by the type signature for app :: (Base m ~ IO, MonadReader SInit m, MonadIO m, IsSource src, Resource m) = src m a1 - Sink a1 m b - ResourceT m b at gistfile1.hs:(29,1)-(59,27) `m' is a rigid type variable bound by the type signature for app :: (Base m ~ IO, MonadReader SInit m, MonadIO m, IsSource src, Resource m) = src m a1 - Sink a1 m b - ResourceT m b at gistfile1.hs:29:1 Expected type: Conduit a1 m a1 Actual type: Conduit a1 (ResourceT m0) a1 In the second argument of `(=$=)', namely `process2' In the second argument of `($=)', namely `(process1 =$= process2)' Thu, Mar 01, 2012 at 02:19:29PM +0400, Dmitry Olshansky wrote If I'm running register outside runWriterT everything will work. Maybe just lift $ register $ print freed2 or I didn't catch something? 2012/3/1 Alexander V Vershilov alexander.vershi...@gmail.com Hello. I'm trying to add monad stack into network-conduit, and everything works except some details [1]. I've run runReaderT $ runTCPServer (wrapper around runResourceT) and inside conduit I want to run writer to gather results of inner computation. In inner computation I want to use IO, data from outter stack (ReaderT) so I'm running {-1-}: (k,t) - lift $ runWriterT $ ask = \x - tell [x] {- 1 -} and {-2-} (k,t) - lift $ runWriterT $ do {- 2 -} x - ask liftIO $ print $x+1 tell [x] and that will work (except I've thought I should not lift runWriterT, but calling functions inside. And finally in computation that will run once I want to register cleaning function (for example register $ putStrLn cleaned) ({-3-}) (k,t) - lift $ runWriterT $ do {- 3 -} x - ask liftIO $ print $x+1 register $ print freed2 tell [x] but I've got type error. If I'm running register outside runWriterT everything will work. I would apperated if there will be any suggestions how to make this code better or use register in internal computation (runWriterT) [1] https://gist.github.com/1941151 -- Best regards, Alexander V Vershilov ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] FreeSect -- generalised sections syntax extension
For anyone who tried building the implementation linked off the fremissant page (see above email), there was a glitch or two and this is fixed. The problem being simply the target path -- I build to a ramdisk because, as is often the case, GHC produces a rather large binary and I don't like to thrash my HDD during development. The executable is now produced in the root directory of the distro. Cheers, Andrew On Wed, Feb 29, 2012 at 9:27 PM, Ras Far ras...@gmail.com wrote: Hello, I bit premature perhaps but I wanted to post it on a leap day... http://fremissant.net/freesect Thanks for eyebloom on #haskell for motivating me to finally implement an old idea. Thanks to the rest on #haskell for doing their best to talk me out of it. ;) I make no claims regarding the usefulness of the extension, but some folks might find it interesting, or may just appreciate additional examples of using HSE and SYB. I regret that I am not a better Haskell coder, but it is what it is! Kind Reg'ds, Andrew Seniuk (rasfar) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Does somebody know about these functions?
So, these two functions do not appear to be defined, perhaps because many of their potential uses could be expressed using the functions from Data.Applicative and Data.Arrow instead. You may have noticed that the words and lines examples where defunct, but not difficult to fix: words = go . dropWhile isSpace where go [] = [] go s = withPair (:) id words (break isSpace s) lines [] = [] lines s = withPair (:) id (lines . safeTail) (break (== '\n') s) safeTail [] = [] safeTail l = tail l Ofcourse RHS of 'lines s' can be written (and likewise for words): uncurry (:) $ second (lines . safeTail) $ break (== '\n') s which looks rather nice to me. /Johan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Fwd: Now Accepting Applications for Mentoring Organizations for GSoC 2012
FYI, Edward Kmett has volunteered to do it again. On 28/02/2012 16:23, Johan Tibell wrote: Hi all, Anyone interested in acting as an admin for haskell.org http://haskell.org this year? I'm afraid I won't have time. It's not that much work (filling in some information, sending out some emails, making sure things happen in time.) -- Forwarded message -- From: *Carol Smith* car...@google.com mailto:car...@google.com Date: Mon, Feb 27, 2012 at 11:47 AM Subject: Now Accepting Applications for Mentoring Organizations for GSoC 2012 To: Google Summer of Code Announce google-summer-of-code-annou...@googlegroups.com mailto:google-summer-of-code-annou...@googlegroups.com Hi all, We're pleased to announce the applications for mentoring organizations for GoogleSummer of Code 2012 are now being accepted [1]. Please go Melange [2] to apply on behalf of your organization. Please note that the application period [3] closes on 9 March at 23:00 UTC. We will not accept any late applications for any reason. [1] - http://google-opensource.blogspot.com/2012/02/mentoring-organization-applications-now.html [2] - http://www.google-melange.com [3] - http://www.google-melange.com/gsoc/events/google/gsoc2012 Cheers, Carol -- You received this message because you are subscribed to the Google Groups Google Summer of Code Announce group. To post to this group, send email to google-summer-of-code-annou...@googlegroups.com mailto:google-summer-of-code-annou...@googlegroups.com. To unsubscribe from this group, send email to google-summer-of-code-announce+unsubscr...@googlegroups.com mailto:google-summer-of-code-announce%2bunsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-summer-of-code-announce?hl=en. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] need help with monad transformers
I've found a solution, I should not use lift for runWriterT, and should explicilty lift all computation of level I need, i.e. (lift.lift) for ask and lift for register. Thu, Mar 01, 2012 at 02:19:29PM +0400, Dmitry Olshansky wrote If I'm running register outside runWriterT everything will work. Maybe just lift $ register $ print freed2 or I didn't catch something? 2012/3/1 Alexander V Vershilov alexander.vershi...@gmail.com Hello. I'm trying to add monad stack into network-conduit, and everything works except some details [1]. I've run runReaderT $ runTCPServer (wrapper around runResourceT) and inside conduit I want to run writer to gather results of inner computation. In inner computation I want to use IO, data from outter stack (ReaderT) so I'm running {-1-}: (k,t) - lift $ runWriterT $ ask = \x - tell [x] {- 1 -} and {-2-} (k,t) - lift $ runWriterT $ do {- 2 -} x - ask liftIO $ print $x+1 tell [x] and that will work (except I've thought I should not lift runWriterT, but calling functions inside. And finally in computation that will run once I want to register cleaning function (for example register $ putStrLn cleaned) ({-3-}) (k,t) - lift $ runWriterT $ do {- 3 -} x - ask liftIO $ print $x+1 register $ print freed2 tell [x] but I've got type error. If I'm running register outside runWriterT everything will work. I would apperated if there will be any suggestions how to make this code better or use register in internal computation (runWriterT) [1] https://gist.github.com/1941151 -- Best regards, Alexander V Vershilov ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Records in Haskell
Thanks Evan, I've had a quick read through. Thanks for reading and commenting! It's a bit difficult to compare to the other proposals. I can't see discussion of extracting higher-ranked functions and applying them in polymorphic contexts. (This is SPJ's `rev` example.) Putting h-r fields into records is the standard way of emulating object- oriented style. SPJ's view is that requirement is very important in practice. (No proposal has a good answer to updating h-r's, which you do discuss.) Yeah, I've never wanted that kind of thing. I've written in object-oriented languages so it's not just that I'm not used to the feature so I don't feel its lack. And if I did want it, I would probably not mind falling back to the traditional record syntax, though I can see how people might find that unsatisfying. But my suggestion is meant to solve only the problem of composed record updates and redundant things in 'Thing.thing_field thing'. Not supporting higher-ranked function record fields *only* means that you can't use this particular convenience to compose updates to a higher-ranked field. If you happen to have that particular intersection of requirements then you'll have to fall back to typing more things for that particular update. My motivation is to solve an awkward thing about writing in haskell as it is, not add a new programming style. Re the cons 1. Still can't have two records with the same field name in the same module since it relies on modules for namespacing. Did you see the DORF precursor page ? http://hackage.haskell.org/trac/ghc/wiki/Records/DeclaredOverloadedRecordFields /NoMonoRecordFields I tried to figure out if that would help, but I suspect not. (Looking at the desugar for `deriving (Lens)`, you need the H98 field selector functions.) Then for me, cons 1. is a show-stopper. (I know you think the opposite.) Yeah, I don't think the DORF precursor stuff is related, because it's all based on typeclasses. I think there are two places where people get annoyed about name clashes. One is where they really want to have two records with the same field name defined in one module. The other is where they are using unqualified imports to shorten names and get a clash from records in different modules. Only the former is a problem, the latter should work just fine with my proposal because ghc lets you import clashing names as long as you don't call them unqualified, and SDNR qualifies them for you. So about the former... I've never had this problem, though the point about circular imports forcing lots of things into the same module is well taken, I have experienced that. In that case: nested modules. It's an orthogonal feature that can be implemented and enabled separately, and can be useful in other ways too, and can be implemented separately. If we are to retain modules as *the* way to organize namespaces and visibility then we should think about fancying-up modules when a namespacing problem comes up. Otherwise you're talking about putting more than one function into one symbol, and that's typeclasses, and now you have to think of something clever to counteract typeclasses' desire to be global (e.g. type proxies). Maybe that's forcing typeclasses too far beyond their power/weight compromise design? I also don't see whether you can 'hide' or make abstract the representation of a record type, but still allow read-access to (some of) its fields. If you want a read-only field, then don't export the lens for 'a', export a normal function for it. However, it would mean you'd use it as a normal function, and couldn't pass it to 'get' because it's not a lens, and couldn't be composed together with lenses. I'd think it would be possible to put 'get' and 'set' into different typeclasses and give ReadLenses only the ReadLens dictionary. But effectively we'd need subtyping, so a Lens could be casted automatically to a ReadLens. I'm sure it's possible to encode with clever rank2 and existentials and whatnot, but at that point I'm inclined to say it's too complicated and not worth it. Use plain functions. Since 'get' turns a lens into a plain function, you can still compose with '#roField . get (#rwField1 . #rwField2)'. We could easily support 'get (#roField1 . #roField2)' by doing the ReadLens thing and putting (-) into ReadLens, it's just combining rw fields and ro fields into the same composition that would require type gymnastics. Suppose a malicious client declares a record with field #a. Can you stop them reading and/or updating your field #a whilst still letting them see field #b of your record type? I don't think it's worth designing to support malicious clients, but if you don't want to allow access to a function or lens or any value, then don't export it. #a can't resolve to M.a if M doesn't export 'a'. With SDNR, is it possibly to define a polymorphic field selector function? I suspect no looking at the desugar for `deriving (Lens)`, but perhaps
Re: [Haskell-cafe] Fwd: Now Accepting Applications for Mentoring Organizations for GSoC 2012
On Thu, Mar 1, 2012 at 12:54 PM, Ganesh Sittampalam gan...@earth.li wrote: FYI, Edward Kmett has volunteered to do it again. That's great since he's the most experienced GSoC admin we have. :) There's still room for a replacement for me. I had a few people show interest so far. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Fwd: Now Accepting Applications for Mentoring Organizations for GSoC 2012
On 01/03/2012 21:37, Johan Tibell wrote: On Thu, Mar 1, 2012 at 12:54 PM, Ganesh Sittampalam gan...@earth.li mailto:gan...@earth.li wrote: FYI, Edward Kmett has volunteered to do it again. That's great since he's the most experienced GSoC admin we have. :) There's still room for a replacement for me. I had a few people show interest so far. Maybe I'm confused about the roles, then. Were you co-admins previously, or something else? Ganesh ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Conduits and large ConduitResult chunks
I'm porting lzma-enumerator over to conduits and I've run into a snag. The output chunks from lzma can be quite large, so I'd like to stream the results out in smaller chunks instead of tens (or hundreds) of megabytes at a time. It seems as though this should be possible, as it is with enumeratees, but I can't see how. Is there a way to get this working without unsafeInterleaveIO? https://github.com/alphaHeavy/lzma-conduit/blob/2b1451f5596b2db5a23df9a0fb128c7444e112b2/src/Data/Conduit/Lzma.hs#L165 thanks, -n ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Fwd: Now Accepting Applications for Mentoring Organizations for GSoC 2012
On Thu, Mar 1, 2012 at 1:42 PM, Ganesh Sittampalam gan...@earth.li wrote: On 01/03/2012 21:37, Johan Tibell wrote: On Thu, Mar 1, 2012 at 12:54 PM, Ganesh Sittampalam gan...@earth.li mailto:gan...@earth.li wrote: FYI, Edward Kmett has volunteered to do it again. That's great since he's the most experienced GSoC admin we have. :) There's still room for a replacement for me. I had a few people show interest so far. Maybe I'm confused about the roles, then. Were you co-admins previously, or something else? Edward and I were co-admins last year. That worked out great in my opinion. I want to make sure that we have at least one admin this year, otherwise we won't get any GSoC slots this year, hence my original email. I didn't know if Edward was interested or not. Now we have a few candidates, including Edward. My preference is to have 2+ admins, preferably with Edward as one of them as he has experience in the matter. Sorry about the confusions. Cheers, Johan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] FreeSect -- generalised sections syntax extension
On Wed, Feb 29, 2012 at 9:27 PM, Ras Farras...@gmail.com wrote: Hello, I bit premature perhaps but I wanted to post it on a leap day... http://fremissant.net/freesect Thanks for eyebloom on #haskell for motivating me to finally implement an old idea. Thanks to the rest on #haskell for doing their best to talk me out of it. ;) I make no claims regarding the usefulness of the extension, but some folks might find it interesting, or may just appreciate additional examples of using HSE and SYB. I regret that I am not a better Haskell coder, but it is what it is! Kind Reg'ds, Andrew Seniuk (rasfar) why couldn't you use standard brackets ( to delimit the extent ? I suppose that would have added complexity to the syntax analysis, however I think it would have been (in my mind) neater. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] need help with monad transformers
Did you try to use transformers instead of mtl? I am just in doubt about it in my work. I've found that Conduit use it. So you remove extra dependency. I hope that transformers have more readable messages (without FD) and you can control what is lift more clear. I have no experience although. 2012/3/2 Alexander V Vershilov alexander.vershi...@gmail.com I've found a solution, I should not use lift for runWriterT, and should explicilty lift all computation of level I need, i.e. (lift.lift) for ask and lift for register. Thu, Mar 01, 2012 at 02:19:29PM +0400, Dmitry Olshansky wrote If I'm running register outside runWriterT everything will work. Maybe just lift $ register $ print freed2 or I didn't catch something? 2012/3/1 Alexander V Vershilov alexander.vershi...@gmail.com Hello. I'm trying to add monad stack into network-conduit, and everything works except some details [1]. I've run runReaderT $ runTCPServer (wrapper around runResourceT) and inside conduit I want to run writer to gather results of inner computation. In inner computation I want to use IO, data from outter stack (ReaderT) so I'm running {-1-}: (k,t) - lift $ runWriterT $ ask = \x - tell [x] {- 1 -} and {-2-} (k,t) - lift $ runWriterT $ do {- 2 -} x - ask liftIO $ print $x+1 tell [x] and that will work (except I've thought I should not lift runWriterT, but calling functions inside. And finally in computation that will run once I want to register cleaning function (for example register $ putStrLn cleaned) ({-3-}) (k,t) - lift $ runWriterT $ do {- 3 -} x - ask liftIO $ print $x+1 register $ print freed2 tell [x] but I've got type error. If I'm running register outside runWriterT everything will work. I would apperated if there will be any suggestions how to make this code better or use register in internal computation (runWriterT) [1] https://gist.github.com/1941151 -- Best regards, Alexander V Vershilov ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Conduits and large ConduitResult chunks
On Thu, Mar 1, 2012 at 11:50 PM, Nathan Howell nathan.d.how...@gmail.com wrote: I'm porting lzma-enumerator over to conduits and I've run into a snag. The output chunks from lzma can be quite large, so I'd like to stream the results out in smaller chunks instead of tens (or hundreds) of megabytes at a time. It seems as though this should be possible, as it is with enumeratees, but I can't see how. Is there a way to get this working without unsafeInterleaveIO? https://github.com/alphaHeavy/lzma-conduit/blob/2b1451f5596b2db5a23df9a0fb128c7444e112b2/src/Data/Conduit/Lzma.hs#L165 thanks, -n ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe I just wrote a blog post on this topic: http://www.yesodweb.com/blog/2012/03/more-powerful-conduit Feedback requested! Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe