[Haskell-cafe] Is Repa suitable for boxed arrays?...
Hi, I have a newb-ish question about Haskell 2D arrays. I need to construct a 2D array of a Haskell data type (boxed ?) where each array entry value depends on values earlier in the same array (i.e. for entries in previous row/column indexes). Repa (V3.1.4.2) looks very powerful and flexible but it's still not clear to me that it will work with arbitrary values as I haven't been able to get any of the Wiki tutorial array creation examples to work (this is with Haskell platform 2012.2 pre-release for OS/X). I can see I could also construct my own 2D array data structure from Data.Vector instances. Are there any other approaches for general 2D arrays I should be looking at? Thanks, Stu ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Need inputs for a Haskell awareness presentation
Maybe too late but here it is: I was given a similar opportunity recently, but with only developers in the audience (no managers), so I focused on coding examples and functional programming in general rather than Haskell in particular (although all code examples were Haskell). One thing I tried to do was crushing the myth (?) that functional programming is more difficult than imperative by showing an example of typical imperative code and it's functional mate. I was afraid this would not fly well because the particular code example was the fibonacci sequence (it was the shortest most to the point example I could think of then)[1]. To my surprise it was fairly well received and I believe the point got through. Other more real world code examples where shown (counting word frequencies in a text file etc), introducing folding and mapping and the ever useful list. If I was to do this again, given the experience, I would try focus more on the types of functions, to show how much can be learned about a function's behaviour by just lookup at it's type. I feel this got lost in my presentation due to me utilising type reconstruction to show how writing code in a staticaly typed FPL like Haskell resembles coding in scripting languages (succintness) but with the compiler helping spot many errors. Time is the obvious enemy when introducing an imperative audience to FP. Code is mostly uninteresting for an audience who do not understand it, so you may need to explain HOF:s, algebraic data types, currying (for Haskell) and maybe point free style, the ring operator etc. This can easily steal the whole time slot if you are not careful. I agree that using GHCI is very good, but I think you should be careful if using emacs' ghci integration so the audience do not believe interaction is only possible through emacs. Best wishes! /Johan [1] Showing both the memoized zipWith version and the non-memoized and incredibly inefficient version, explaining the difference. 2012/6/2 C K Kashyap ckkash...@gmail.com: Thank you all very much, I am sitting now and collating all your responses. I'll revert with questions if I may have. Indeed, it may be better to have this kind of collateral ready for future use. I am going to put my stuff on github considering markdown + pandoc. Regards, Kashyap On Sat, Jun 2, 2012 at 3:06 AM, Claus Reinke claus.rei...@talk21.com wrote: I have the opportunity to make a presentation to folks (developers and managers) in my organization about Haskell - and why it's important - and why it's the only way forward. Haskell is important, but not the only way forward. Also, there have been other great languages, with limited impact - incorporating great ideas is no guarantee for takeup. If you want to be convincing, you need to be honest. 1. Any thoughts around the outline of the presentation - target audience being seasoned imperative programmers who love and live at the pinnacle of object oriented bliss. If you approach this from the Haskell side (what is Haskell good at), you might get some people curious, but you won't connect their interest to their daily work. You don't want to give them a show, you want to inspire them to want to try coding in that language. If you really want to understand what is good about Haskell, stop using it for a while, and work in something like Javascript (or whatever your audience is comfortable with, but for me Javascript was an eye opener). You won't believe how basic the issues are that conventional coders are struggling with until you realize that you do not have them in Haskell. If you have felt that pain, have understood that you can't make those issues go away by saying that wouldn't be an issue in Haskell, then you can understand that their struggles and issues are real. If you respect that, you can take one of their problems/source bases, and translate it to Haskell. That step tells them (and you!) that Haskell is adequate for their problem domains (which won't always be the case - no point showing them a wonderful language that they won't be able to apply). The next step is to go through some of those pain points in that code and show how to get rid of them in the Haskell version. Instead of presenting ready-made solutions, show them how to work with code they understand, much more confidently than they would be used to. Go slowly, and focus on their daily pain points (which they probably have stopped feeling because they can't do anything against them). Explain why you are confident in your modifications, compare against the obstacles that their current language would throw up against such modifications. Some examples: - types can replace basic documentation and documentation lookup - no need to test things that the type system can check, not in test suites and not in the prelude of every function definition; you still need tests, but those can focus on interesting aspects;
Re: [Haskell-cafe] Re-exports of resourcet in conduit
The easiest thing to do is just build your code with cabal, which will ensure you're using consistent versions. (Similar questions came up twice recently on Stack Overflow[1][2].) Wiping our your ~/.ghc and installing from scratch should work also, but it's like using a tactical nuke instead of a scalpel. As for checking versions of dependencies, try `ghc-pkg describe conduit`. Michael [1] http://stackoverflow.com/questions/10729291/lifting-trouble-with-resourcet/10730909#10730909 [2] http://stackoverflow.com/questions/10843547/snap-monad-liftio-and-ghc-7-4-1/10847401#10847401 On Sun, Jun 3, 2012 at 3:01 AM, Myles C. Maxfield myles.maxfi...@gmail.com wrote: It could be. Do you know how I can check which versions of packages other packages have built against with Cabal? Will it help if I remove all the relevant packages and then re-install only a single version? Thanks, Myles On Saturday, June 2, 2012, Antoine Latter wrote: Is it possible that you are puuling in two different versions of the package that defines the MonadThrow class? That is, package a was built against version 1, but package b was built against version 2? This would make GHC think the type-class were incompatable. This is just a guess - I have not tried what you are trying. On Jun 2, 2012 6:35 PM, Myles C. Maxfield myles.maxfi...@gmail.com wrote: To: Michael Snoyman CC: haskell-cafe Hello, I'm having a problem working with the conduit library, and was hoping you could help me out. Data.Conduit re-exports ResourceT, MonadResource, and MonadThrow (but not ExceptionT) from Control.Monad.Trans.Resource. I have a conduit which operates on a monad in the MonadThrow class. I am trying to figure out which MonadThrow class this should be (the Data.Conduit.MonadThrow class, or the Montrol.Monad.Trans.Resource.MonadThrow class, since apparently GHC doesn't recognize them as the same, even though one is just a re-export of the other). If a user of this conduit wants to chain this conduit up with something like sourceFile, the underlying monad has to be a member of Data.Conduit.MonadResource and whatever MonadThrow class I chose to use. I would like to be able to use an existing instance to lift the class of the inner monad to the class of the entire monad stack (so I don't have to tell the user of my conduit that they have to define their own instances), and the only rule that I can find that does that is the following from Data.Conduit: Data.Conduit.MonadThrow m = Data.Conduit.MonadThrow (Data.Conduit.ResourceT m) However, GHC doesn't seem to think that Control.Monad.Trans.Resource.ExceptionT is an instance of Data.Conduit.MonadThrow: No instance for (Data.Conduit.MonadThrow (ExceptionT IO)) arising from a use of `.' Control.Monad.Trans.Resource has a similar instance: Control.Monad.Trans.Resource.MonadThrow m = Control.Monad.Trans.Resource.MonadThrow (Control.Monad.Trans.Resource.ResourceT m) but because sourceFile operates in the Data.Conduit.MonadResource class, and Control.Monad.Trans.Resource.ResourceT isn't a member of that class (it's only a member of Control.Monad.Trans.Resource.MonadResource), that doesn't help: No instance for (Data.Conduit.MonadResource (Control.Monad.Trans.Resource.ResourceT (ExceptionT IO))) arising from a use of `.' It should be noted that neither module defines anything like the following: MonadResource m = MonadResource (ExceptionT m) It seems like the underlying problem here is that: 1) I am required to use the Control.Monad.Trans.Resource.ExceptionT class, because Data.Conduit doesn't re-export it 2) I am required to use the Data.Conduit.MonadResource class, because sourceFile and others require it 3) There doesn't seem to be an existing instance that bridges between the two. This seems like a fundamental flaw with re-exporting; it can only work if you re-export every single last thing from the original module. This doesn't seem tenable because the orignal module might not be under your control, so its author can add new symbols whenever he/she wants to. I see two solutions to this problem: 1) Re-export Control.Monad.Trans.Resource.ExceptionT in Data.Conduit. This will work until someone adds something to the resourcet package and someone wants to use the new addition and Data.Conduit.ResourceT in the same stack 2) Don't re-export anything in Data.Conduit; make sourceFile and others explicitly depend on types in another module, but this might break compatibility with existing programs if they use fully-qualified symbol names. 3) Make anyone who wants to use a monad stack in MonadThrow and MonadResource define their own instances. This is probably no good because it means that many different modules will implement the same instance in potentially many different ways. I feel like option 2) is probably the best solution here. I'm perfectly happy to issue a pull
Re: [Haskell-cafe] Most Important GHC extensions to learn/use?
On Fri, Jun 1, 2012 at 4:37 PM, James Cook mo...@deepbondi.net wrote: On Jun 1, 2012, at 6:11 AM, Gábor Lehel wrote: On Fri, Jun 1, 2012 at 6:29 AM, wren ng thornton w...@freegeek.org wrote: TypeFamilies (aka TFs) These are really nifty and they're all the rage these days. In a formal sense they're equivalent to fundeps, but in practice they're weaker than fundeps. Is that still true? The reason used to be that we didn't have superclass equalities, but we do have them now since 7.2. The only drawbacks I know of relative to FDs are that it's sometimes more typing, not supported by GeneralizedNewtypeDeriving, and doesn't allow OverlappingInstances (ick). In addition to other things mentioned today in the Fundeps and overlapping instances thread, type families have no way of defining injective type functions where the range includes already-existing types. For example, if you define: type family Succ a there is no way (that I've found) to define it in such a way that the compiler can see that Succ a ~ Succ b = a ~ b. The equivalent in MPTCs+FDs would be: class Succ a b | a - b, b - a class (S a ~ b, P b ~ a) = Succ a b where type S a type P b (Succ a c, Succ b c) = (S a ~ c, P c ~ a, S b ~ c, P c ~ b) = (P c ~ a, P c ~ b) = (a ~ P c, P c ~ b) = (a ~ b) There is more discussion of this particular weakness at http://hackage.haskell.org/trac/ghc/ticket/6018 . Also, there are less-common usages of fundeps that may be translatable to type families but not easily, when there are complex interrelationships between type variables. For example, type-level binary operations will sometimes have fundeps such as a b - c, a c - b, b c - a - that is to say, any two determines the third. Like above: class (FD1 a b ~ c, FD2 b c ~ a, FD3 c a ~ b) = BinOp a b c where type FD1 a b type FD2 b c type FD3 c a You can mechanically translate MPTCs with FDs into MPTCs with ATs and superclass equalities in this way, and your fingers will get a lot of exercise. But that's the basis for the claim that TFs with superclass equalities are no less powerful than FDs. It's true that this doesn't always allow you to express everything as just plain top-level type families, but then, neither do FDs :). @wren, did you have some other examples in mind? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is Repa suitable for boxed arrays?...
On 03/06/2012, at 18:10 , Stuart Hungerford wrote: I need to construct a 2D array of a Haskell data type (boxed ?) where each array entry value depends on values earlier in the same array (i.e. for entries in previous row/column indexes). It should work. Use the V type-index for boxed arrays [1], so your array type will be something like (Array V DIM2 Float) If you can't figure it out then send me a small list program showing what you want to do. Repa (V3.1.4.2) looks very powerful and flexible but it's still not clear to me that it will work with arbitrary values as I haven't been able to get any of the Wiki tutorial array creation examples to work (this is with Haskell platform 2012.2 pre-release for OS/X). The wiki tutorial is old. It was written for the Repa 2 series, but Repa 3 is different. However I just (just) submitted a paper on Repa 3 to Haskell Symposium, which might help [2] [1] http://hackage.haskell.org/packages/archive/repa/3.1.4.2/doc/html/Data-Array-Repa-Repr-Vector.html [2] http://www.cse.unsw.edu.au/~benl/papers/guiding/guiding-Haskell2012-sub.pdf Ben. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] An attempt at an EDSL for platform independent 3D animation
Hi All, I've written a Haskell program that allows you to describe dance movements and it spits out javascript that does animation on an HTML 5 canvas (that's the platform independent bit). https://github.com/ckkashyap/Dancer Please do check it out and let me know what you think - all you'd need is Haskell platform. It's really preliminary at this point - The only animation that I've built using it is walk - this makes a matchstick man walk (you have to stretch your imagination a bit). Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Announce: Haskell Platform 2012.2.0.0
We're pleased to announce the next release of Haskell Platform: a single, standard Haskell distribution for everyone. Download Haskell Platform 2012.2.0.0: http://haskell.org/platform/ The specification, along with installers (including Windows, Macintosh, and Unix installers for a full Haskell environment) are available. Notable version changes with this release: ghc 7.4.1 cabal 1.14 cabal-install 0.14 mtl 2.1.1 transformers 0.3.0.0 alex 3.0.1 full package and version list: http://hackage.haskell.org/platform/changelog.html Thanks to: Joachim Breitner, George Colpitts, Duncan Coutts, Jason Dagit, Chris Dornan, Yitzchak Gale, Mikhail Glushenkov, Andres Löh, Gábor Páli, Jens Petersen, Don Stewart, David Terei, Johan Tibell, Mark Wright for their efforts and help in putting together this release. -- The Platform Infrastructure Team Mark Lentczner, release manager - The Haskell Platform is a single, standard Haskell distribution for every system, in the form of a blessed library and tool suite for Haskell distilled from the thousands of libraries on Hackage, along with installers for a wide variety of systems. It saves developers work picking and choosing the best Haskell libraries and tools to use for a task. When you install the Haskell Platform, you get the latest stable compiler, an expanded set of core libraries, additional development tools, and cabal-install – so you can download anything else you need from Hackage. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announce: Haskell Platform 2012.2.0.0
On Sun, Jun 3, 2012 at 6:24 PM, Mark Lentczner wrote: We're pleased to announce the next release of Haskell Platform: a single, standard Haskell distribution for everyone. Awesome! Congratulations! Download Haskell Platform 2012.2.0.0: http://haskell.org/platform/ It's a relatively minor thing, but I noticed that the above URL redirects to http://hackage.haskell.org/platform// which is incidentally considered a different URL from http://hackage.haskell.org/platform/ by Google's +1 service. Perhaps not surprisingly, http://haskell.org/platform redirects to the latter, single-/ Hackage URL. Regards, Sean ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re-exports of resourcet in conduit
Yep, that was my problem. Thanks so much! GHC is smart enough to realize that Data.Conduit.ResourceT is the same as Control.Monad.Trans.Resource.ResourceT. Yay! --Myles On Sun, Jun 3, 2012 at 2:00 AM, Michael Snoyman mich...@snoyman.com wrote: The easiest thing to do is just build your code with cabal, which will ensure you're using consistent versions. (Similar questions came up twice recently on Stack Overflow[1][2].) Wiping our your ~/.ghc and installing from scratch should work also, but it's like using a tactical nuke instead of a scalpel. As for checking versions of dependencies, try `ghc-pkg describe conduit`. Michael [1] http://stackoverflow.com/questions/10729291/lifting-trouble-with-resourcet/10730909#10730909 [2] http://stackoverflow.com/questions/10843547/snap-monad-liftio-and-ghc-7-4-1/10847401#10847401 On Sun, Jun 3, 2012 at 3:01 AM, Myles C. Maxfield myles.maxfi...@gmail.com wrote: It could be. Do you know how I can check which versions of packages other packages have built against with Cabal? Will it help if I remove all the relevant packages and then re-install only a single version? Thanks, Myles On Saturday, June 2, 2012, Antoine Latter wrote: Is it possible that you are puuling in two different versions of the package that defines the MonadThrow class? That is, package a was built against version 1, but package b was built against version 2? This would make GHC think the type-class were incompatable. This is just a guess - I have not tried what you are trying. On Jun 2, 2012 6:35 PM, Myles C. Maxfield myles.maxfi...@gmail.com wrote: To: Michael Snoyman CC: haskell-cafe Hello, I'm having a problem working with the conduit library, and was hoping you could help me out. Data.Conduit re-exports ResourceT, MonadResource, and MonadThrow (but not ExceptionT) from Control.Monad.Trans.Resource. I have a conduit which operates on a monad in the MonadThrow class. I am trying to figure out which MonadThrow class this should be (the Data.Conduit.MonadThrow class, or the Montrol.Monad.Trans.Resource.MonadThrow class, since apparently GHC doesn't recognize them as the same, even though one is just a re-export of the other). If a user of this conduit wants to chain this conduit up with something like sourceFile, the underlying monad has to be a member of Data.Conduit.MonadResource and whatever MonadThrow class I chose to use. I would like to be able to use an existing instance to lift the class of the inner monad to the class of the entire monad stack (so I don't have to tell the user of my conduit that they have to define their own instances), and the only rule that I can find that does that is the following from Data.Conduit: Data.Conduit.MonadThrow m = Data.Conduit.MonadThrow (Data.Conduit.ResourceT m) However, GHC doesn't seem to think that Control.Monad.Trans.Resource.ExceptionT is an instance of Data.Conduit.MonadThrow: No instance for (Data.Conduit.MonadThrow (ExceptionT IO)) arising from a use of `.' Control.Monad.Trans.Resource has a similar instance: Control.Monad.Trans.Resource.MonadThrow m = Control.Monad.Trans.Resource.MonadThrow (Control.Monad.Trans.Resource.ResourceT m) but because sourceFile operates in the Data.Conduit.MonadResource class, and Control.Monad.Trans.Resource.ResourceT isn't a member of that class (it's only a member of Control.Monad.Trans.Resource.MonadResource), that doesn't help: No instance for (Data.Conduit.MonadResource (Control.Monad.Trans.Resource.ResourceT (ExceptionT IO))) arising from a use of `.' It should be noted that neither module defines anything like the following: MonadResource m = MonadResource (ExceptionT m) It seems like the underlying problem here is that: 1) I am required to use the Control.Monad.Trans.Resource.ExceptionT class, because Data.Conduit doesn't re-export it 2) I am required to use the Data.Conduit.MonadResource class, because sourceFile and others require it 3) There doesn't seem to be an existing instance that bridges between the two. This seems like a fundamental flaw with re-exporting; it can only work if you re-export every single last thing from the original module. This doesn't seem tenable because the orignal module might not be under your control, so its author can add new symbols whenever he/she wants to. I see two solutions to this problem: 1) Re-export Control.Monad.Trans.Resource.ExceptionT in Data.Conduit. This will work until someone adds something to the resourcet package and someone wants to use the new addition and Data.Conduit.ResourceT in the same stack 2) Don't re-export anything in Data.Conduit; make sourceFile and others explicitly depend on types in another module, but this might break compatibility with existing programs if they use fully-qualified symbol names. 3) Make anyone who wants to use a monad stack in MonadThrow and MonadResource
[Haskell-cafe] Announce: haskellifi-trayicon-0.0.1
Hi everyone, I wrote a small app that suggests default passwords for visible wifi networks (currently only some Telefonica Jazztel Wifis in Spain, but could be extended). Not a big deal (less than 400 lines of code with the GUI), but some people asked me to release it, so here it is. Disclaimer THIS IS IMPORTANT. This program is not intended for hacker wannabes. This is meant ONLY for network administrators. Use *only* with permission of the wifi admin. Introduction = More often than not, network administrators have to deal with clients or other administrators how know very little about wifi security. It is not uncommon to find wifis with default passwords. This program suggests passwords for the wifis it detects, and presents the information in a visually attractive way (tray icon with popup menu) so that your customers/collaborators fully understand HOW EASY IT IS TO BREAK INTO THEIR NETWORKS. NOTE: at the present time, this only works with Telefonica Spain's WPA2 default passwords (and maybe Jazztel's). If the default password of your wifi can be automatically generated from open or publicly visible parameters, feel free to write the algorithm in Haskell, send it to me and I'll see if I can add it here. Instructions = Code, Installation, readme, and other instructions: https://github.com/ivanperez-keera/haskellifi-trayicon During execution, you should see an icon on your traybar or notification area. Left click will show a menu with the list of wifis it can suggest a password for. Clicking on one will copy the suggested password to the clipboard. Right click on the icon to clear the wifi list or quit the program. Feel free to send me bugs reports and suggestions. Hope it helps somebody. Cheers, Ivan. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announce: Haskell Platform 2012.2.0.0
Congratulations on the release! Thank you for all the hard work and great to see it come out in this timely manner. :-) It's a relatively minor thing, but I noticed that the above URL redirects to http://hackage.haskell.org/platform// which is incidentally considered a different URL from http://hackage.haskell.org/platform/ by Google's +1 service. Perhaps not surprisingly, http://haskell.org/platform redirects to the latter, single-/ Hackage URL. I can reproduce this with Chrome, but not Firefox. Equally surprising to me is that the number of slashes also seems to affect the CSS presentation of the website in Chrome. // seems to give the Summer theme, whereas / gives the Winter one! Kind of weird. Anyway I agree it would be better to avoid the superfluous slashes if possible. I am going build HP 2012.2 for Fedora 18 soon but the first proper build may be after ghc-7.4.2 is released. Jens ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announce: Haskell Platform 2012.2.0.0
On Mon, Jun 4, 2012 at 1:16 PM, Jens Petersen j...@community.haskell.org wrote: Congratulations on the release! Equally surprising to me is that the number of slashes also seems to affect the CSS presentation of the website in Chrome. // seems to give the Summer theme, whereas / gives the Winter one! Kind of weird. Anyway I agree it would be better to avoid the superfluous slashes if possible. Your browser might be caching the file. Try pressing Ctrl-F5 on the winter page. I am going build HP 2012.2 for Fedora 18 soon but the first proper build may be after ghc-7.4.2 is released. Jens ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announce: Haskell Platform 2012.2.0.0
On Mon, Jun 4, 2012 at 1:16 PM, Jens Petersen j...@community.haskell.org wrote: Congratulations on the release! Equally surprising to me is that the number of slashes also seems to affect the CSS presentation of the website in Chrome. // seems to give the Summer theme, whereas / gives the Winter one! Kind of weird. Anyway I agree it would be better to avoid the superfluous slashes if possible. Your browser might be caching the file. Try pressing Ctrl-F5 on the winter page to force a reload. I am going build HP 2012.2 for Fedora 18 soon but the first proper build may be after ghc-7.4.2 is released. Jens ___ 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