__GLASGOW_HASKELL__=708?
Using GHC 7.8.3 from the latest Haskell Platform on OS X 10.9.4, the __GLASGOW_HASKELL__ preprocessor symbol is being set to 708 instead of 783. I'd guess I have some stale files lying from previous versions GHC or HP, but I can't seem to find them. Any clues? $ cat wtf.hs {-# LANGUAGE CPP #-} $ ghc-7.8.3 -v -E wtf.hs 21 | grep 708 /usr/bin/gcc -E -undef -traditional -Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs -I /Library/Frameworks/GHC.framework/Versions/7.8.3-x86_64/usr/lib/ghc-7.8.3/base-4.7.0.1/include -I /Library/Frameworks/GHC.framework/Versions/7.8.3-x86_64/usr/lib/ghc-7.8.3/integer-gmp-0.5.1.0/include -I /Library/Frameworks/GHC.framework/Versions/7.8.3-x86_64/usr/lib/ghc-7.8.3/include '-D__GLASGOW_HASKELL__=708' '-Ddarwin_BUILD_OS=1' '-Dx86_64_BUILD_ARCH=1' '-Ddarwin_HOST_OS=1' '-Dx86_64_HOST_ARCH=1' -U__PIC__ -D__PIC__ '-D__SSE__=1' '-D__SSE2__=1' -x assembler-with-cpp wtf.hs -o /var/folders/w7/_cxvr2k540163p59kwvqlzrcgn/T/ghc14288_0/ghc14288_1.hscpp Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: __GLASGOW_HASKELL__=708?
Thanks John. I see that the bug is in how that symbol is being used in the music-score package. Sorry for the noise. -Greg On Thu, Sep 25, 2014 at 8:20 PM, John Lato jwl...@gmail.com wrote: The value 708 is correct. From the user's guide, http://www.haskell.org/ghc/docs/latest/html/users_guide/options-phases.html#c-pre-processor: _GLASGOW_HASKELL__ For version x.y.z of GHC, the value of __GLASGOW_HASKELL__ is the integer xyy (if y is a single digit, then a leading zero is added, so for example in version 6.2 of GHC, __GLASGOW_HASKELL__==602). More information in Section 1.4, “GHC version numbering policy”. On Fri, Sep 26, 2014 at 11:09 AM, Greg Fitzgerald gari...@gmail.com wrote: Using GHC 7.8.3 from the latest Haskell Platform on OS X 10.9.4, the __GLASGOW_HASKELL__ preprocessor symbol is being set to 708 instead of 783. I'd guess I have some stale files lying from previous versions GHC or HP, but I can't seem to find them. Any clues? $ cat wtf.hs {-# LANGUAGE CPP #-} $ ghc-7.8.3 -v -E wtf.hs 21 | grep 708 /usr/bin/gcc -E -undef -traditional -Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs -I /Library/Frameworks/GHC.framework/Versions/7.8.3-x86_64/usr/lib/ghc-7.8.3/base-4.7.0.1/include -I /Library/Frameworks/GHC.framework/Versions/7.8.3-x86_64/usr/lib/ghc-7.8.3/integer-gmp-0.5.1.0/include -I /Library/Frameworks/GHC.framework/Versions/7.8.3-x86_64/usr/lib/ghc-7.8.3/include '-D__GLASGOW_HASKELL__=708' '-Ddarwin_BUILD_OS=1' '-Dx86_64_BUILD_ARCH=1' '-Ddarwin_HOST_OS=1' '-Dx86_64_HOST_ARCH=1' -U__PIC__ -D__PIC__ '-D__SSE__=1' '-D__SSE2__=1' -x assembler-with-cpp wtf.hs -o /var/folders/w7/_cxvr2k540163p59kwvqlzrcgn/T/ghc14288_0/ghc14288_1.hscpp Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell-cafe] haskell.cs.yale.edu error
I was hoping to check on the status of Yampa, but: http://haskell.cs.yale.edu/ [an error occurred while processing this directive] You don't have permission to access the requested directory. There is either no index document or the directory is read-protected. [an error occurred while processing this directive] Do you know who maintains this website? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: tie-knot library
GHC's reliance on the LGPLed GMP library ... use integer-simple in your GHC I think this can still use some attention. GHC requires an integer library internally, so to switch to integer-simple, you need to build GHC from source. Has anyone reviewed of the performance implications of this switch? +the new GHC Performance Team, Johan and Bryan Thanks, Greg On Fri, Dec 14, 2012 at 4:21 AM, Niklas Larsson metanik...@gmail.comwrote: Yes, if you link statically, if you want to distribute without giving away source (or relinkable object files) you can link dynamically or use integer-simple in your GHC. Niklas -- Från: Herbert Valerio Riedel h...@gnu.org Skickat: 2012-12-14 11:55 Till: Brandon Allbery allber...@gmail.com Kopia: Ramana Kumar ramana.ku...@cl.cam.ac.uk; haskell-cafehaskell-cafe@haskell.org Ämne: Re: [Haskell-cafe] ANNOUNCE: tie-knot library Brandon Allbery allber...@gmail.com writes: Haskell libraries are mostly BSD licensed, as is GHC itself. (Oddly enough, GPL is not the only open source license.) btw, what about GHC's reliance on the LGPLed GMP library? Doesn't that already taint the whole GHC eco-system? Quoting [1]: | GMP is licensed under the GNU Lesser General Public License (LGPL), a | kind of copyleft license. According to the terms of the LGPL, | paragraph 5, you may distribute a program that is designed to be | compiled and dynamically linked with the library under the terms of | your choice (i.e., commercially) but if your program incorporates | portions of the library, if it is linked statically, then your program | is a derivative--a work based on the library--and according to | paragraph 2, section c, you must cause the whole of the work to be | licensed under the terms of the LGPL (including for free). | | The LGPL licensing for GMP is a problem for the overall licensing of | binary programs compiled with GHC because most distributions (and | builds) of GHC use static libraries. (Dynamic libraries are currently | distributed only for OS X.) The LGPL licensing situation may be worse: | even though The Glasgow Haskell Compiler License is essentially a | free software license (BSD3), according to paragraph 2 of the LGPL, | GHC must be distributed under the terms of the LGPL! [1]: http://hackage.haskell.org/trac/ghc/wiki/ReplacingGMPNotes#ReasonsforReplacingGMPastheBignumlibrary cheers, hvr ___ 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: Hoopl vs LLVM?
On Wed, Dec 12, 2012 at 4:35 AM, Simon Marlow marlo...@gmail.com wrote: Now, all that LLVM knows is that z was read from Sp[8], it has no more information about its value. Are you saying Hoopl can deduce the original form from the CPS-version? Or that LLVM can't encode the original form? Or within GHC, LLVM is thrown in late in the game, where neither Hoopl nor LLVM can be of much use. -Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Hoopl vs LLVM?
Thank you all for your replies. On Tue, Dec 11, 2012 at 11:16 AM, Simon Peyton-Jones simo...@microsoft.comwrote: And I think there is probably quite a lot that is in reach for C--, but out of reach for LLVM. Why? Because before we pass the code to LLVM we do CPS-conversion. Is there a case for making a C/C++ compiler target C-- instead of LLVM? Or does its optimizations cater more to functional programming or lazy evaluation? Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Hoopl vs LLVM?
I don't know my way around the GHC source tree. How can I get the list of optimizations implemented with Hoopl? Is there overlap with LLVM's optimization passes? If so, has anyone compared the implementations at all? Should one group be stealing ideas from the other? Or apples and oranges? Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell-cafe] fixed-length bit-vectors
Hi all, My goal, eliminate the failure case in 'byte': https://gist.github.com/4128503 I don't want my 'byte' function to fail at runtime or return $ Left vector not 8 bits. I want it to return a Word8 for an 8-bit bit-vector or not compile. Is there an existing library that offers fixed-length vectors as a thin veneer over the 'vector' package? I see 'vector-static', but it is unmaintained and hasn't been touched in years. Alternatively, there's 'VecN', but having already learned 'vector', I'd like to know if there is an existing solution that uses it. Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Cabal failures...
cabal install -v cabal-install Not sure if you're running into this one, but a configuration that wasn't working for me: 1) Install Haskell Platform 2) Install GHC 7.6.1 3) cabal install cabal-install As I recall, the error had something to do with a Cabal-generated 'Paths' file assuming the Prelude exported 'catch'. It was affecting a bunch of other packages too, which forced me to upgrade cabal-install. To get things working, I had to boot GHC 7.6 from my system PATH, upgrade cabal-install using GHC 7.4, and then put 7.6 back in the system path. After doing that, everything has worked well with GHC 7.6. -Greg On Mon, Nov 19, 2012 at 1:38 PM, Johan Tibell johan.tib...@gmail.com wrote: Hi Greg, On Mon, Nov 19, 2012 at 1:25 PM, Gregory Guthrie guth...@mum.edu wrote: I follow the Cabal-messes threads with some interest, since that is the hardest area for me since starting to use Haskell. Probably 40-60% of all package install fail for some mysterious reason, with threats that trying to fix them will break more things, which generally is true. :-) We're working on it. Be brave, things are going to get better! I am not exert in the area, but I wonder how /why/ this is different than other package managers, like apt in Linux, I have never had any problems with it, and I would think that their dependencies are of at least similar complexities. The Linux package managers solve a different problems. They let you install a set of packages that have been manually curated and are know to work together (i.e. all version dependencies are fixed) while cabal does version resolution on packages that might not ever have been tried together. If you install Haskell packages via your distro's package manager I assume they will always install cleanly. The problem is that people want the latest bleeding edge of packages, which haven't made it into the distros yet, and hence they get to experience some of the pains associated with being on the bleeding edge. Being on Windows also makes things harder, as most developers don't have a Windows box to test their stuff on. In any case; Trying to do a cabal update I was told to try to update cabal-install, which I think means actually updating cabal (since I actually run installs via cabal install...), but that fails with this message below, and I don't know how to proceed. cabal-install is the package that includes the cabal executable. Cabal (with a capital C) is the library that cabal-install uses. The naming is unfortunate but hard to change at this point. To update cabal-install you do: $ cabal update cabal install cabal-install Make sure that the place that the cabal binary gets installed into (which is printed at the end of the install) is on your PATH. Linking C:\Users\guthrie\AppData\Local\Temp\Cabal-1.16.0.3-13880\Cabal-1.16.0.3\dist\setup\setup.exe ... Configuring Cabal-1.16.0.3... Warning: This package indirectly depends on multiple versions of the same package. This is highly likely to cause a compile failure. This is a sure sign that things are not going to work well. Could you include the output of cabal install -v cabal-install please. The output here is not enough to tell me what's going on. Please also include the output of cabal --version ghc --version Are you using the Haskell Platform, if so, which version? -- Johan ___ 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] hackageDB haddock errors
Any reason haddock isn't run at the time the package is uploaded? Or could the docs be included in the tarball? Folks oftentimes want to announce their new packages right after uploading them, but usually there are no docs yet. A little awkward. Thanks, Greg On Tue, Nov 13, 2012 at 7:41 AM, timothyho...@seznam.cz wrote: Hello, There are several packages without haddock documentation on hackage. The one that bugs me right now, is the latest version of gtk2hs: http://hackage.haskell.org/package/gtk I've been told that this may be due to hackage updating docs with an infrequent cron job, so that new packages don't get their docs for a long time. Whatever is causing it, the fact that hayoo http://holumbus.fh-wedel.de/hayoo/hayoo.html always uses the most frequent docs, means that I cannot currently search for anything gtk2hs related :( Can someone please look into prodding this cron job so it doesn't take days to run, or look into resolving any errors that might be causing this unfortunate behaviour? Thank you for your time, and happy hacking, Timothy ___ 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] Safe lens?
Why are getters from the 'lens' package unsafe? Is there a subset like Data.Label.Pure from 'fclabels' that can be imported safely? $ cat a.hs {-# LANGUAGE Safe #-} import Control.Lens.Getter main = print 123 $ runghc a.hs a.hs:3:1: Control.Lens.Getter: Can't be safely imported! The module itself isn't safe. Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Safe lens?
There's no dependency on TH here. I'm hoping to do the same thing as I have done with fclabels, which is to have a Trustworthy module that imports Control.Lens.TH, derive lenses, and then allow all users of that data type to Safely import only the Getter/Setter modules. So, I'm curious: * Could Control.Lens.Getter have a LANGUAGE dependency it doesn't need? * Is there something fundamental in the design of lens (compared to fclabels), that its getters require unsafe language features? * Maybe the Internal module should be marked Trustworthy? Thanks, Greg On Mon, Oct 29, 2012 at 10:14 AM, Petr P petr@gmail.com wrote: Hi I believe the reason is that it uses TemplateHaskell for automatic derivation of labels. And TemplateHaskell is of course unsafe, since it could convert your code into something entirely different. Best regards, Petr Pudlak 2012/10/29 Greg Fitzgerald gari...@gmail.com: Why are getters from the 'lens' package unsafe? Is there a subset like Data.Label.Pure from 'fclabels' that can be imported safely? $ cat a.hs {-# LANGUAGE Safe #-} import Control.Lens.Getter main = print 123 $ runghc a.hs a.hs:3:1: Control.Lens.Getter: Can't be safely imported! The module itself isn't safe. Thanks, Greg ___ 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] Safe lens?
Works great. Thanks for the quick work! -Greg On Mon, Oct 29, 2012 at 2:46 PM, Edward Kmett ekm...@gmail.com wrote: I fixed it. Version 3.0.6 was just uploaded to hackage and is appropriately Trustworthy where needed. Please let me know if I missed flagged anything you need flagged, or mis-flagged anything you think shouldn't be. ;) On Mon, Oct 29, 2012 at 5:42 PM, Michael Sloan mgsl...@gmail.com wrote: It happened somewhere between 2.6 and 2.7: http://hackage.haskell.org/packages/archive/lens/2.6.1/doc/html/Control-Lens-Internal.html http://hackage.haskell.org/packages/archive/lens/2.7.0.1/doc/html/Control-Lens-Internal.html The strange thing is that the only internal dependency of 2.7.0.1, Control.Lens.Isomorphic, is still Safe-Infered (this spelling error should probably be fixed) http://hackage.haskell.org/packages/archive/lens/2.7.0.1/doc/html/Control-Lens-Isomorphic.html It'd be pretty fancy if Safe Haskell could give reasons for None / tell what would have made it unsafe in the event of Trustworthy. Particularly fancy if integrated into the haddocks. -mgsloan On Mon, Oct 29, 2012 at 2:33 PM, Edward Kmett ekm...@gmail.com wrote: Actually Control.Lens.Getter doesn't use TH. The issue is more that it depends on some modules I didn't flag as Trustworthy and which require some more high-falutin type system extensions that GHC isn't happy about treating as Safe. I'll try adding a few Trustworthy flags. It previously was treated as Trustworthy or SafeInfered throughout. Somewhere along the way I must have toggled on an extension and broken that property. -Edward On Mon, Oct 29, 2012 at 1:14 PM, Petr P petr@gmail.com wrote: Hi I believe the reason is that it uses TemplateHaskell for automatic derivation of labels. And TemplateHaskell is of course unsafe, since it could convert your code into something entirely different. Best regards, Petr Pudlak 2012/10/29 Greg Fitzgerald gari...@gmail.com: Why are getters from the 'lens' package unsafe? Is there a subset like Data.Label.Pure from 'fclabels' that can be imported safely? $ cat a.hs {-# LANGUAGE Safe #-} import Control.Lens.Getter main = print 123 $ runghc a.hs a.hs:3:1: Control.Lens.Getter: Can't be safely imported! The module itself isn't safe. Thanks, Greg ___ 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 ___ 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] foldr (.) id
Alternatively: flip (foldr id) Very cool, but... Prelude import qualified Data.Foldable as F Prelude F :t F.foldr id F.foldr id :: F.Foldable t = b - t (b - b) - b {- Generalizing -} Prelude F import qualified Control.Category as C Prelude F C :t F.foldr (C..) C.id F.foldr (C..) C.id :: (F.Foldable t, C.Category cat) = t (cat b b) - cat b b {- Sneaky type-specialization -} Prelude F C :t F.foldr C.id F.foldr C.id :: F.Foldable t = b - t (b - b) - b On Sat, Oct 27, 2012 at 3:09 AM, Ross Paterson r...@soi.city.ac.uk wrote: On Fri, Oct 26, 2012 at 07:41:18PM +0100, Greg Fitzgerald wrote: I've recently found myself using the expression: foldr (.) id to compose a list (or Foldable) of functions. It's especially useful when I need to map a function over the list before composing. Does this function, or the more general foldr fmap id, defined in a library anywhere? I googled and hoogled, but no luck so far. Alternatively: flip (foldr id) ___ 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] Overload function application? (was: foldr (.) id)
Should library functions target Control.Category? We write for Num, IsString, and ListLike. Haskell overloads number literals and string literals, and awkwardly not List literals. Should Haskell overload function application too? How cool would it be to be able to leverage all of Haskell's libraries, and effectively none of the runtime, by implementing instances for literals and function application? Say, for example, to generate a call graph, or make the language strict, or target LLVM more directly. Anyone tried this? Thanks, Greg On Sat, Oct 27, 2012 at 11:39 AM, Greg Fitzgerald gari...@gmail.com wrote: Alternatively: flip (foldr id) Very cool, but... Prelude import qualified Data.Foldable as F Prelude F :t F.foldr id F.foldr id :: F.Foldable t = b - t (b - b) - b {- Generalizing -} Prelude F import qualified Control.Category as C Prelude F C :t F.foldr (C..) C.id F.foldr (C..) C.id :: (F.Foldable t, C.Category cat) = t (cat b b) - cat b b {- Sneaky type-specialization -} Prelude F C :t F.foldr C.id F.foldr C.id :: F.Foldable t = b - t (b - b) - b On Sat, Oct 27, 2012 at 3:09 AM, Ross Paterson r...@soi.city.ac.ukwrote: On Fri, Oct 26, 2012 at 07:41:18PM +0100, Greg Fitzgerald wrote: I've recently found myself using the expression: foldr (.) id to compose a list (or Foldable) of functions. It's especially useful when I need to map a function over the list before composing. Does this function, or the more general foldr fmap id, defined in a library anywhere? I googled and hoogled, but no luck so far. Alternatively: flip (foldr id) ___ 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] foldr (.) id
Hi Haskellers, I've recently found myself using the expression: foldr (.) id to compose a list (or Foldable) of functions. It's especially useful when I need to map a function over the list before composing. Does this function, or the more general foldr fmap id, defined in a library anywhere? I googled and hoogled, but no luck so far. Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] foldr (.) id
Hmm, neato. but didn't make life any easier! Data.Monoid (appEndo . mconcat . map Endo) [(+10), (+20)] 3 33 Data.Monoid (foldr (.) id) [(+10), (+20)] 3 33 I had hoped for something like: mconcat [(+10), (+20)] 3 But I suppose that's nonsense, considering this works: mconcat [(++10), (++20)] 3 310320 I think this is the most general solution? import Control.Category import Data.Foldable import Prelude hiding (foldr, (.), id) compose :: (Foldable t, Category cat) = t (cat a a) - cat a a compose = foldr (.) id Usage: compose [(+10), (+20)] 3 Real-world use case: let parseOrIgnore p = either (const s) id . parse p s parseAllOrIgnore = compose . map parseOrIgnore [p1, p2, p3] Naming: (.)/compose is consistent with (+)/sum, (*)/product, ()/and, etc. Thoughts? -Greg On Fri, Oct 26, 2012 at 12:31 PM, John Wiegley jwieg...@gmail.com wrote: Greg Fitzgerald gari...@gmail.com writes: I've recently found myself using the expression: foldr (.) id to compose a list (or Foldable) of functions. You want the Endo monoid: ghci appEndo (Endo (+ 10) Endo (+ 20)) $ 3 33 John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] foldr (.) id
sorry for the buggy code let parseOrIgnore p s = either (const s) id $ parse p s let parseAllOrIgnore = compose . map parseOrIgnore [p1, p2, p3] parseAllOrIgnore abbbcccbbba On Fri, Oct 26, 2012 at 2:11 PM, Greg Fitzgerald gari...@gmail.com wrote: Hmm, neato. but didn't make life any easier! Data.Monoid (appEndo . mconcat . map Endo) [(+10), (+20)] 3 33 Data.Monoid (foldr (.) id) [(+10), (+20)] 3 33 I had hoped for something like: mconcat [(+10), (+20)] 3 But I suppose that's nonsense, considering this works: mconcat [(++10), (++20)] 3 310320 I think this is the most general solution? import Control.Category import Data.Foldable import Prelude hiding (foldr, (.), id) compose :: (Foldable t, Category cat) = t (cat a a) - cat a a compose = foldr (.) id Usage: compose [(+10), (+20)] 3 Real-world use case: let parseOrIgnore p = either (const s) id . parse p s parseAllOrIgnore = compose . map parseOrIgnore [p1, p2, p3] Naming: (.)/compose is consistent with (+)/sum, (*)/product, ()/and, etc. Thoughts? -Greg On Fri, Oct 26, 2012 at 12:31 PM, John Wiegley jwieg...@gmail.com wrote: Greg Fitzgerald gari...@gmail.com writes: I've recently found myself using the expression: foldr (.) id to compose a list (or Foldable) of functions. You want the Endo monoid: ghci appEndo (Endo (+ 10) Endo (+ 20)) $ 3 33 John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] a parallel mapM?
I'm new to concurrent programming in Haskell. I'm looking for a drop-in replacement for 'mapM' to parallelize a set of independent IO operations. I hoped 'mapConcurrently' might be it, but I need something that will only spawn as many threads as I have CPUs available [1]. I also tried Control.Parallel.Strategies [2]. While that route works, I had to use unsafePerformIO. Considering that IO is for sequencing effects and my IO operation doesn't cause any side-effects (besides hogging a file handle), is this a proper use of unsafePerformIO? Attempt 1 -- import System.Process(readProcess) import Control.Concurrent.Async(mapConcurrently) main :: IO [String] main = mapConcurrently (\n - readProcess echo [test: ++ show n] ) [0..1000] $ ghc --version The Glorious Glasgow Haskell Compilation System, version 7.6.1 $ runghc test.hs test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: echo: createProcess: resource exhausted (Too many open files) Attempt 2 -- import System.Process(readProcess) import Control.Parallel.Strategies(parMap, rpar) import System.IO.Unsafe(unsafePerformIO) main :: IO [String] main = myMapConcurrently (\n - readProcess echo [test: ++ show n] ) [0..1000] where myMapConcurrently f = return . parMap rpar (unsafePerformIO . f) $ runghc test.hs /dev/null echo Success Success Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] a parallel mapM?
Check out the parallel combinators in parallel-io: Cool, that's the library I'm looking for! I see it uses 'numCapabilities' to get the command-line value for '-N' and not 'getNumCapabilities' to query the system for how many cores are available. So using the 'Local' module, this works: parMapM f xs = do n - getNumCapabilities withPool n $ \pool - parallel pool (map f xs) Thanks, Greg On Fri, Sep 28, 2012 at 11:58 AM, Patrick Mylund Nielsen hask...@patrickmylund.com wrote: Check out the parallel combinators in parallel-io: http://hackage.haskell.org/packages/archive/parallel-io/0.3.2/doc/html/Control-Concurrent-ParallelIO-Global.html On Fri, Sep 28, 2012 at 1:01 PM, Greg Fitzgerald gari...@gmail.com wrote: I'm new to concurrent programming in Haskell. I'm looking for a drop-in replacement for 'mapM' to parallelize a set of independent IO operations. I hoped 'mapConcurrently' might be it, but I need something that will only spawn as many threads as I have CPUs available [1]. I also tried Control.Parallel.Strategies [2]. While that route works, I had to use unsafePerformIO. Considering that IO is for sequencing effects and my IO operation doesn't cause any side-effects (besides hogging a file handle), is this a proper use of unsafePerformIO? Attempt 1 -- import System.Process(readProcess) import Control.Concurrent.Async(mapConcurrently) main :: IO [String] main = mapConcurrently (\n - readProcess echo [test: ++ show n] ) [0..1000] $ ghc --version The Glorious Glasgow Haskell Compilation System, version 7.6.1 $ runghc test.hs test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: runInteractiveProcess: pipe: Too many open files test.hs: echo: createProcess: resource exhausted (Too many open files) Attempt 2 -- import System.Process(readProcess) import Control.Parallel.Strategies(parMap, rpar) import System.IO.Unsafe(unsafePerformIO) main :: IO [String] main = myMapConcurrently (\n - readProcess echo [test: ++ show n] ) [0..1000] where myMapConcurrently f = return . parMap rpar (unsafePerformIO . f) $ runghc test.hs /dev/null echo Success Success Thanks, Greg ___ 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] JavaScript (SpiderMonkey, V8, etc) embedded in GHC?
Hi Bob, All I really need is to allow users to write some JavaScript that accepts a single JSON 'file/string' from my Haskell program and produces another JSON 'file/string' that my Haskell program will accept. One option is to make your Haskell program an HTTP server, and then use Node.js to send and receive JSON files. http://www.happstack.com/docs/happstack-lite-7.2.0/doc/html/happstack-lite/index.html http://nodejs.org/ -Greg On Sat, Sep 8, 2012 at 12:08 PM, Bob Hutchison hutch-li...@recursive.cawrote: Hi, I've looked around with no success… this surprises me actually. Has anyone embedded SpiderMonkey, V8, or any other relatively decent JavaScript interpreters in GHC (using the FFI)? I did find http://justinethier.github.com/husk-scheme/ which is a scheme R5RS implementation (I could make this work). There's also some work done embedding Lua. I also found a number of packages that compile javascript to Haskell, or the other way around, but I don't need that kind of thing. All I really need is to allow users to write some JavaScript that accepts a single JSON 'file/string' from my Haskell program and produces another JSON 'file/string' that my Haskell program will accept. Thanks, Bob ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell-beginners] Why is the the transpose function in Data.List more complicated?
Hi KC, transp :: [[b]] - [[b]] transp ([]:_) = [] transp rows = map head rows : transp (map tail rows) Why is the the transpose function in Data.List more complicated? In the Data.List version, the list comprehension syntax quietly filters out items that fail to pattern-match (empty lists). Therefore the transpose in Data.List does not generate a pattern-match exception when you give it lists of different lengths: transpose [[1], [], [3]] == [[1,3]] The Data.List version also returns an empty list if the input is an empty list, whereas your version returns an infinite list of empty lists. -Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] (+1) vs let inc=(+1)
In ghci 7.4.1: Prelude :t (+1) (+1) :: Num a = a - a Prelude let inc=(+1) Prelude :t inc inc :: Integer - Integer Why the difference? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] (+1) vs let inc=(+1)
Thanks! $ ghci -XNoMonomorphismRestriction Prelude :t (+1) (+1) :: Num a = a - a Prelude let inc=(+1) Prelude :t inc inc :: Num a = a - a Cool. -Greg On Tue, May 22, 2012 at 12:34 PM, Artyom Kazak artyom.ka...@gmail.comwrote: http://www.haskell.org/**haskellwiki/Monomorphism_**restrictionhttp://www.haskell.org/haskellwiki/Monomorphism_restriction __**_ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://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] anyone else driven mad by trying to setup a gmp free version of haskell platform?
can we build a version of the compiler that loads [GMP] via dlopen on demand? An explanation from well-typed: http://www.well-typed.com/blog/32 But that was ~3 years ago. Anybody still looking at possible solutions? Maintaining the INTEGER_SIMPLE branch of GHC, minor as it is, is still a pain. If you follow the GHC recommendation of getting GHC from the Haskell Platform distribution, it means finding the matching GHC version, hoping you got all the build dependencies right, and then either overlaying the result in the HP installation or pointing HP to the new build. Not a ton of work, but not something I want to do each HP release. What are other commercial users of GHC doing? Thanks, Greg On Tue, May 8, 2012 at 8:07 AM, Anatoly Yakovenko aeyakove...@gmail.com wrote: i would really like to be able to ship haskell based linux binaries, but the gmp dependency makes it virtually impossible. so what version of host os, host ghc, and haskell-platform sources are known to build a working compiler? any reason why the dependency on gmp is static? are the interfaces between versions actually different? or can we build a version fo the compiler that loads the library via dlopen on demand? Thanks, Anatoly ___ 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] LLVM M.D. source code?
A paper, LLVM M.D.: A Denotational Translation Validator, mentions the source code for LLVM M.D is available here: http://llvm-md.seas.harvard.edu/ I can't seem to spot it there or on Hackage. Anyone seen it? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ping haskell.org timeout
cabal update hangs. ping haskell.org times out. But haskell.org and hackage webpages are loading just fine. What's going on? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
how to link a minimal executable?
Is there any documentation or examples available that shows what needs to be linked to get a haskell executable to print hello world? Instead of using GHC to link, I'm interested in using gcc, ar, or link directly. For starters, what implements the entry point? $ cat Main.hs main = print hello world $ ghc -c Main.hs $ Vs8/VC/bin/link.exe -NOLOGO Main.o LINK : fatal error LNK1561: entry point must be defined I see using ghc -v, it links all sorts of stuff: $ ghc -v Main.hs ... *** Linker: ... -lHSrtsmain -lHShaskell98-1.0.1.1 -lHSrandom-1.0.0.2 -lHStime-1.1.4 -lHSprocess-1.0.1.2 -lHSdirectory-1.0.1.0 -lHSold-time-1.0.0.3 -lHSold-locale-1.0.0.2 -lHSfilepath-1.1.0.3 -lHSWin32-2.2.0.1 -luser32 -lgdi32 -lwinmm -ladvapi32 -lshell32 -lshfolder -lHSbytestring-0.9.1.5 -lHSarray-0.3.0.0 -lHSbase-4.2.0.0 -lwsock32 -luser32 -lshell32 -lHSinteger-simple-0.1.0.0 -lHSghc-prim-0.2.0.0 -lHSrts -lm -lwsock32 -u _ghczmprim_GHCziTypes_Izh_static_info -u _ghczmprim_GHCziTypes_Czh_static_info -u _ghczmprim_GHCziTypes_Fzh_static_info -u _ghczmprim_GHCziTypes_Dzh_static_info -u _base_GHCziPtr_Ptr_static_info -u _base_GHCziWord_Wzh_static_info -u _base_GHCziInt_I8zh_static_info -u _base_GHCziInt_I16zh_static_info -u _base_GHCziInt_I32zh_static_info -u _base_GHCziInt_I64zh_static_info -u _base_GHCziWord_W8zh_static_info -u _base_GHCziWord_W16zh_static_info -u _base_GHCziWord_W32zh_static_info -u _base_GHCziWord_W64zh_static_info -u _base_GHCziStable_StablePtr_static_info -u _ghczmprim_GHCziTypes_Izh_con_info -u _ghczmprim_GHCziTypes_Czh_con_info -u _ghczmprim_GHCziTypes_Fzh_con_info -u _ghczmprim_GHCziTypes_Dzh_con_info -u _base_GHCziPtr_Ptr_con_info -u _base_GHCziPtr_FunPtr_con_info -u _base_GHCziStable_StablePtr_con_info -u _ghczmprim_GHCziBool_False_closure -u _ghczmprim_GHCziBool_True_closure -u _base_GHCziPack_unpackCString_closure -u _base_GHCziIOziException_stackOverflow_closure -u _base_GHCziIOziException_heapOverflow_closure -u _base_ControlziExceptionziBase_nonTermination_closure -u _base_GHCziIOziException_blockedIndefinitelyOnMVar_closure -u _base_GHCziIOziException_blockedIndefinitelyOnSTM_closure -u _base_ControlziExceptionziBase_nestedAtomically_closure -u _base_GHCziWeak_runFinalizzerBatch_closure -u _base_GHCziTopHandler_runIO_closure -u _base_GHCziTopHandler_runNonIO_closure -u _base_GHCziConc_ensureIOManagerIsRunning_closure -u _base_GHCziConc_runSparks_closure -u _base_GHCziConc_runHandlers_closure -lHSffiReading Any insight would be greatly appreciated. Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
$thisdir for package.conf?
Is there a way for a package.conf file to contain paths that are relative to the directory containing the .conf file? GHC 6.12.1 chokes on relative paths. I see the problem is solved for GHC's core libraries with the $topdir variable. Is there something like a $thisdir we could use in inplace .conf files? Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell-cafe] ANN: spec2code
After 5 years of RD, I’m proud to announce the spec2code compiler. With spec2code, developers no longer need to acknowledge the mundane details of programming, such as memory allocation, bounds-checking, byte ordering, inheritance models or performance tuning. spec2code uses the latest techniques in compiler optimization to derive a deterministic implementation from only a high-level specification. For example, an optimal quicksort is derived from the following specification. sort :: Ord a = [a] - (b | ordered b) sort = undefined ordered :: Ord a = [a] - Bool ordered [] = True ordered [_] = True ordered (x1:x2:xs) = x2 x1 ordered (x2:xs) Read as, “the function 'sort' takes a list of orderable list items, and returns a list for which each list item is greater to the one preceding it.” How does it work? By telling the compiler about the logical properties of how its output relates to its input, the compiler is sufficiently constrained to apply its genetic algorithm. It iterates over the specification with all known optimization techniques, algebraically reducing the program to an underlying machine model. The compiler uses static analysis and complexity theory in conjunction with the machine model to order implementations by their performance characteristics and choose the optimal one. Conceptually, the first phase orders algorithms by complexity, using average case, worst case and memory consumption: [MergeSort (n*log n) (n*log n) n, QuickSort (n*log n) (n*n) (log n), InsertionSort (n*n) (n*n) 1, BubbleSort (n*n) (n*n) 1 ] After choosing a high-level algorithm, spec2code does the usual low-level optimizations via LLVM to map the algorithm to optimal native code. Does it scale? Absolutely, spec2code is not confined to specifications for which optimized algorithms are already known. spec2code can be used to implement operation systems, device drivers, build systems, package management tools, and even do your shirt laundry. spec2code will change your job from programmer to specification author, giving you more time for meetings, managing email, and browsing the web. Say goodbye to those dirty Perl scripts, broken C code, and ultimately, your job. spec2code is the future of programming and the beginning of the end of mankind. Looking forward to obsoleting you soon, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: integer-simple by default
As another data point, Python has also re-invented the GMP wheel, likely for the same licensing reasons. They have been using a simple implementation of Karatsuba multiplication for years. I have never heard of anyone complaining about it Thanks for the data point. Looks like they swapped out their integer implementation for Python3: http://gmplib.org/list-archives/gmp-discuss/2008-November/003434.html Here's the code from January 30, 2010: http://svn.python.org/view/python/trunk/Objects/longobject.c?view=markup More data points: http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic -Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: integer-simple by default
You can dynamically link libgmp on windows. That might be easier: Do you know if the dynamic link escape hatch has ever held up in court? Last time I looked into it, the free software community had mixed opinions. In any case, giving GMP the boot alleviates any licensing concerns, makes the GHC build a little simpler, and allows users to create standalone executables. Is there any reason we shouldn't attempt to make integer-simple the default? -Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Confusion about GHC and GMP
I assume you mean http://hackage.haskell.org/trac/ghc/wiki/ReplacingGMPNotes#CurrentStatus in which case, yes. I assume that INTEGER_LIBRARY=integer-foo is an option when compiling GHC itself and not when using GHC, correct? Yes. Great, thanks for your help Ian. Building GHC with INTEGER_LIBRARY=integer-simple is exactly what I was looking for. So naturally though, I'd like to avoid maintaining an internal branch of GHC. Are there any plans to make integer-simple the default integer library? I was able to build GHC on Linux with no trouble. But on Windows, I go down because (I think) the preprocessor is choking on ^M characters. I get errors like this: libraries\haskeline\.\System\Console\Haskeline\Backend\Win32.hsc:153: error: syntax error before ')' token libraries\haskeline\.\System\Console\Haskeline\Backend\Win32.hsc: In function `main': libraries\haskeline\.\System\Console\Haskeline\Backend\Win32.hsc:155: error: syntax error before ';' token compiling libraries/haskeline/dist-install/build/System/Console/Haskeline/Backend/Win32_hsc_make.c After removing those ^M's from Win32.hsc and Win32_hsc_make.c, things are moving along, slowly but surely. The build is using the inplace gcc so I assume the problem is not gcc, but whatever generates those files. Any idea how the extra line feeds slip in? Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell] Parsec operator issue
Hi Adam, parse x=-1, it fails. Does anyone know how to fix this? This issue is in using the 'reservedOp' combinator which rejects '=' when followed by '-'. reservedOp name = lexeme $ try $ do{ string name ; notFollowedBy (opLetter languageDef) ? (end of ++ show name) } If you change: reservedOp = to: char '=' then your test passes. -Greg On Tue, Feb 16, 2010 at 2:10 PM, Adam Crume adamcr...@hotmail.com wrote: I have a parser with a prefix - and an infix =. When I try to parse x=-1, it fails. Does anyone know how to fix this? I stripped my code down as much as possible. It parses x=1 and -1, but fails for x=-1. import Text.Parsec import qualified Text.Parsec.Expr as PE import qualified Text.Parsec.Language as L import qualified Text.Parsec.Token as T lexer = T.makeTokenParser L.emptyDef {T.reservedOpNames = [=, -]} reservedOp = T.reservedOp lexer integer = T.integer lexer return symbol = T.identifier lexer expression = PE.buildExpressionParser table (integer | symbol) where table = [ [ PE.Prefix (reservedOp - return (\x- )) ], [ PE.Infix (reservedOp = return (\x- \y-)) PE.AssocRight ] ] input = do e - expression eof return e testParse s = case (parse input (unknown) s) of Left f - putStrLn $ s ++ \n ++ show f Right f - putStrLn s main = do testParse x=1 testParse -1 testParse x=-1 Hotmail: Free, trusted and rich email service. Get it now. ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Confusion about GHC and GMP
I wonder if someone might be able to clear a few things up for me about implementing Integer with GMP. First, is the link below the most up-to-date information regarding GHC's situation? http://hackage.haskell.org/trac/ghc/wiki/ReplacingGMPNotes#BinaryDropinReplacementforGMP I assume that INTEGER_LIBRARY=integer-foo is an option when compiling GHC itself and not when using GHC, correct? If so, what version of GHC was this added? 6.10, 6.12, HEAD? Lastly, I'm confused about GHC's posted license, should it actually be LGPL so long as it statically links GMP? Aren't there a number of companies releasing binaries that were compiled with GHC? Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] Token parsers in parsec consume trailing whitespace
Hi Edward, 1. Is there a more elegant way of doing number parsing? In particular, are there token parsers that don't consume trailing whitespace, or is there a better way to do this with the primitives. Parsec defines a combinator it calls 'lexeme' which the tokenizer wraps each of its functions in. The purpose of the tokenizer is to create a set of parsing combinators that ignore whitespace, comments, and some other handy stuff like checking for collisions with reserved keywords. To consume the trailing whitespace is not a bug, it's an abstraction layer, and Parsec is consistent about only using this abstraction in the Token module. It's too bad that the 'nat' function in Token is not defined in Parsec's Char module, and because of that, you need to copy-paste that code or roll your own. It seems that the token approach of parsing lends itself to a different style of parsing than the one I'm doing That's correct. Sounds to me like you shouldn't bother creating a tokenizer. You might even be able to get away with using the regex library instead of Parsec. -Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Implicit newtype unwrapping
On Thu, Dec 3, 2009 at 5:34 AM, Conor McBride wrote: http://www.haskell.org/pipermail/libraries/2008-January/008917.html On Tue, Jan 15, 2008 at 3:31 PM, Conor McBride wrote: Haskell's classes are the best damn rhythm section in the industry: you hum it, they play it. On Fri, Dec 10, 2004 at 2:21 AM, Conor McBride wrote: If you're willing to make the types distinguish the idioms you're using, as in choice-lists and vector-lists, then a lot of routine operations wither to a huddle of combinators sitting under a type signature which actually does most of the work. Instance inference is like having a great rhythm section: you hum it, they play it. Very eloquent Conor. Can we get this guy quoted in HWN? I think he's earned it. :-) On Thu, Dec 3, 2009 at 5:34 AM, Conor McBride wrote: class Newtype n where type Unpack n pack :: Unpack n - n unpack :: n - Unpack n Nice. Would the code below be a good way to deal with subtyping? It'd be convenient to have some way to go from a 64-bit Double to a 32-bit Float and be informed when a Double can't be represented precisely by a Float, but to have the option to move forward with the minor loss of precision. class Subset n where type Superset n demote :: Superset n - Either n n promote :: n - Superset n squeeze :: Subset n = Superset n - n squeeze = either id id . demote In action: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=13554#a13554 Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Implicit newtype unwrapping
Gregory Crosswhite gcr...@phys.washington.edu wrote: Out of curiosity, why would one want a newtype that were unwrapped implicitly, rather than just using type? One reason might be because you only switched from 'type' to 'newtype' so that you could write more refined Arbitrary instances for your QuickCheck tests. -Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Implicit newtype unwrapping
That suggests that the feature we'd really like is a way to declare that we want a type in a context to act as if it had a different instance declaration for a given typeclass, without having to go through newtype. I'd want implicit type coercion from subtypes, so that you wouldn't need an infinite hierarchy of nested typeclasses to implement the following for all integers: data One = One -- Somehow tell GHC that One is a subset of Integer (without implementing Num) oneToInteger :: One - Integer oneToInteger One = 1 One + One == (2 :: Integer) Seems like something Agda could handle. -Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Update on GHC 6.12.1
Another minor question is whether -XDoRec is a good name for the flag. We can't really use -XRecursiveDo because that's the one we are deprecating! -XReDo :) -Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] cabal haddock hpc, exposed modules?
Duncan wrote: By default hpc markup will generate pages for every module in the program. Am I missing something? Nope, user error. I started using --include to avoid running coverage over my test framework files, and was looking for something like haddock's internal flag before thinking to just delete all the --include lines. Nothing means something didn't occur to me. Thanks! Duncan wrote: $ cabal haddock --help [...] --executables Run haddock for Executables targets --internal Run haddock for internal modules and include all symbols [...] Great! Looks like these docs are new to 2.4.x. $ haddock --version Haddock version 2.3.0, (c) Simon Marlow 2006 Ported to use the GHC API by David Waern 2006-2008 $ haddock --help | grep internal $ Thanks for your help Duncan. -Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] cabal haddock hpc, exposed modules?
I have a cabal package that defines a few dozen modules, and I'm hoping to generate documentation and code coverage for all modules without listing each module explicitly. currently my .cabal includes: library exposed-modules: Language.Idl.Data, Language.Idl.Merge, Language.Idl.Parser, ...lots more... my Setup.hs includes an explicit system call to hpc: exec hpc [markup , --include=Language.Idl.Data , --include=Language.Idl.Merge , --include=Language.Idl.Parser ...all the same files as above... ] Questions: 1) Is there a way to create haddock docs for /all/ modules, instead of just the ones listed by 'exposed-modules'? 2) Is there a way to query cabal for the list of modules? Or by chance has hpc recently been integrated with cabal? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: cabal haddock hpc, exposed modules?
The workaround is for a script to traverse the filesystem and generate a list of modules that can then be copied into the .cabal for haddock and Setup.hs for hpc. If anyone else is trying to do the same, here's the code: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=11224#a11224 script copied below: import System.Directory(doesDirectoryExist, getDirectoryContents) import Data.Tree(unfoldTreeM, flatten) import Control.Monad(filterM) import System.FilePath(splitDirectories, dropExtension, takeExtension) import Data.List(sort, intercalate) main :: IO () main = do paths - modules putStrLn (cabal paths) putStrLn (hpc paths) cabal :: [String] - String cabal xs = header ++ intercalate sep xs where header = exposed-modules: sep = ,\n hpc :: [String] - String hpc = concatMap include where include x = pre ++ x ++ \ pre = \n , \--include= modules :: IO [String] modules = do paths - filePaths . return [modName p | p - paths, takeExtension p == .hs] where modName = intercalate . . splitDirectories . dropExtension filePaths :: FilePath - IO [FilePath] filePaths path = do tree - unfoldTreeM childPaths path filterM (fmap not . doesDirectoryExist) (flatten tree) childPaths :: FilePath - IO (FilePath, [String]) childPaths dir = do b - doesDirectoryExist dir fs - if b then getDirectoryContents dir else return [] return (dir, [dir ++ / ++ p | p - fs, head p /= '.']) -Greg On Tue, Oct 27, 2009 at 2:33 PM, Greg Fitzgerald gari...@gmail.com wrote: I have a cabal package that defines a few dozen modules, and I'm hoping to generate documentation and code coverage for all modules without listing each module explicitly. currently my .cabal includes: library exposed-modules: Language.Idl.Data, Language.Idl.Merge, Language.Idl.Parser, ...lots more... my Setup.hs includes an explicit system call to hpc: exec hpc [markup , --include=Language.Idl.Data , --include=Language.Idl.Merge , --include=Language.Idl.Parser ...all the same files as above... ] Questions: 1) Is there a way to create haddock docs for /all/ modules, instead of just the ones listed by 'exposed-modules'? 2) Is there a way to query cabal for the list of modules? Or by chance has hpc recently been integrated with cabal? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: a boring parser
Cool, I like how this parser can model the Look, an Eagle scenario. For reference: http://www.youtube.com/watch?v=pjh3e198pUQ The parser can change focus (that is, change traversal strategy) in response to a successful parse. In the Look, an Eagle scenario, the bear is able to interpret and respond to its input serially and interactively, but when the bear's input stream is replaced by a new one, the man is able to capture the prize. -Greg On Thu, Oct 1, 2009 at 1:02 PM, Anatoly Yakovenko aeyakove...@gmail.comwrote: so whats pretty cool is that I can traverse arbitrary data structures as well: data Tree a = Tree (Tree a) a (Tree a) | Bottom deriving Show left a = do make $ \ st - do case(st) of (Bottom) - eos (Tree left val right) - case (a val) of True - return $ (val, left) False - noMatch right a = do make $ \ st - do case(st) of (Bottom) - eos (Tree left val right) - case (a val) of True - return $ (val, right) False - noMatch eqT a = do make $ \ st - do case(st) of (Bottom) - eos (Tree _ val _) - case (a == val) of True - return $ (val, st) False - noMatch search a = manyTill (left a | right a) (eqT a) run (search 5) $ Tree (Tree Bottom 1 Bottom) 3 (Tree Bottom 5 Bottom) Right (([3],5),Tree Bottom 5 Bottom) On Wed, Sep 30, 2009 at 8:04 PM, Anatoly Yakovenko aeyakove...@gmail.com wrote: i got annoyed with Parsec and wrote a much more boring parser which allows me to parse anything with any kind of matching i want. Its basically a combination of State and Error monads. So i can use a grep like parser that matches via a regular expression over a list of lines grep re = do vv::B.ByteString - any let (_,_,_,rv) = (vv =~ re)::(B.ByteString,B.ByteString,B.ByteString,[B.ByteString]) case (rv) of [] - throwError no match _ - return $ rv run (grep $ C.pack (hello)) $ [C.pack hello world] Right ([hello],[]) or use the same library to scan over a string by combining regular expressions regex re = do make $ \ st - do case (B.null st) of True - throwError eos _ - do let (_,_,after,rv) = (st =~ re)::(B.ByteString,B.ByteString,B.ByteString,[B.ByteString]) case (rv) of [] - throwError no match _ - return $ (rv,after) run (do aa - regex $ C.pack (hello); bb - regex $ C.pack (world); return (aa,bb) ) $ C.pack hello world Right (([hello],[world]),) or simply match integers in a list, or anything that is of type Eq run (many1 $ eq 1) [1,1,1,2,3,4] Right ([1,1,1],[2,3,4]) i can define lt lt cc = do vv - any case (vv cc) of True - return $ vv _ - throwError no match and do run (many1 $ lt 5 | eq 5) [1..10] Right ([1,2,3,4,5],[6,7,8,9,10]) here is the implementation module Parser( ParserM --type alias for the parser ParserM a b is over stream a and returns b , make--makes a parser from a matching function of type :: stream - m (match_data,stream) --for example any is implemented via: --any :: ParserM [a] a --any = make $ \ ll - -- case (ll) of -- (hh:tt) - return $ (hh,tt) -- _ - throwError eos --matches and returns an element from a list, which makes any of type :: ParserM [a] a , any --matches any element from [a] type stream , eq --matches an equal element from [Eq] stream, trivialy implemented in terms of any --eq :: Eq a = a - ParserM [a] a --eq cc = do -- vv - any -- case (vv == cc) of -- True - return $ vv -- _ - throwError no match , (|) --or operator, tries the left one then the right one , manyTill--collects the results of parser 1 until parser 2 succeeds , many1 --collects the results of the parser, must succeed at least once , many--collects the results of a parser , run --runs the parser ) where import Control.Monad.State.Lazy import Control.Monad.Error import Test.QuickCheck import Control.Monad.Identity import Prelude hiding (any) type ParserM a c = StateT a (ErrorT [Char] Identity) c make pp = do st - get (rv,nst) - pp $ st put $ nst return $ rv aa | bb = aa `catchError` \ _ - bb manyTill :: ParserM a c -
Re: [Haskell-cafe] the problem of design by negation
On Wed, May 20, 2009 at 3:54 PM, Michael Mossey m...@alumni.caltech.edu wrote: I want to aspire to positive design. I want to list the goals, and think of design as making clever choices that meet all the goals. Design by Thomas the Tank Engine? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Parsec and (then?) type-check
Parser gurus, When you write a parser with a library like Parsec, do you typically type-check while parsing, or afterward in a separate pass? The latter is more modular, but it means labeling every element in the AST with the parser position so that you can give good error messages. Do you find the added modularity worth the hassle or just pack type-checking into the parser pass? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: [Haskell] GHC 6.10 and OpenGL
$ cabal install OpenGL HOpenGL installs easily with cabal-install, but most HOpenGL examples and tutorials also use GLUT, which is not so painless on Windows. Luckily Conal Elliot just recently posted detailed instructions of how to do it: http://netsuperbrain.com/blog/posts/freeglut-windows-hopengl-hglut/ -Greg On Sat, Nov 22, 2008 at 12:34 PM, Don Stewart [EMAIL PROTECTED] wrote: ninegua: Hi everyone, It's sad to see the OpenGL binding being dropped from GHC binary installers starting from 6.10. Though this issue has been brought up and discussed before, I'm sure a lot of people who based their work on OpenGL would share the same sympathy. $ cabal install OpenGL I'm not here to argue whether this decision by GHC dev team is right or wrong, but what's really causing the pain is that the OpenGL binding doesn't have its own binary installer for Windows, and compilation from source on this platform is non-trivial. I wouldn't recommend doing it for ordinary users. So my question is, are we going to see a binary installer for OpenGL binding provided separately from either HOpenGL site, or Hackage? Or even the GHC installation page? This would be a job for the Windows distribution team to sort out. Each other distro addresses the native packaging problem by developing packages, and what is needed for a similar team for Windows, to provide Windows packages. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: OOPer?
Jonathan Cast wrote: [Functional and object-oriented programming] have points of similarity, but on net the best plan is to simply never reason analogically from one to the other. Coming from the OO world, I found it very useful to see how the same solution is modeled using different paradigms. I don't recall where I found the following example, but copied it locally as compelling evidence that the functional solution can be much clearer and shorter than the same solution modeled with objects and inheritance. -- Arithmetic expression forms data Expr = Num Int | Add Expr Expr -- Evaluate expressions eval :: Expr - Int eval (Num i) = i eval (Add l r ) = eval l + eval r -- Modify literals modulo v modn :: Expr - Int - Expr modn (Num i) v = Num (i 'mod' v) modn (Add l r) v = Add (modn l v) (modn r v) public abstract class Expr { public abstract int eval (); public abstract void modn(int v); } public class Num extends Expr { private int value; public Num(int value) { this.value = value; } public int eval () { return value; } public void modn(int v) { this.value = this.value % v; } public class Add extends Expr { private Expr left, right; public Add(Expr left, Expr right ) { this.left = left; this.right = right; } public int eval () { return left.eval () + right.eval (); } public void modn(int v) { left.modn(v); right.modn(v); } } -Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: OOPer?
I wrote: I don't recall where I found the following example My apologies to Ralf Lammel and Ondrej Rypacek. Five seconds on Google tells me I had copied that code verbatim from their paper, The expression lemma. http://www.uni-koblenz.de/~laemmel/expression/long.pdf Great paper, by the way! -Greg On Mon, Nov 17, 2008 at 11:00 AM, Greg Fitzgerald [EMAIL PROTECTED] wrote: Jonathan Cast wrote: [Functional and object-oriented programming] have points of similarity, but on net the best plan is to simply never reason analogically from one to the other. Coming from the OO world, I found it very useful to see how the same solution is modeled using different paradigms. I don't recall where I found the following example, but copied it locally as compelling evidence that the functional solution can be much clearer and shorter than the same solution modeled with objects and inheritance. -- Arithmetic expression forms data Expr = Num Int | Add Expr Expr -- Evaluate expressions eval :: Expr - Int eval (Num i) = i eval (Add l r ) = eval l + eval r -- Modify literals modulo v modn :: Expr - Int - Expr modn (Num i) v = Num (i 'mod' v) modn (Add l r) v = Add (modn l v) (modn r v) public abstract class Expr { public abstract int eval (); public abstract void modn(int v); } public class Num extends Expr { private int value; public Num(int value) { this.value = value; } public int eval () { return value; } public void modn(int v) { this.value = this.value % v; } public class Add extends Expr { private Expr left, right; public Add(Expr left, Expr right ) { this.left = left; this.right = right; } public int eval () { return left.eval () + right.eval (); } public void modn(int v) { left.modn(v); right.modn(v); } } -Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Linker errors to OpenGL with GHC 6.10.1
Do you know how I can fix these linker errors? C:\projects\funcat HelloWorld.hs import Graphics.Rendering.OpenGL import Graphics.UI.GLUT main = do (progname, _) - getArgsAndInitialize createWindow Hello World displayCallback $= clear [ColorBuffer] mainLoop C:\projects\funls lib GlU32.Lib glut32.lib OpenGL32.Lib glut.def glut32.dll C:\projects\funghc -Llib -lglut32 -lglu32 -lopengl32 HelloWorld.hs --make Linking HelloWorld.exe ... C:\Program Files\Haskell\GLUT-2.1.1.2\ghc-6.10.1/libHSGLUT-2.1.1.2.a(Begin.o):fake:(.text+0x1cb): undefined reference to `glutGet' C:\Program Files\Haskell\GLUT-2.1.1.2\ghc-6.10.1/libHSGLUT-2.1.1.2.a(Begin.o):fake:(.text+0x8af): undefined reference to `glutMainLoop' C:\Program Files\Haskell\GLUT-2.1.1.2\ghc-6.10.1/libHSGLUT-2.1.1.2.a(Window.o):fake:(.text+0x3cd): undefined reference to `glutEntryFunc' C:\Program Files\Haskell\GLUT-2.1.1.2\ghc-6.10.1/libHSGLUT-2.1.1.2.a(Window.o):fake:(.text+0x40d): undefined reference to `glutVisibilityFunc' C:\Program Files\Haskell\GLUT-2.1.1.2\ghc-6.10.1/libHSGLUT-2.1.1.2.a(Window.o):fake:(.text+0x3595): undefined reference to `glutPassiveMotionFunc' ...hundreds more... Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Parsec in 6.10 RC 1
The instance for Functor (Either ParserError) disappeared. Is that intentional? Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] lines of code metrics
On Aug 19, 2008, at 9:12 AM, Greg Fitzgerald wrote: Does anyone know of a good case study comparing a project written in C versus one written in Haskell? I'm mostly looking for a comparison of lines of code, but any other metric, such as time to market and code quality metrics could also be ... loads of great references ... Thank you all for your help! These references are a great help for pushing Haskell at work. -Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] lines of code metrics
Greg wrote: Thank you all for your help! These references are a great help for pushing Haskell at work. Don wrote: I've also set up the Who's using Haskell section on haskell.org's front page -- let me know what you think Great, thanks! I added Qualcomm. -Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] lines of code metrics
Does anyone know of a good case study comparing a project written in C versus one written in Haskell? I'm mostly looking for a comparison of lines of code, but any other metric, such as time to market and code quality metrics could also be ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: ANN: prof2dot, version 0.4.1
Sounds fantastic I'm using 'prof2dot' on a ~3000 LOC project and it's working well. Visual quality metrics like this and Haskell Program Coverage makes using Haskell in the corporate world a little easier to pull off. Zero crash reports helps too. ;-) -Greg F On Tue, Aug 5, 2008 at 1:02 PM, Neil Mitchell [EMAIL PROTECTED] wrote: Hi Gregory, Sounds fantastic. I'd love to see a single example of the resultant .dot file, so I can figure out just how useful this might be to me. Thanks Neil On Tue, Aug 5, 2008 at 8:50 PM, Gregory Wright [EMAIL PROTECTED] wrote: I am pleased to announce the release of prof2dot version 0.4.1, a graphical profiling tool for use with GHC. The program is a filter that takes the profiling output generated by running a GHC-compiled program with the +RTS -px -RTS option and turns it into a dot file. (The dot format is a textual representation of a directed or undirected graph.) The dot file can rendered in any format supported by Graphviz's dot program, and the file itself can be post-processed or edited to adjust the layout. The new release fixes a number of bugs and has some significant improvements in its internal organization over the previous 0.3.1 (Premature Optimizations 'r' Us) release. Version 0.4.1 (Triumph of Hope Over Experience) defaults to generating a call graph colored by number of entries into each call center. There is now an option to annotate the graph edges with the triple of (cost center entries, ticks, allocations). Module names are also given in each cost center. The latest version has been tested on the profiling output of some moderately large programs, e.g., the profile produced by a darcs get of the entire ghc repository: $ darcs get http://darcs.haskell.org/ghc +RTS -px -RTS There is also better error reporting of parser errors and consistency checking of the internal graph data structure. If anyone comes across a parse failure or an assertion failure, please report it to the author. The dot program from the graphviz tools is required to render the output of prof2dot. Very large graphs, or graphs with extensive annotations, can exceed the capabilities of dot. Prof2dot is available from Hackage in the development category. -Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell-cafe] GHC ARM Hackathon (Re: Haskell on ARM )
It may not be long before most of the computing world has gone mobile. CNET suggests the major players will be Qualcomm and Intel, where QC is more power-efficient, but Intel conveniently targets x86. June 29, 2008 7:30 PM PDT Qualcomm vs Intel: You decide%20http://news.cnet.com/8301-13924_3-9979989-64.html I'm a software engineer at Qualcomm with a desire to code more Haskell at work. This desire will only get stronger in coming years as multithreaded apps on mobile devices get more popular, and ways to write them reliably in traditional languages continue not to exist. Jeremy Shaw said: Perhaps we should have some sort of GHC on the ARM hackathon when 6.10 comes out Would anybody be interested in a GHC on ARM Hackathon in San Diego this year? When is 6.10 estimated to come out? Do we really need to wait for it? Jeremy Apthorp said: it'll also require that I significantly strip down the runtime system, as the current RTS won't fit in 4M Do you have a plan for how to do this? Maybe we can invite a Simon to teach us the innards of the RTS and help guide us? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: GHC ARM Hackathon (Re: Haskell on ARM )
...try that hyperlink again... Qualcomm vs Intel: You decide http://news.cnet.com/8301-13924_3-9979989-64.html On Wed, Jul 2, 2008 at 11:16 AM, Greg Fitzgerald [EMAIL PROTECTED] wrote: It may not be long before most of the computing world has gone mobile. CNET suggests the major players will be Qualcomm and Intel, where QC is more power-efficient, but Intel conveniently targets x86. June 29, 2008 7:30 PM PDT Qualcomm vs Intel: You decide I'm a software engineer at Qualcomm with a desire to code more Haskell at work. This desire will only get stronger in coming years as multithreaded apps on mobile devices get more popular, and ways to write them reliably in traditional languages continue not to exist. Jeremy Shaw said: Perhaps we should have some sort of GHC on the ARM hackathon when 6.10 comes out Would anybody be interested in a GHC on ARM Hackathon in San Diego this year? When is 6.10 estimated to come out? Do we really need to wait for it? Jeremy Apthorp said: it'll also require that I significantly strip down the runtime system, as the current RTS won't fit in 4M Do you have a plan for how to do this? Maybe we can invite a Simon to teach us the innards of the RTS and help guide us? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] derive Pretty?
Is it possible to automatically derive instances of Prettyhttp://haskell.org/ghc/docs/latest/html/libraries/haskell-src/Language-Haskell-Pretty.html? If no, what do most do when it comes to pretty-printing large data types? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] shootout using 6.6?
http://shootout.alioth.debian.org/gp4/haskell.php Anyone know if the Language Shootout is actually using GHC 6.6 or is that a typo? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] cabal and hpc?
Has the Haskell Program Coverage tool been integrated into Cabal? That is, is there anything like runhaskell Setup.hs coverage to generate a coverage report? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: GHC 6.8.2, Haddock not finding std libs
Haddock is no longer able to resolve the names from the standard libraries. There should be a new haddock release shortly, which fixes that as well as an HTML link bug. Or you can get the latest source with darcs The darcs version fixes the issue. Thanks Ian! -Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: HUnit 1.2.0.0 on 6.8.1 vs 1.1.1 on 6.6.1
abc @=? efg Loading package HUnit-1.2.0.0 ... linking ... done. *** Exception: (unknown) On Dec 3, 2007 7:23 AM, Ian Lynagh [EMAIL PROTECTED] wrote: This is caused by a change in the HUnit library, from assertFailure msg = ioError (userError (hunitPrefix ++ msg)) to assertFailure msg = E.throwDyn (HUnitFailure msg) I've had no luck contacting Dean Herington using the email address posted on the HUnit page. They just use the latest version in the darcs repositories at the time that they are built Sounds like this is the first case where the latest version isn't a stable one (Go Haskell!). Is it much trouble for package maintainers to package GHC with HUnit.1.1.1? To keep it simple, maybe there should be an HUnitStable branch where 1.1.1 is the latest version? Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: HUnit 1.2.0.0 on 6.8.1 vs 1.1.1 on 6.6.1
abc @=? efg Loading package HUnit-1.2.0.0 ... linking ... done. *** Exception: (unknown) On Dec 3, 2007 7:23 AM, Ian Lynagh [EMAIL PROTECTED] wrote: This is caused by a change in the HUnit library, from assertFailure msg = ioError (userError (hunitPrefix ++ msg)) to assertFailure msg = E.throwDyn (HUnitFailure msg) We don't really have a good answer for where non-bootlib library bugs should go at the moment. I don't know if Dean uses the sourceforge bug tracker or not. Could this change be reverted for 6.8.2? HUnit is mostly useless in its current state. Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
GHC 6.8.2, Haddock not finding std libs
Please test as much as possible One difference between 6.8.1 and 6.8.2 that I see is in running runhaskell Setup.hs haddock with Haddock 0.8 on Windows XP. Haddock is no longer able to resolve the names from the standard libraries. Running Haddock for Xyz-0.1... Warning: Xyz: the following names could not be resolved: FilePath Show Eq String Maybe Bool Char Int Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
HUnit 1.2.0.0 on 6.8.1 vs 1.1.1 on 6.6.1
On Windows, HUnit's assertions are not working - trace below in ghci 6.8.1and 6.6.1. Can others reproduce? Is this the right place to report bugs? Should I confirm a bug here and then create a ticket, create a ticket and that's it, or just mention it here and someone else creates a ticket? GHCi, version 6.8.1: http://www.haskell.org/ghc/ :? for help Loading package base ... linking ... done. :m Test.HUnit abc @=? efg Loading package HUnit-1.2.0.0 ... linking ... done. *** Exception: (unknown) ___ ___ _ / _ \ /\ /\/ __(_) / /_\// /_/ / / | | GHC Interactive, version 6.6.1, for Haskell 98. / /_\\/ __ / /___| | http://www.haskell.org/ghc/ \/\/ /_/\/|_| Type :? for help. Loading package base ... linking ... done. :m Test.HUnit abc @=? efg Loading package HUnit-1.1.1 ... linking ... done. *** Exception: user error (HUnit:expected: abc but got: efg) Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Exposed module still hidden, why?
Using GHC 6.8.1 on Windows XP, after having used ghc-pkg to expose ' directory-1.0.0.0', I am getting an error when I build haddock that says the package is hidden. When I type ghc-pkg list, the package is not in parenthesis. Typing ghc -v says that it is using the file from C:\ghc\ghc-6.8.1\package.conf. That package.conf file has the 'exposed' set to True for that file. Why does GHC still think the package is hidden? ...\haddock-0.8runhaskell Setup.lhs configure Configuring haddock-0.8... ...\haddock-0.8runhaskell Setup.lhs build Preprocessing executables for haddock-0.8... shift/reduce conflicts: 5 Building haddock-0.8... src/Main.hs:49:7: Could not find module `System.Directory': it is a member of package directory-1.0.0.0, which is hidden ...\haddock-0.8ghc-pkg list C:/ghc/ghc-6.8.1\package.conf: Cabal-1.2.2.0, HUnit-1.2.0.0, OpenGL-2.2.1.1, QuickCheck-1.1.0.0, Win32-2.1.0.0, array-0.1.0.0, base-3.0.0.0, bytestring-0.9.0.1, cgi-3001.1.5.1, containers-0.1.0.0, directory-1.0.0.0, fgl-5.4.1.1, filepath-1.1.0.0, (ghc-6.8.1), haskell-src-1.0.1.1, haskell98-1.0.1.0, hpc-0.5.0.0, html-1.0.1.1, mtl-1.1.0.0, network-2.1.0.0, old-locale-1.0.0.0, old-time-1.0.0.0, packedstring-0.1.0.0, parallel-1.0.0.0, parsec-2.1.0.0, pretty-1.0.0.0, process-1.0.0.0, random-1.0.0.0, regex-base-0.72.0.1, regex-compat-0.71.0.1, regex-posix-0.72.0.1, rts-1.0, stm-2.1.1.0, template-haskell-2.2.0.0, time-1.1.2.0, xhtml-3000.0.2.1 Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell-cafe] Re: Exposed module still hidden, why?
Why does GHC still think the package is hidden? You need to add directory to the Build-Depends instruction in the cabal file Thanks Olivier. Haddock now builds with this list for 'build-depends': base=1.0, haskell98=1.0, directory=1.0, process=1.0, containers=0.1, array=0.1, pretty=1.0 The 'build' step also requires Happy and Alex to be installed, which are not mentioned in the cabal file. Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
6.8.1: source code in docs?
GHC 6.8.1's docs no longer link to the source code in the upper right-hand corner of each module. Intentional? http://haskell.org/ghc/docs/latest/html/libraries/ Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell-cafe] Re: Composing trading strategies (was: Should I step into a minefield? / Writing a trading studio in Haskell)
Hi Joel, Can you post a couple of examples of what the trading strategies look like? Here are some very simple strategies, which are written in the context of just one stock. If these aren't very convincing, could you post some more complex strategies that you'd like to see built using this library? -- open long when price drops to 109.34 myOpenStrategy = limitOrder 109.34 -- close after done increasing or price drops below 105.12 myCloseStrategy openPrice = increasing openPrice | limitOrder 105.12 -- succeed when the current price reaches or drops below the given price limitOrder price = satisfy (= price) Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Composing trading strategies (was: Should I step into a minefield? / Writing a trading studio in Haskell)
My idea is to write something like TradeStation [1] or NinjaTrader, only for the Mac. It would be quite nifty to use SPJ's financial combinator approach I was experimenting with a Haskell EDSL for financial trading not too long ago. My favorite strategy so far is the parallel parser combinator approach. It allows users to run many parallel trading strategies in a nice single-threaded way that's easy to reason about and straightforward to compose new trading strategies. The idea is that the user composes an 'openPosition' and 'closePosition' trading strategies from a combinator library and gives them to the trading platform. The user's trading strategies are nothing more than a numeric parser combinators. With each incoming quote, the trading platform kicks off the user's 'openPosition' trading strategy. When a strategy succeeds (a successful parse), the trading platform opens a position for the user. Once a position is opened, the platform starts running the user's 'closePosition' strategy. The closePosition parser is run the same way and when it succeeds, the user's position is closed. To implement, I leveraged Twan van Laarhoven's ParseP library ( http://twan.home.fmf.nl/parsep/), which at least for my simple experiments, was incredibly complete and stable given its 0.1 version number. Why ParseP and not Parsec or ReadP? Parsec doesn't have an unbiased choice operator and ReadP only works on strings. Implementing context-free trading strategies like limit orders is very easy (limitOrder price = satisfy (= price)), but context-sensitive strategies, such as match the longest string of increasing numbers is quite a bit more painful. Below are some of my experiments (also on hpaste: http://hpaste.org/3756). If anybody could offer more elegant solutions, I'd love to hear because this still feels overly complicated to me. 'testUpThenDown' matches an input stream that increases then decreases. 'testNumericFib' will try to match as much of the Fibonacci sequence as possible. import Text.ParserCombinators.ParseP import qualified Text.ParserCombinators.ParseP.Greedy as Greedy import Control.Applicative import Data.Monoid testUpThenDown = print $ runParser coaster [1, 2, 1] testNumericFib = print $ runParser (fib (Sum 1) (Sum 1)) (map Sum [2, 3, 5, 7, 1]) testAlphaFib = print $ runParser (fib a b) [ab, bab, cad] fib :: (Eq a, Monoid a) = a - a - Parser a p [a] fib n1 n2 = Greedy.option [] (do n3 - satisfy (== (n1 `mappend` n2)) ns - fib n2 n3 return (n3:ns)) coaster :: Ord a = Parser a p ([a], [a]) coaster = do seed - get up - increasing seed down - decreasing (last up) return (seed:up, down) increasing seed = trend () seed decreasing seed = trend () seed trend :: (Monad (Parser a p)) = (a - a - Bool) - a - Parser a p [a] trend f = many1WithContext (satisfy . f) manyWithContext p = Greedy.option [] . many1WithContext p many1WithContext p seed = do n - p seed ns - manyWithContext p n return (n:ns) Thanks, Greg On Nov 7, 2007 5:02 PM, Joel Reymont [EMAIL PROTECTED] wrote: I need to pick among the usual list of suspects for a commercial product that I'm writing. The suspects are OCaml, Haskell and Lisp and the product is a trading studio. My idea is to write something like TradeStation [1] or NinjaTrader, only for the Mac. It would be quite nifty to use SPJ's financial combinator approach and, for example, embed Yi (Haskell editor). One of the key features of the product would be the ability to model your trading logic using a trading DSL. I'm thinking that this DSL could well be Haskell but I'm concerned about stepping into a minefield. I will need to embed GHC into the app, for example, and I understand that the GHC API does not offer unloading of code at the moment. I would prefer not to bundle GHC separately so I don't think the hs- plugins approach would work for me. Maybe I'm mistaken. Most of all, I'm concerned that my users will need to face the error reports from GHC and could get tripped by laziness, i.e. write something that would make the app run out of memory. Off the top of my head I can't figure out a way to limit what my users can do without analyzing the Haskell AST within the GHC API and complaining if necessary. Can someone with experience in offering a Haskell DSL to their users please comment? Notice that I'm not even mentioning being concerned with the unpredictable effects of laziness. There's probably a reason why Jane St Capital is using OCaml instead of Haskell. I'm not going to play in that league but my knee-jerk reaction is to use OCaml or Lisp and avoid laziness altogether. I just can't see how laziness can help in processing real-time price data. Thanks, Joel [1] http://www.tradestation.com/default_2.shtm [2] http://www.ninjatrader.com/webnew/index.htm -- http://wagerlabs.com ___ Haskell-Cafe mailing list
[Haskell-cafe] ARM back end?
Anybody know of an ARM back end for any of the Haskell compilers? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Why can't Haskell be faster?
while LOC is not perfect, gzip is worse. the gzip change didn't significantly alter the rankings Currently the gzip ratio of C++ to Python is 2.0, which at a glance, wouldn't sell me on a less code argument. Although the rank stayed the same, did the change reduce the magnitude of the victory? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Elevator pitch for Haskell.
Paul, This page (http://www.npdbd.umn.edu/deliver/elevator.html) has a template for an elevator pitch. I thought I'd try instantiating it for Haskell. For software developers who need to produce highly reliable software at minimum cost... Looks like a good pitch for developers. Here's my attempt for management: For software project leaders looking to decrease the risk of software construction in large componentized systems. Haskell is a programming language where software components can be built safely and predictably from existing components without increasing the system's overall complexity. Unlike Java or C, Haskell functions are called 'safe' because each function either explicitly states its side effects or is guaranteed to have none. Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
OPTIONS_GHC -iMyDir
I notice that some of GHC's command-line parameters do not work from within the OPTIONS_GHC pragma (6.6.1 on Windows). I can see how that makes sense for some parameters like --make, but what about -i and -v? Is this intentional or a bug? Can't specify the include path: {-# OPTIONS_GHC -iMyDir #-} Can't compile a single file in 'verbose' mode: {-# OPTIONS_GHC -v #-} Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] directory tree?
Chad, I can't seem to find anything representing a directory tree Here's my shot. http://hpaste.org/370 Not much different than Tom Moertel's, but grabs the fileSize along the way. -Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: 64-bit windows version? (Haskell is a scripting language too!)
each sub-project...have a...Haskell program...building that sub-project I was trying to build something like this recently but hit a roadblock. Rather than execute the script in each directory, I wanted to import it as a module instead. This way you can, for example, pass functions, like a logger, to a function in the imported module. Also, rather than execute the script immediately, you can combine many sub-projects into a big graph, have a look at common dependencies and use Concurrent Haskell to parallelize the build. Unfortunately, the imported module needs to have the line module X.Y.Zwhere, which means the file needs to be aware of its parent directories. I think that's too harsh a constraint, and makes it a pain to move things around (true in everyday Haskell projects with local modules too!). My plan for a workaround was to try to use a preprocessor, but would really rather avoid that if anyone else has any ideas. Thanks, Greg ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] embedded build language?
Tomek, If you want to see the code I will try to release it I'm very interested. Thanks, Greg On 6/15/07, Tomasz Zielonka [EMAIL PROTECTED] wrote: On Thu, Jun 14, 2007 at 05:55:46PM -0700, Greg Fitzgerald wrote: Has anyone embedded a build language in Haskell? Something like Rakehttp://rake.rubyforge.org/is to Ruby, but in Haskell or any statically-typed functional language. I have. It consists of such components: - A type for build rules type Rule = FilePath - Maybe (BuildMonad (IO ())) newtype BuildMonad a = BuildMonad { runBuildMonad :: WriterT [FilePath] IO a } deriving (Monad, MonadWriter [FilePath]) Every rule has three levels: - matching target file names:: FilePath - Maybe a - generating dependencies :: WriterT [FilePath] m a - target building :: IO () The levels are nested in a way that allows to use variables bound on one level in the levels below. - An simple rule execution engine - takes a list of rules and tries to build given targets taking care of dependencies - A small library of useful functions, eg. for using temporary files with automatic renaming on successful completion (so you don't end up with partially built targets). - A small Template Haskell library for Perl-like string interpolation to help constructing shell commands If you want to see the code I will try to release it (it's in a company's project), but it's quite small and IMHO the nicest thing in it is the overall idea. It's quite heavy for simple uses, but in more complicated cases it allows things which are nearly (or literally) impossible in GNU make. Best regards Tomek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] embedded build language?
Has anyone embedded a build language in Haskell? Something like Rakehttp://rake.rubyforge.org/is to Ruby, but in Haskell or any statically-typed functional language. Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: [Haskell] Who pays for *.haskell.org machines?
is its funding will be reliable? for example, if we don't get money from Google in 2008 year? Some hosting companies, like http://turtol.com/ offer pay once, keep forever. Would that be an option? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Idiomatically using lists
Kevin, Below is my attempt, which hopefully is bad enough to get this thread rolling for you. :) It rotates the 'i'th element 'n' times by swapping the 'i'th element with the element to its right 'n' times. It looks horribly inefficient to me, but is fairly simple and only depends on the prelude. I think it ought to be possible to reduce this to a very simple function with no recursion and one strategic splitAt, but I've run out of time to work more on it. :( rotate :: [a] - Int - Int - [a] rotate xs i n = snd (iterate swap (i,xs) !! n) swap :: (Int, [a]) - (Int, [a]) swap (i,xs) | i == length xs - 1 = (0, last xs : init (tail xs) ++ [head xs]) | otherwise = (i + 1, start ++ [right,left] ++ end) where (start, left:right:end) = splitAt i xs -Greg On 6/4/07, kevin birch [EMAIL PROTECTED] wrote: On 火, 2007-6月-05, at 02:54, Greg Fitzgerald wrote: rotating the fourth element 2 positions would result in: [1, 2, 4, 3, 5] Seems odd. Should that be [4,1,2,3,5]? Yes, I meant to use the 5 element in my second example. Sorry for the confusion. Is there an idomatic way to handle both of these cases in a function? Generally people like to see your attempt at a solution before giving the idomatic one so that they are sure it's not a homework question. What do you have so far? Yeah, I only wish I had gone to a school that would be forward thinking enough to each FP. ;-) Here is my version: rotate :: Array Integer Card - Integer - Integer - Array Integer Card rotate a i n | i = u - n = a // [(i, a ! (i + 1)), (i + 1, a ! (i + 2)), (i + 2, a ! i)] | otherwise = a // zip [l..u] (h ++ [a ! i] ++ filter (not . (== (a ! i))) t) where (l, u) = bounds a (h, t) = splitAt (fromInteger ((i - u) + n)) $ elems a This function is part of my implementation of the Solitaire encryption algorithm, so that is why I have the reference to a Card data type. This does what I want, and seems basically idiomatic, but perhaps it could be better. Thanks, Kevin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Lazy IO and closing of file handles
Pete, mapM fileContentsOfDirectory = mapM_ print . threadEmails . map parseEmail . concat By using the IO monad you've /scheduled/ your first 'print' to occur after your last 'readFile', so every file is opened before the first file is read. I've come across the same problem and would also be interested in a more elegant solution. The problem is that your program assumes a readonly filesystem, but the compiler doesn't know that. For all it knows, the 'print' after your first parse may be overwriting the contents of your second file. What we need is a library for a readonly filesystem. That is, all the same functions but pure. I believe you could make this readonly library by wrapping each readonly I/O function with 'unsafeInterleaveIO' or 'unsafePerformIO', but I don't really understand the consequences of using 'unsafe' calls, so I avoided it myself. Until that's figured out, one solution is as Don suggested, when you read a file, read the whole file at once so that the runtime can close the file handle. This lets you leave the rest of your code alone, but if your files are too big, as they were for me, this will blow your heap! My solution (code below) was to rearrange my I/O calls so that each print is executed immediately after each readFile. This takes away the modularity you're looking for and assumes you can process one file at time, but without a safe readonly filesystem library and files too big to be read all at once, I think this is about the best we can do for now. Hopefully others will disagree! main = do [dir] - getArgs paths - getFilePaths dir mapM_ (either print prettyPrint `oM` parse) paths getFilePaths = return . flatten `oM` getFileTree -- Given a path, this returns a tree getFileTree :: FilePath - IO (Tree FilePath) getFileTree = unfoldTreeM childPaths where childPaths dir = do fs - if' (getDirectoryContents dir) (return []) = doesDirectoryExist dir return (dir, [dir ++ / ++ p | p - fs, head p /= '.']) infixl 8 `oM` (a `oM` b) x = b x = a if' t f b = if b then t else f Thanks, Greg On 3/14/07, Pete Kazmier [EMAIL PROTECTED] wrote: When using readFile to process a large number of files, I am exceeding the resource limits for the maximum number of open file descriptors on my system. How can I enhance my program to deal with this situation without making significant changes? My program takes one or more directories that contain email messages, stored one per file, and prints a list of all the email threads. Here is a snippet of output: New addition to the Kazmier family Casey Kazmier Memoization in Erlang? Thomas Johnsson Ulf Wiger \(AL/EAB\) As a newcomer to Haskell, I am intrigued by lazy evaluation and how it can influence one's designs. With that said, I wrote the program as a sequence of list manipulations which seemed quite natural to do in Haskell starting with reading the contents of the each file. Here is the algorithm at the high level: 1. Read contents of all files returning a list of Strings 2. Map over the list and parse each String as an Email 3. Sort the list of Emails 4. Group the list of Emails by Subject 5. Map over the grouped list to create a list of Threads 6. Finally, print the list of Threads It is my understanding that, as a result of lazy IO, the entire file does not need to be read into memory because parseEmail only inspects the topmost portion of the email (its headers), which is a key part of my design as some of the files can be quite large. Unfortunately, as soon as I run this program on a directory with more than 1024 files, GHC craps out on me due to resource limits. It seems that the handles opened by readFile remain open. Would this be common across all Haskell implementations? How do I go about fixing this without making a significant number of changes to my program? Did I make a mistake in steps 1 and 2 above? Should I have read and parsed a single file at a time, and then move on to the next? I'd appreciate any other comments on the program as well. I feel this is the best example of Haskell code that I have written. Compared to the first version of this program I wrote a few months ago, this is a hundred times better. Here is the program: module Main where import Control.Monad (filterM, liftM) import Data.List import Data.Maybe import System.Directory import System.Environment type From= String type Subject = String data Email = Email {from :: From, subject :: Subject} deriving Show data Thread = Thread [Email] instance Show Thread where show (Thread emails@(e:es)) = title ++ senders where title = newline . bolder . subject $ e sender = newline . indent . from senders = concatMap sender emails newline = (++ \n) indent = ( ++) bolder = (\27[0;32;40m ++) . (++ \27[0m) main = getArgs = mapM
[Haskell-cafe] How to build a generic spreadsheet?
I want to write a program where a user would update a bunch of variables, and everything that depends on those variables (and nothing else) are recalculated. Basically, a spreadsheet, but generalized for any computation. Could someone recommend an elegant way to do it or some good reading material? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] pythags
Check out Hoogle: http://haskell.org/hoogle/?q=guard import Control.Monad -Greg On 2/12/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, the Advanced Monads page in the Haskell Wikibook (http://en.wikibooks.org/wiki/Haskell/Advanced_monads) contains the following example of a List Monad pythags = do x - [1..] y - [x..] z - [y..] guard (x^2 + y^2 == z^2) return (x, y, z) However, whenever you load that function definition into Hugs or GHCi, you get a message saying that guard is an undefined variable. Does anyone know why? Thanks. phiroc ___ 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] OT: any haskell-friendly / functional programming friendly comp sci programs? (for a 30s guy who did his undergrad in liberal arts)
Thomas, Here's a good place to start, although I'm not sure how up to date it is: http://haskell.org/haskellwiki/Haskell_in_education I too am interested in an FP-related, higher education in California. Could you please send another post with whatever information you find? Thanks, Greg On 2/5/07, Thomas Hartman [EMAIL PROTECTED] wrote: haskellers, I'm contemplating returning to school after a decade as a worker bee, and almost that long as a worker bee doing computer consulting / miscelaneous tech stuff. Ideally I'd like to get a masters, but I don't know if that's feasible this late in the game. If it's not, I might settle for a lesser degree and worry about the masters later. Part of my desire to return to school is that after encountering functional programming over the past year or so (first through lisp, then haskell), I've found something that I'm really interested in, but that it feels the amount of learning I can do around a job just won't cut it to get to the level that I want. That's the personal reason; the practical reason is that I think it would be a good networking opportunity (hankering to start my own company, and not meeting the right kinds of people), and obviously increase my chance of getting better paying, but especially more *interesting* jobs. I have some savings, figure loans would cover the rest, and no wife or kids. So I'll make a rather open ended request for advice. Are there decent comp sci master's programs out there that will take someone who didn't do a hard science in undergrad, but has lots of work-related experience with programming? If not, what's the next best thing? Get a quick bachelor's? Spend six months cramming for the GREs and then try for a master's? Whether master's, bachelor's, or other, I am specifically interested in programs that are functional friendly. In other words, I don't want to just go and study algorithms in java for two years. Ideally, I'd like to go somewhere where I could really explore and get good at the functional languages, with haskell my current favorite but also open to others. (For what it's worth, most of my experience is in perl, but I take it seriously as a language and try not to write the kind of throwaway crap that mean people make fun of.) My background is that I have a liberal arts bachelors from an american ivy. Though I enjoyed the program very much, it probably wasn't the wisest financial decision, given the type of career I subsequently gravitated to. But hey, maybe that gives me a different kind of perspective that has its own kind of value. Since, then, there;s mainly work work work for me, with some time off bumming around europe. And, on my own time: learn learn learn. I'm now 31. I've been living in germany for a few years, mainly freelancing as a computer consultant, and am open to programs in europe -- probably either england or germany. Largely because programs out here seem to be significantly cheaper than programs in the states, and being a somewhat older student seems to be less unusual out here. However, truth be told, I have a hankering for my homeland, the good old USA. And if possible somewhere in california, where my extended family is based, or it not that new york, where I have a good network. (But open to other locations as well; cali and new york would just be my top choices.) Distance learning is okay if the program is really good, but doing the campus thing again, perhaps while working part or semi-full time, would be the ideal (though perhaps I'm pushing the age limit there?). This has gotten rather long, so I'll leave it at that. Sorry about going off topic, and thanks in advance for any advice. thomas ___ 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] Suggestions for a hReadUntilStr implementation
Matt, should finish evaluating when either the timer has run out or I recommend changing my implementation of hReadUntilStr so that the deadline is calculated upfront (have a look at System.Time), and then reducing the number of milliseconds for hReadUntilChar with each call to it. Thanks, Greg On 2/4/07, Matt Revelle [EMAIL PROTECTED] wrote: Thanks for the responses. Greg, your implementation looks useful but it's a little different than what I was thinking (my apologies, I wasn't very clear). In the implementation you posted, the timeout parameter is used to limit the amount of time spent waiting to read an individual character - I was hoping to use the timeout as an initial value for a timer that should start running when hReadUntilStr is evaluated and the function should finish evaluating when either the timer has run out or when the string match has been found. Martin, thanks for the link. Cheers, Matt On 2/3/07, Greg Fitzgerald [EMAIL PROTECTED] wrote: Hi Matt, hReadUntilStr - that is, a function that takes a Handle as an input source, a String to match, and a Num a as the number of seconds to wait before returning a (String, Bool) where the String is all the text read from the Handle until either matching or timing out and the Bool is true if the input String was matched This might work for you: http://hpaste.org/289 . It throws an IO exception if hWaitForChar times out, and makes use of lazy evaluation to schedule all the IO upfront so that grabbing the string prefix can be done in pure code. Thanks, Greg ___ 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] Suggestions for a hReadUntilStr implementation
Hi Matt, hReadUntilStr - that is, a function that takes a Handle as an input source, a String to match, and a Num a as the number of seconds to wait before returning a (String, Bool) where the String is all the text read from the Handle until either matching or timing out and the Bool is true if the input String was matched This might work for you: http://hpaste.org/289. It throws an IO exception if hWaitForChar times out, and makes use of lazy evaluation to schedule all the IO upfront so that grabbing the string prefix can be done in pure code. Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Simple HTTP lib for Windows?
Alistair, Neil, Brad, Yitzchak, Bjorn, Thanks all for your help. -Greg On 1/19/07, Björn Bringert [EMAIL PROTECTED] wrote: Greg Fitzgerald wrote: I'd like to write a very simple Haskell script that when given a URL, looks up the page, and returns a string of HTML. I don't see an HTTP library in the standard libs, and the one in Hackage requires Windows machines have GHC and MinGW to be installed and in the PATH. Is there a simple way to get the contents of a webpage using Haskell on a Windows box? I agree with other posters that the Network.HTTP API should be made more easy to use. I will happily accept patches for this. The HTTP package homepage (http://www.haskell.org/http/) mentioned the GHC and MinGW requirements you cite, but those seemed to be out of date. You should be able to use plain Cabal to install the HTTP package for any recent GHC or Hugs. /Björn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Simple HTTP lib for Windows?
I'd like to write a very simple Haskell script that when given a URL, looks up the page, and returns a string of HTML. I don't see an HTTP library in the standard libs, and the one in Hackage requires Windows machines have GHC and MinGW to be installed and in the PATH. Is there a simple way to get the contents of a webpage using Haskell on a Windows box? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Shrinking the Prelude: The categorical approach
Wouldn't this raise the same problems monad comprehensions raise? The do-notation isn't specific to IO, yet it is the only thing beginners use it for. Do beginners have noticeably more trouble with the do-notation errors than list comprehension errors? As someone who learned Haskell fairly recently, I never really read the compiler errors. I looked for the line number, and whether it was a type error or syntax error. The rest might as well have been Greek, and I was fine with that. Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Showing the 1 element tuple
Neil, On Tue, Dec 19, 2006 at 10:41:56PM +, Neil Mitchell wrote: A weird question, what does the 1 element tuple look like? Could tuples be implemented as an HList? singleton = (`hCons` hNil) -Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Refactoring recklessly
I'd like to be able to reorganize my code and then verify that I didn't change any functionality. That is, the old and new code have precisely the same meaning. Also, I'd like to be able to change a function and verify that efficiency was the only thing affected. Are either of these possible in Haskell or any language? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Reversing a string of words: C# v Perl V Ruby v Haskell
Hi Steve, On 12/11/06, Steve Downey [EMAIL PROTECTED] wrote: transforming one two three four into four three two one, how could this be done? This is a good problem for Parsechttp://www.cs.uu.nl/%7Edaan/download/parsec/parsec.html : import Text.ParserCombinators.Parsec reverseWords = concat . reverse . split where split = fromRight . parse wordsSpaces fromRight (Right s) = s wordsSpaces = many (many1 space | many1 alphaNum) -Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] '+++' and 'interleave'
Could ReadP's '+++' (symmetric choice) operator be implemented for all Monads with the 'interleave' function mentioned in Backtracking, Interleaving, and Terminating Monad Transformershttp://portal.acm.org/ft_gateway.cfm?id=1086390type=pdfcoll=GUIDEdl=GUIDECFID=5430836CFTOKEN=76321932? This paper was a tough read for me, but it looks like they solve the same problem, but one interleaves computations within a monad and the other does it from the outside. Or am I just confused? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Parsec: Where's +++?
Koen Claessen's Parallel Parsing Processes, suggests their parsing combinators have been integrated into Parsec. If so, where is the +++ operator hiding? If not, does anyone know of a parsing library with a choice operator that does breadth-first search? Also, how do I determine what instances a datatype supports? Is Parsec an instance of Applicative? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parsec: Where's +++?
Text.ParserCombinators.ReadP.(+++) :: ReadP a - ReadP a - ReadP a Wow, fast and complete, Thanks Don!:) Would it make sense to derive instances of Applicable and Alternative for ReadP? Something like this maybe: instance Applicative ReadP where pure = return (*) = ap instance Alternative ReadP where empty = pfail (|) = (++) Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Strictness, order of IO operations: NewCGI HDBC
Does DB.getTables use 'unsafeInterleaveIO'?I would think that if an unsafe operation was *not* used, DB.disconnect could *not* execute before DB.getTables has returned every row.Either way, by the Principle of Least Surprise, I think Tim's original code ought to be made to work, despite not leveraging laziness. If you are going to tuck away an unsafeInterleaveIO, it seems reasonable that an explicit disconnect should force those deferred operations to be evaluated. Maybe the same should be done for hGetContents/hClose too? Thanks,GregOn 10/9/06, John Goerzen [EMAIL PROTECTED] wrote: On Mon, Oct 09, 2006 at 04:01:02PM -0600, Tim Smith wrote: main =dodbh - connectODBC DSN=testres - DB.getTables dbh-- print (show ((concat . intersperse , ) res)) DB.disconnect dbhprint (show ((concat . intersperse , ) res)) Am I just expecting the wrong thing from Haskell?Is there aYes.Remember the Haskell mantra: no computation is performed before its result is demanded.Since you are not demanding the list of tablesuntil the print statement, the code to get the list of tables is notexecuted until then.Actually, follow that logic through.Think about when the connection to the database is established.If I understand things properly, it won'thappen until your call to disconnect, since nothing demands the handleuntil then.Note that this is normally not the case, since the first use of it will demand that the connection happens.I think the easiest way around this is to add this line after the callto getTables:return $ seq res resthough you may also be able to say: evaluate res(provided you have imported Control.Exception)But the very best way is to simply not disconnect until after you'veprinted. technical reason why HDBC can't synchronize the IO so that everything is resolved before the disconnect?Or is this a bug in HDBC?It's a Feature of Haskell, not a bug.This is the same feature that lets you process infinite lists, treatmulti-GB files as strings, and, in fact, treat multi-GB SQL result sets as simple lists.Haskell only loads each line of the file, or row ofresult, into RAM when it is demanded.(Note that some databases areless lazy than Haskell in this respect, so this only works if yourdatabase API can return partial results!) I have tried to put warnings into the HDBC docs where I think people areparticularly likely to run afoul of this -- quickQuery springs to mind.Note that the API docs for getTables, at http://darcs.complete.org/hdbc/doc/Database-HDBC.html#v%3AgetTablesmention that the data is returned in the same manner as fetchAllRows.Click on the link to fetchAllRows and you see:Lazily fetch all rows from an executed Statement. You can think of this as hGetContents applied to a database result set.The result of this is a lazy list, and each new row will be read,lazily, from the database as the list is processed. When you have exhausted the list, the Statement will be finished.Please note that the careless use of this function can lead to someunpleasant behavior. In particular, if you have not consumed the entire list, then attempt to finish or re-execute the statement, and thenattempt to consume more elements from the list, the result will almostcertainly not be what you want.But then, similar caveats apply with hGetContents. Bottom line: this is a very convenient abstraction; use it wisely.-- John___Haskell-Cafe mailing list Haskell-Cafe@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Strictness, order of IO operations: NewCGI HDBC
An ugly solution is to explicitly keep a pointer to the next unevaluated entry, advancing it in the interleaved IO operation. A leaky solution is to keep a reference to the list, and force it all. Another way to attack this is asking: Why doesn't the simple solution work? That is, not using unsafeInterleaveIO.It seems like any problem caused by not using unsafeInterleaveIO is fundamentally because the IO monad encapsulates orthogonal regions. Why can't I interleave fetching rows from the DB with writing each row to the console? Sure, it is *possible* that writing to the console is piped back into the same database, but if not, you're serializing things that don't need to be serialized. Thanks,Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] flip dot
You mean apply the function on the right to the result of the left?Yes.(.) :: a - (a - b) - bx.f == f xPrefix usage:given: (f :: Integer - Char) and (g :: Double - Double - Integer) (foo = .f) == \x - f x(bar = .g) == \x y = g x yfoo :: Double - Double - Charfoo = .g.f How about making . reverse composition, and...symbol for flip ($) [1,2,3]#null.not that works too, and is clearly easier to implement, but there's an opportunity to shorten the gap between Haskell and the mainstream languages, and without losing functional composition.Also, if you flip the meaning of dot, some existing code will still compile, but produce different values (map ((+1) . (*2))). By changing the type signature of the infix operator, it would break all existing code at *compile-time*. With the prefix dot operator, I like how small the transition from pointwise to point-free code is:f x = x.null.notf = .null.notSame is true of the hash-dot style too, of course:f x = x#null.not f = null.notBoth are quite a better than Haskell today:f x = not (null x)f x = not $ null xf x = (not . null) xf = not . null left-to-right order lets you think of the starting value and make a sequence of transformations does syntax affect this? if someone views a solution with an imperative point-of-view, won't they just use $ or parenthesis everywhere anyway?Thanks,Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] flip dot
Since there's talk of removal of the composition operator in Haskell-prime, how about this: Instead of:foo = f . gyou write:foo = .g.fA leading dot would mean, apply all unnamed parameters to the function on the right. A trailing dot would mean, apply the result of the left to the function on the right. Prelude notNull = .null.not= [a] - BoolnotNull [1,2,3]= True[1,2,3].notNull= True[1,2,3].null.not = TrueI like this because it has the same perks as the composition operator, yet it looks like OO code and the data flows nicely from left to right. It reads especially well when using the bind operator on the same line. Thoughts?Thanks,Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] automatic instance derivation
well, the best practical way i know is to use Template Haskell / DrIFTThat's too bad. I was hoping we could trivially solve Tim Newsham's XML problem by importing HaXml, automatically deriving Data and Typeable for HaXml's 'Content' data type, and then use 'everywhereM' from Data.Generics.Schemes to do his stateful XML transformation.-Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe