From ivan.miljenovic at gmail.com Sat Sep 1 00:44:27 2012 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Sat, 1 Sep 2012 08:44:27 +1000 Subject: [Haskell-cafe] Function names in Haskell lib not first-class on web! In-Reply-To: References: Message-ID: On 1 September 2012 01:11, damodar kulkarni wrote: > I knew hoogle to some extent, not an expert user though. > and, it seems, the "hoogle plugin for firefox" works only for haskell.org Because Hoogle indexes the packages on Hackage. Where else can it find it Haskell source code? If I understand correctly, Hoogle (and Hayoo) directly parse the Haskell source code rather than being a search engine in the Google sense. -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From evohunz at gmail.com Sat Sep 1 01:14:26 2012 From: evohunz at gmail.com (Thiago Negri) Date: Fri, 31 Aug 2012 20:14:26 -0300 Subject: [Haskell-cafe] Yesod a href render issue Message-ID: I'm following Yesod tutorial that gives this as the first example for "type-safe URLs": | getHomeR = defaultLayout [whamlet|Go to page 1!|] Worked fine, the "a href" generated looks perfect. Then I tried this: | getHomeR = defaultLayout [whamlet|Hello!Go to page 1!|] And got a "a href" referecing a URL without quotes and with no end tag for "a", something like this: | HelloGo to page 1! I tried in many different ways, and the only way to get it working properly was to set the "a" tag in a line by itself: | getHomeR = defaultLayout [whamlet|Hello! | Go to page 1! | |] Is this a failure of Yesod quasiquotation or am I missing something? I know Yesod clearly states that the best approach is to use external files instead of quasiquotes, but as I'm making my first steps into Yesod, I would like to use the practical embedded quasiquotes. From toad3k at gmail.com Sat Sep 1 02:45:46 2012 From: toad3k at gmail.com (David McBride) Date: Fri, 31 Aug 2012 20:45:46 -0400 Subject: [Haskell-cafe] Yesod a href render issue In-Reply-To: References: Message-ID: Hamlet is whitespace sensitive like haskell and python. If you put a tag after text, it is treated as text. Write the wrote: > I'm following Yesod tutorial that gives this as the first example for > "type-safe URLs": > > | getHomeR = defaultLayout [whamlet|Go to page 1!|] > > Worked fine, the "a href" generated looks perfect. > Then I tried this: > > | getHomeR = defaultLayout [whamlet|Hello!Go to page > 1!|] > > And got a "a href" referecing a URL without quotes and with no end tag > for "a", something like this: > > | HelloGo to > page 1! > > I tried in many different ways, and the only way to get it working > properly was to set the "a" tag in a line by itself: > > | getHomeR = defaultLayout [whamlet|Hello! > | Go to page 1! > | |] > > Is this a failure of Yesod quasiquotation or am I missing something? > I know Yesod clearly states that the best approach is to use external > files instead of quasiquotes, but as I'm making my first steps into > Yesod, I would like to use the practical embedded quasiquotes. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jays at panix.com Sat Sep 1 02:56:48 2012 From: jays at panix.com (Jay Sulzberger) Date: Fri, 31 Aug 2012 20:56:48 -0400 (EDT) Subject: [Haskell-cafe] Build regressions due to GHC 7.6 In-Reply-To: References: Message-ID: On Fri, 31 Aug 2012, Alexander Kjeldaas wrote: > I think you're making this way harder than it really is. > > What 99% of people need is that hackage packages builds with the latest > haskell platform, and/or with bleeding edge ghc, and with the latest > versions of its dependencies. > > Thus for every dependency there is only one possible version - the latest > one, and there are only a couple of compilers. > > Having "special interest groups" for ghc 6.12 support and old versions of > text is fine, but I think it is a pretty uninteresting problem to solve. > > Likewise, supporting/fixing packages where the author for some reason > *requires* use of a non-current version of some other package is also quite > uninteresting (or at least outside the scope of my needs). Such a package > is basically just a relic. > > Alexander If that is the set of constraints you must meet, namely that for every library you wish to use, the same platform is specified as the only platform you want, yes, I agree. I am also sympathetic to imposing such tight management of the repository. (This tight management could consist of just well checked annotations as to what works with what.) But there are other cases, for example, testing various combinations of libraries for speed and memory use. And such a flexible tool will be of use when the Move To One Platform comes. Being able to pick up code and modify code, and to write code to do this, is part of the tradition today called "functional programming". The Cut Over would be done with a Big Haskell Program that would test/re-write/test etc. until every line of code was updated and a database of interactions produced and made available in convenient form. oo--JS. > > On 30 August 2012 22:26, Jay Sulzberger wrote: > >> >> >> On Thu, 30 Aug 2012, Alexander Kjeldaas >> wrote: >> >> This is very unfortunate, but this is crucially a tooling issue. I am >>> going to wave my hands, but.. >>> >>> Ignore the mapreduce in the following video, but look at the use of clang >>> to do automatic refactoring of C++. This is *incredibly* powerful in >>> dealing with updates to APIs. >>> >>> http://www.llvm.org/devmtg/**2011-11/videos/Carruth_** >>> ClangMapReduce-desktop.mp4 >>> >>> But without all that fancy tech, *just* having all of Hackage source code >>> in one repository and using perl/regexps, fixing these types of issues is >>> O(1) instead of O(n). >>> >>> All of the issues you mention seems to be fixable by a few lines of perl >>> *if we had the repository*. >>> >> >> Better to do this with sexps. >> >> ad repositories: Part of the general problem of managing a >> repository is close to the problem of inferring a good type for >> (the value of) an expression. The style of constraints is >> similar. Now the design problem is: >> >> 1. Arrange a general system for the specification of the >> constraints. >> >> 2. Design a systematic way of giving both advice and direct >> commands to the system. This subsystem would be used to set >> up the default policy. >> >> 3. Choose a constraint solver. >> >> Maybe worth looking at: >> >> http://en.wikipedia.org/wiki/**Nix_package_manager >> [page was last modified on 17 July 2012 at 20:20] >> >> oo--JS. >> >> >> >>> [a few hours later] >>> >>> Actually, I went and downloaded all of hackage, put it into a git >>> repository and fixed these issues: >>> >>> Fix catch >>> perl -ni -e 'print unless /import Prelude hiding \(catch\)/' $(git grep >>> 'import Prelude hiding (catch)') >>> >>> Fix CInt constructors (lots of other stuff from Foreign.C.Types not fixed >>> though) >>> perl -p -i -e 's/^import Foreign.C.Types(.*)CInt([^(])/**import >>> Foreign.C.Types${1}CInt(..)${**1}/g' $(git grep -l '^import.*CInt') >>> >>> Fix bytestring versioning >>> perl -p -i -e 's/bytestring( +)>=([0-9. &]+)<([ >>> ]*)0.10/bytestring$1>=$2<${3}**0.11/g' $(git grep 'bytestring.*< *0\.') >>> >>> Patch to hackage: >>> http://ge.tt/6Cb5ErM/v/0 >>> >>> I understand that this doesn't help anyone, but if there was a way fix, >>> upload, and get *consensus* on a few regexps like this, then doing API >>> changes wouldn't be such a headache. >>> >>> Alexander >>> >>> On 30 August 2012 07:26, Bryan O'Sullivan wrote: >>> >>> Since the release of the GHC 7.6 RC, I've been going through my packages >>>> and fixing up build problems so that people who upgrade to 7.6 will have >>>> a >>>> smooth ride. >>>> >>>> Sad to say, my experience of 7.6 is that it has felt like a particularly >>>> rough release for backwards incompatibility. I wanted to quantify the >>>> pain, >>>> so I did some research, and here's what I found. >>>> >>>> I maintain 25 open source Haskell packages. Of these, the majority have >>>> needed updates due to the GHC 7.6 release: >>>> >>>> - base16-bytestring >>>> - blaze-textual >>>> - bloomfilter >>>> - configurator >>>> - criterion >>>> - double-conversion >>>> - filemanip >>>> - HDBC-mysql >>>> - mwc-random >>>> - pcap >>>> - pool >>>> - riak-haskell-client >>>> - snappy >>>> - text >>>> - text-format >>>> - text-icu >>>> >>>> >>>> That's 16 out of 25 packages I've had to update. I've also either >>>> reported >>>> bugs on, or had to fix, several other people's packages along the way >>>> (maybe four?). So let's say I've run into problems with 20 out of the >>>> combined 29 packages of mine and my upstreams. >>>> >>>> The reasons for these problems fall into three bins: >>>> >>>> - Prelude no longer exports catch, so a lot of "import Prelude hiding >>>> (catch)" had to change. >>>> - The FFI now requires constructors to be visible, so "CInt" has to be >>>> imported as "CInt(..)". >>>> - bytestring finally got bumped to 0.10, so many upper bounds had to >>>> be relaxed (*cf* my suggestion that the upper-bounds-by-default policy >>>> >>>> is destructive). >>>> >>>> It has been a lot of work to test 29 packages, and then modify, rebuild, >>>> and release 20 of them. It has consumed most of my limited free time for >>>> almost two weeks. Worse, this has felt like make-work, of no practical >>>> benefit to anyone beyond scrambling to restore the status quo ante. >>>> >>>> If over half of my packages needed fixing, I'm alarmed at the thought of >>>> the effects on the rest of Hackage. >>>> >>>> I'm torn over this. I understand and agree with the impetus to improve >>>> the >>>> platform by tidying things up, and yet just two seemingly innocuous >>>> changes >>>> (catch and FFI) have forced me to do a bunch of running to stand still. >>>> >>>> I don't have any suggestions about what to do; I know that it's hard to >>>> estimate the downstream effects of what look like small changes. And so >>>> I'm >>>> not exactly complaining. Call this an unhappy data point. >>>> >>>> ______________________________**_________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe at haskell.org >>>> http://www.haskell.org/**mailman/listinfo/haskell-cafe >>>> >>>> >>>> >>> >> ______________________________**_________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/**mailman/listinfo/haskell-cafe >> > From felipe.lessa at gmail.com Sat Sep 1 03:04:41 2012 From: felipe.lessa at gmail.com (Felipe Almeida Lessa) Date: Fri, 31 Aug 2012 22:04:41 -0300 Subject: [Haskell-cafe] Yesod a href render issue In-Reply-To: References: Message-ID: On Fri, Aug 31, 2012 at 9:45 PM, David McBride wrote: > Hamlet is whitespace sensitive like haskell and python. If you put a tag > after text, it is treated as text. > > Write the when the tag is in the middle of the line. This is especially useful for tags such as or , e.g. This is very important! vs. This is # very \ important! Cheers, -- Felipe. From ppremont at cognimeta.com Sat Sep 1 04:54:41 2012 From: ppremont at cognimeta.com (Patrick Premont) Date: Fri, 31 Aug 2012 22:54:41 -0400 Subject: [Haskell-cafe] [Haskell] ANNOUNCE: Perdure In-Reply-To: References: <001101cd86bc$6b8def50$42a9cdf0$@com> Message-ID: <000001cd87ed$22aaf300$6800d900$@com> We will work on releasing more interesting examples. For now there are only the test files such as https://github.com/Cognimeta/perdure/blob/7b6cbe80d1fc735f697b3ee148b01eb57c4079fa/exe-src/Database/Perdure/TestState.hs. There were many internals that are needlessly exposed. We've hidden them in 0.2.0 so you can browse the actual API. Thank you for the words of welcome. Patrick Cognimeta Inc. -----Original Message----- From: Felipe Almeida Lessa [mailto:felipe.lessa at gmail.com] Sent: Thursday, August 30, 2012 11:26 To: Patrick Premont Cc: Haskell Cafe Subject: Re: [Haskell] ANNOUNCE: Perdure [moving discussion to haskell-cafe] Congratulations and thanks for your new open source contribution! I hope you feel at home =). Your library looks really interesting but I'm completely overwhelmed by its size. Its Cabal description is huge and there's no example of how to use the library (it actually took me some time to understand what the library tries to accomplish). I took a quick look at the modules but there are so many that I couldn't really make sense of anything in a short time. So, could you perhaps write a full example of how to use the library? It looks like a nice library but I need a starting point =). Cheers! -- Felipe. From faridnsh at gmail.com Sat Sep 1 06:13:46 2012 From: faridnsh at gmail.com (Farid Neshat) Date: Sat, 1 Sep 2012 12:13:46 +0800 Subject: [Haskell-cafe] Compiling a haskell project as a shared library and loading it in C/C++ Message-ID: So I'm trying to follow [this blog][1]. So I tried the code, couldn't compile the haskell part, probably due to the fact the guide uses version 6, but I have version 7 of ghc. By changing the paramaters I could compile it with the following: ghc --make -dynamic -shared -fPIC -no-hs-main -optl '-shared' -optc '-DMODULE=Test' -o Test.so Test.hs module_init.c But the when trying to load it, on dlopen, I get the following error: /usr/lib/ghc/ghc-prim-0.2.0.0/libHSghc-prim-0.2.0.0-ghc7.4.1.so: undefined symbol: stg_forkOnzh I suspect it's because the haskell runtime is not linked to the shared library but adding -L/usr/lib/ghc/ didn't really help. I searched a lot, but couldn't find anymore example that somebody have done this. [Here's also some docs][2] for compiling shared libraries: [1]: http://weblog.haskell.cz/pivnik/building-a-shared-library-in-haskell [2]: http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/using-shared-libs.html From timothyhobbs at seznam.cz Sat Sep 1 12:18:39 2012 From: timothyhobbs at seznam.cz (timothyhobbs at seznam.cz) Date: Sat, 01 Sep 2012 12:18:39 +0200 (CEST) Subject: [Haskell-cafe] Over general types are too easy to make. References: Message-ID: So after having played with it a little, it looks like GADTs are the way to go.? The method of manipulating the module system won't work because of two reasons: A) How can a user pattern match against data constructors that are hidden by the module system? B) It's an awful hack. Do I understand correctly that with the GADTs I have to create my own record selectors/lenses separately? Thanks, Timothy ---------- P?vodn? zpr?va ---------- Od: Austin Seipp Datum: 31. 8. 2012 P?edm?t: Re: [Haskell-cafe] Over general types are too easy to make. "What you are essentially asking for is a refinement on the type of 'BadFoo' in the function type, such that the argument is provably always of a particular constructor. The easiest way to encode this kind of property safely with Haskell 2010 as John suggested is to use phantom types and use the module system to ban people from creating BadFrog's etc directly, by hiding the constructors. That is, you need a smart constructor for the data type. This isn't an uncommon idiom and sometimes banning people (by default) from those constructors is exactly what you have to do. It's also portable and easy to understand. Alternatively, you can use GADTs to serve witness to a type equality constraint, and this will discharge some of the case alternatives you need to write. It's essentially the kind of refinement you want: data Frog data Bar data Foo x :: * where Bar :: Int -> Foo Bar Frog :: String -> Int -> Foo Frog You can't possibly then pattern match on the wrong case if you specify the type, because that would violate the type equality constraint: deFrog :: Foo Frog -> String deFrog (Frog x _) = x -- not possible to define 'deFrog (Bar ...) ...', because that would violate the constraint 'Foo x' ~ 'Foo Frog' It's easier to see how this equality constraint works if you deconstruct the GADT syntax into regular equality constraints: data Bar data Frog data Foo x = (x ~ Bar) => Bar Int | (x ~ Frog) => Frog String Int It's then obvious the constructor carries around the equality constraint at it's use sites, such as the definition of 'deFrog' above. Does this solve your problem? On Fri, Aug 31, 2012 at 1:00 PM, wrote: > I'd have to say that there is one(and only one) issue in Haskell that bugs > me to the point where I start to think it's a design flaw: > > It's much easier to type things over generally than it is to type things > correctly. > > Say we have a > >>data BadFoo = >> BadBar{ >> badFoo::Int} | >> BadFrog{ >> badFrog::String, >> badChicken::Int} > > This is fine, until we want to write a function that acts on Frogs but not > on Bars. The best we can do is throw a runtime error when passed a Bar and > not a Foo: > >>deBadFrog :: BadFoo -> String >>deBadFrog (BadFrog s _) = s >>deBadFrog BadBar{} = error "Error: This is not a frog." > > We cannot type our function such that it only takes Frogs and not Bars. > This makes what should be a trivial compile time error into a nasty runtime > one :( > > The only solution I have found to this is a rather ugly one: > >>data Foo = Bar BarT | Frog FrogT > > If I then create new types for each data constructor. > >>data FrogT = FrogT{ >> frog::String, >> chicken::Int} > >>data BarT = BarT{ >> foo :: Int} > > Then I can type deFrog correctly. > >>deFrog :: FrogT -> String >>deFrog (FrogT s _) = s > > But it costs us much more code to do it correctly. I've never seen it done > correctly. It's just too ugly to do it right :/ and for no good reason. It > seems to me, that it was a design mistake to make data constructors and > types as different entities and this is not something I know how to fix > easily with the number of lines of Haskell code in existence today :/ > >>main = do >> frog <- return (Frog (FrogT "Frog" 42)) >> print $ >> case frog of >> (Frog myFrog) -> deFrog myFrog >> badFrog <- return (BadBar 4) >> print $ >> case badFrog of >> (notAFrog at BadBar{}) -> deBadFrog notAFrog > > The ease with which we make bad design choices and write bad code(in this > particular case) is tragically astounding. > > Any suggestions on how the right way could be written more cleanly are very > welcome! > > Timothy Hobbs > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe (http://www.haskell.org/mailman/listinfo/haskell-cafe) > -- Regards, Austin" -------------- next part -------------- An HTML attachment was scrubbed... URL: From mad.one at gmail.com Sat Sep 1 17:28:12 2012 From: mad.one at gmail.com (Austin Seipp) Date: Sat, 1 Sep 2012 10:28:12 -0500 Subject: [Haskell-cafe] Over general types are too easy to make. In-Reply-To: References: Message-ID: On Sat, Sep 1, 2012 at 5:18 AM, wrote: > So after having played with it a little, it looks like GADTs are the way to > go. The method of manipulating the module system won't work because of two > reasons: > > A) How can a user pattern match against data constructors that are hidden by > the module system? You can't directly, but the correct way to do this if you want it is to use view patterns and export a view specifically for your hidden data type. This gives you some extra flexibility in what you give to clients, although view patterns add a little verbosity. > B) It's an awful hack. To each his own. The module system in Haskell serves as nothing more than a primitive namespace really, so I don't see why hiding things by default in namespaces seems like a hack (you should of course export hidden stuff too, but in another module, as a last ditch effort in case users need it. Sometimes this is very very useful.) > Do I understand correctly that with the GADTs I have to create my own record > selectors/lenses separately? I don't know. I suppose it depends on the lens library in question. Ones that use template haskell to drive accessors may, or may not, work (I suppose it would depend on whether or not the derivation is prepared to deal with GADTs when invoked, which isn't guaranteed - Template Haskell is kind of awful like that.) > Thanks, > > Timothy > > > ---------- P?vodn? zpr?va ---------- > Od: Austin Seipp > > > Datum: 31. 8. 2012 > P?edm?t: Re: [Haskell-cafe] Over general types are too easy to make. > > What you are essentially asking for is a refinement on the type of > > 'BadFoo' in the function type, such that the argument is provably > always of a particular constructor. > > The easiest way to encode this kind of property safely with Haskell > 2010 as John suggested is to use phantom types and use the module > system to ban people from creating BadFrog's etc directly, by hiding > the constructors. That is, you need a smart constructor for the data > type. This isn't an uncommon idiom and sometimes banning people (by > default) from those constructors is exactly what you have to do. It's > also portable and easy to understand. > > Alternatively, you can use GADTs to serve witness to a type equality > constraint, and this will discharge some of the case alternatives you > need to write. It's essentially the kind of refinement you want: > > data Frog > data Bar > > data Foo x :: * where > Bar :: Int -> Foo Bar > Frog :: String -> Int -> Foo Frog > > You can't possibly then pattern match on the wrong case if you specify > the type, because that would violate the type equality constraint: > > deFrog :: Foo Frog -> String > deFrog (Frog x _) = x > -- not possible to define 'deFrog (Bar ...) ...', because that would > violate the constraint 'Foo x' ~ 'Foo Frog' > > It's easier to see how this equality constraint works if you > deconstruct the GADT syntax into regular equality constraints: > > data Bar > data Frog > > data Foo x = > (x ~ Bar) => Bar Int > | (x ~ Frog) => Frog String Int > > It's then obvious the constructor carries around the equality > constraint at it's use sites, such as the definition of 'deFrog' > above. > > Does this solve your problem? > > On Fri, Aug 31, 2012 at 1:00 PM, wrote: >> I'd have to say that there is one(and only one) issue in Haskell that bugs >> me to the point where I start to think it's a design flaw: >> >> It's much easier to type things over generally than it is to type things >> correctly. >> >> Say we have a >> >>>data BadFoo = >>> BadBar{ >>> badFoo::Int} | >>> BadFrog{ >>> badFrog::String, >>> badChicken::Int} >> >> This is fine, until we want to write a function that acts on Frogs but not >> on Bars. The best we can do is throw a runtime error when passed a Bar and >> not a Foo: >> >>>deBadFrog :: BadFoo -> String >>>deBadFrog (BadFrog s _) = s >>>deBadFrog BadBar{} = error "Error: This is not a frog." >> >> We cannot type our function such that it only takes Frogs and not Bars. >> This makes what should be a trivial compile time error into a nasty >> runtime >> one :( >> >> The only solution I have found to this is a rather ugly one: >> >>>data Foo = Bar BarT | Frog FrogT >> >> If I then create new types for each data constructor. >> >>>data FrogT = FrogT{ >>> frog::String, >>> chicken::Int} >> >>>data BarT = BarT{ >>> foo :: Int} >> >> Then I can type deFrog correctly. >> >>>deFrog :: FrogT -> String >>>deFrog (FrogT s _) = s >> >> But it costs us much more code to do it correctly. I've never seen it done >> correctly. It's just too ugly to do it right :/ and for no good reason. It >> seems to me, that it was a design mistake to make data constructors and >> types as different entities and this is not something I know how to fix >> easily with the number of lines of Haskell code in existence today :/ >> >>>main = do >>> frog <- return (Frog (FrogT "Frog" 42)) >>> print $ >>> case frog of >>> (Frog myFrog) -> deFrog myFrog >>> badFrog <- return (BadBar 4) >>> print $ >>> case badFrog of >>> (notAFrog at BadBar{}) -> deBadFrog notAFrog >> >> The ease with which we make bad design choices and write bad code(in this >> particular case) is tragically astounding. >> >> Any suggestions on how the right way could be written more cleanly are >> very >> welcome! >> >> Timothy Hobbs >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > -- > Regards, > Austin -- Regards, Austin From david.feuer at gmail.com Sat Sep 1 21:26:00 2012 From: david.feuer at gmail.com (David Feuer) Date: Sat, 1 Sep 2012 15:26:00 -0400 Subject: [Haskell-cafe] hstats median algorithm Message-ID: The median function in the hstats package uses a naive O(n log n) algorithm. Is there another package providing an O(n) option? If not, what would it take to get the package upgraded? From ivan.miljenovic at gmail.com Sun Sep 2 00:25:15 2012 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Sun, 2 Sep 2012 08:25:15 +1000 Subject: [Haskell-cafe] hstats median algorithm In-Reply-To: References: Message-ID: On 2 September 2012 05:26, David Feuer wrote: > The median function in the hstats package uses a naive O(n log n) > algorithm. Is there another package providing an O(n) option? If not, > what would it take to get the package upgraded? http://hackage.haskell.org/packages/archive/statistics/latest/doc/html/Statistics-Quantile.html#v:medianUnbiased ? hstats appears not to have been updated since 2008 and doesn't build with GHC 7.2 (and presumably 7.4). Maybe try contacting the maintainer? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From tsuyoshi.ito.2006 at gmail.com Sun Sep 2 01:08:03 2012 From: tsuyoshi.ito.2006 at gmail.com (Tsuyoshi Ito) Date: Sat, 1 Sep 2012 19:08:03 -0400 Subject: [Haskell-cafe] Is there a tool for automatic update of other-extensions and other-modules sections in a .cabal file? Message-ID: Hello, I have a *.cabal file which contains a package description for several executables (which share some of the source files). Is there a tool which updates other-extensions section and other-modules section in the .cabal file automatically to synchronize them to the source files? If it matters, I am using Haskell Platform 2012.2.0.0 on Windows. (I am aware that neither ?cabal configure? nor ?cabal build? requires these sections, and therefore it is not strictly necessary to update them during development of a program. But when I use a version control system such as Git, I find it ugly to store a .cabal file which is not synchronized to the latest source files? this is the primary reason why I would like such a tool.) Best regards, Tsuyoshi From gershomb at gmail.com Sun Sep 2 03:17:06 2012 From: gershomb at gmail.com (Gershom Bazerman) Date: Sat, 01 Sep 2012 21:17:06 -0400 Subject: [Haskell-cafe] hstats median algorithm In-Reply-To: References: Message-ID: <5042B392.5030401@gmail.com> In my experience, doing much better than the naive algorithm for median is surprisingly hard, and involves a choice from a range of trade-offs. Did you have a particular better algorithm in mind? If you did, you could write it, and contact the package author with a patch. You also may be able to find something of use in Edward Kmett's order-statistics package: http://hackage.haskell.org/package/order-statistics Cheers, Gershom On 9/1/12 3:26 PM, David Feuer wrote: > The median function in the hstats package uses a naive O(n log n) > algorithm. Is there another package providing an O(n) option? If not, > what would it take to get the package upgraded? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From kc1956 at gmail.com Sun Sep 2 08:14:08 2012 From: kc1956 at gmail.com (KC) Date: Sat, 1 Sep 2012 23:14:08 -0700 Subject: [Haskell-cafe] hstats median algorithm In-Reply-To: <5042B392.5030401@gmail.com> References: <5042B392.5030401@gmail.com> Message-ID: Is there any special structure in your data that could be exploited? On Sat, Sep 1, 2012 at 6:17 PM, Gershom Bazerman wrote: > In my experience, doing much better than the naive algorithm for median is > surprisingly hard, and involves a choice from a range of trade-offs. Did you > have a particular better algorithm in mind? > > If you did, you could write it, and contact the package author with a patch. > > You also may be able to find something of use in Edward Kmett's > order-statistics package: > http://hackage.haskell.org/package/order-statistics > > Cheers, > Gershom > > > On 9/1/12 3:26 PM, David Feuer wrote: >> >> The median function in the hstats package uses a naive O(n log n) >> algorithm. Is there another package providing an O(n) option? If not, >> what would it take to get the package upgraded? -- -- Regards, KC From tim at dockerz.net Sun Sep 2 12:13:34 2012 From: tim at dockerz.net (Tim Docker) Date: Sun, 02 Sep 2012 20:13:34 +1000 Subject: [Haskell-cafe] Over general types are too easy to make. In-Reply-To: References: Message-ID: <5043314E.4000206@dockerz.net> On 01/09/12 04:00, timothyhobbs at seznam.cz wrote: > I'd have to say that there is one(and only one) issue in Haskell that > bugs me to the point where I start to think it's a design flaw: > > It's much easier to type things over generally than it is to type > things correctly. > > Say we have a > > >data BadFoo = > > BadBar{ > > badFoo::Int} | > > BadFrog{ > > badFrog::String, > > badChicken::Int} > > This is fine, until we want to write a function that acts on Frogs but > not on Bars. The best we can do is throw a runtime error when passed > a Bar and not a Foo: > > >deBadFrog :: BadFoo -> String > >deBadFrog (BadFrog s _) = s > >deBadFrog BadBar{} = error "Error: This is not a frog." > > We cannot type our function such that it only takes Frogs and not > Bars. This makes what should be a trivial compile time error into a > nasty runtime one :( > > The only solution I have found to this is a rather ugly one: > > >data Foo = Bar BarT | Frog FrogT > > If I then create new types for each data constructor. > > >data FrogT = FrogT{ > > frog::String, > > chicken::Int} > > >data BarT = BarT{ > > foo :: Int} > > Then I can type deFrog correctly. > > >deFrog :: FrogT -> String > >deFrog (FrogT s _) = s > I'm curious as to what you find ugly about this. It appears you need to distinguish between Bars and Frogs, so making them separate types (and having a 3rd type representing the union) is a natural haskell solution: data Bar = .. data Frog = .. fn1 :: Bar -> .. fn2 :: Frog -> .. fn3 :: Either Bar Frog -> .. Perhaps a more concrete example would better illustrate your problem? Tim From timothyhobbs at seznam.cz Sun Sep 2 12:35:16 2012 From: timothyhobbs at seznam.cz (timothyhobbs at seznam.cz) Date: Sun, 02 Sep 2012 12:35:16 +0200 (CEST) Subject: [Haskell-cafe] Over general types are too easy to make. References: <5043314E.4000206@dockerz.net> Message-ID: The problem with the last example I gave is evident in your statement "It appears you need to distinguish between Bars and Frogs". I have written quite a number of largish code bases, and I've run into the following problem every time: case largeMultiConstructorTypedValue of ?? Foo{blah=blah,brg=brg} -> .... Some large block... ?? Bar{lolz=lolz,foofoo=foofoo} -> ...Another large block... ?? Frog{legs=legs,heads=heads} -> Yet another large block... Where the obvious re-factor is: case largeMultiConstructorTypedValue of ?? foo at Foo -> processFoo foo ?? bar at Bar -> processBar bar ?? frog at Frog -> processFrog frog processFoo :: Foo -> SomeType processBar :: Bar -> SomeType processFrog:: Frog -> SomeType I always want to be able to make procssFoo, processBar, and processFrog typestrict to their associated constructors.? Otherwise they are doomed to be incomplete functions. It seems to be a probability approaching law, that I run into this for a given multi-constructor type. Regardless of it's purpose. Timothy ---------- P?vodn? zpr?va ---------- Od: Tim Docker Datum: 2. 9. 2012 P?edm?t: Re: [Haskell-cafe] Over general types are too easy to make. "On 01/09/12 04:00, timothyhobbs at seznam.cz wrote: > I'd have to say that there is one(and only one) issue in Haskell that > bugs me to the point where I start to think it's a design flaw: > > It's much easier to type things over generally than it is to type > things correctly. > > Say we have a > > >data BadFoo = > > BadBar{ > > badFoo::Int} | > > BadFrog{ > > badFrog::String, > > badChicken::Int} > > This is fine, until we want to write a function that acts on Frogs but > not on Bars. The best we can do is throw a runtime error when passed > a Bar and not a Foo: > > >deBadFrog :: BadFoo -> String > >deBadFrog (BadFrog s _) = s > >deBadFrog BadBar{} = error "Error: This is not a frog." > > We cannot type our function such that it only takes Frogs and not > Bars. This makes what should be a trivial compile time error into a > nasty runtime one :( > > The only solution I have found to this is a rather ugly one: > > >data Foo = Bar BarT | Frog FrogT > > If I then create new types for each data constructor. > > >data FrogT = FrogT{ > > frog::String, > > chicken::Int} > > >data BarT = BarT{ > > foo :: Int} > > Then I can type deFrog correctly. > > >deFrog :: FrogT -> String > >deFrog (FrogT s _) = s > I'm curious as to what you find ugly about this. It appears you need to distinguish between Bars and Frogs, so making them separate types (and having a 3rd type representing the union) is a natural haskell solution: data Bar = .. data Frog = .. fn1 :: Bar -> .. fn2 :: Frog -> .. fn3 :: Either Bar Frog -> .. Perhaps a more concrete example would better illustrate your problem? Tim _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe at haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe (http://www.haskell.org/mailman/listinfo/haskell-cafe)" -------------- next part -------------- An HTML attachment was scrubbed... URL: From tim at dockerz.net Sun Sep 2 14:03:36 2012 From: tim at dockerz.net (Tim Docker) Date: Sun, 02 Sep 2012 22:03:36 +1000 Subject: [Haskell-cafe] Over general types are too easy to make. In-Reply-To: References: <5043314E.4000206@dockerz.net> Message-ID: <50434B18.8040009@dockerz.net> On 02/09/12 20:35, timothyhobbs at seznam.cz wrote: > > It seems to be a probability approaching law, that I run into this for > a given multi-constructor type. Regardless of it's purpose. > Maybe your large multi-constructor types are too monolithic? Again it's hard to know given a fabricated example, but I would have been satisfied with something like: data Foo = Foo {...} data Bar = Bar {...} data Frog = Frog {...} data LargeUnion = UFoo Foo | UBar Bar | UFrog Frog case largeUnion of (UFoo foo) -> processFoo foo (UBar bar) -> processBar bar (UFrog frog) -> processFrog frog But I think from your original mail, you find this ugly in some way? Tim From nicolas at incubaid.com Sun Sep 2 15:24:58 2012 From: nicolas at incubaid.com (Nicolas Trangez) Date: Sun, 02 Sep 2012 15:24:58 +0200 Subject: [Haskell-cafe] Vector: blit'ing a source into a destination Message-ID: <1346592298.3834.7.camel@tau.nicolast.be> All, For some code I need to alter an (unboxed or storable) vector by blit'ing (copying) data from another (smaller) vector into it, overwriting the existing data. I couldn't find a function for this in the vector API, so I hacked something up which cuts the jobs (see below), but it feels really ugly/dirty. Any ideas about a better way to tackle this, and wouldn't this be a useful addition to the standard API? Thanks, Nicolas import Data.Vector.Unboxed (Unbox, Vector) import qualified Data.Vector.Unboxed as UV import qualified Data.Vector.Unboxed.Mutable as MUV blit :: Unbox a => Vector a -> Vector a -> Int -> Vector a blit src dest offset = UV.modify act dest where act dest' = do let slice = MUV.slice offset len dest' src' <- UV.unsafeThaw src MUV.copy slice src' len = UV.length src main :: IO () main = do let v = UV.fromList [0 :: Int .. 10] b = UV.fromList [20, 30, 40] putStrLn $ "v = " ++ show v putStrLn $ "b = " ++ show b putStrLn $ "blit b v 2 = " ++ show (blit b v 2) -- v = fromList [0,1,2,3,4,5,6,7,8,9,10] -- b = fromList [20,30,40] -- blit b v 2 = fromList [0,1,20,30,40,5,6,7,8,9,10] From ketil at malde.org Sun Sep 2 15:25:37 2012 From: ketil at malde.org (Ketil Malde) Date: Sun, 02 Sep 2012 15:25:37 +0200 Subject: [Haskell-cafe] Over general types are too easy to make. In-Reply-To: (timothyhobbs@seznam.cz's message of "Sun, 02 Sep 2012 12:35:16 +0200 (CEST)") References: <5043314E.4000206@dockerz.net> Message-ID: <87627wy2su.fsf@nmd999X.imr.no> writes: > case largeMultiConstructorTypedValue of > Foo{blah=blah,brg=brg} -> .... Some large block... > Bar{lolz=lolz,foofoo=foofoo} -> ...Another large block... > Frog{legs=legs,heads=heads} -> Yet another large block... > > Where the obvious re-factor is: > case largeMultiConstructorTypedValue of > foo at Foo -> processFoo foo > bar at Bar -> processBar bar > frog at Frog -> processFrog frog Hm - is that really so obvious? To me, it seems like the definition of processFoo will typically be: processFoo (Foo blah brg) = ... deconstructing the Foo again. If the Foo is very big, this might be a good solution, but in many cases, I expect you can do: case largeMultiConstructorTypedValue of Foo {blah=blah,brg=brg} -> processBlahBrg blah brg and this would make the type more specific. -k -- If I haven't seen further, it is by standing in the footprints of giants From timothyhobbs at seznam.cz Sun Sep 2 18:40:43 2012 From: timothyhobbs at seznam.cz (timothyhobbs at seznam.cz) Date: Sun, 02 Sep 2012 18:40:43 +0200 (CEST) Subject: [Haskell-cafe] Over general types are too easy to make. References: <5043314E.4000206@dockerz.net> Message-ID: The thing is, that one ALWAYS wants to create a union of types, and not merely an ad-hock list of data declarations.? So why does it take more code to do "the right thing(tm)" than to do "the wrong thing(r)"?? Lets take an example from Conor McBride's "she"? https://github.com/timthelion/her-lexer/ blob/master/src/Language/Haskell/Her/HaLay.lhs#L139? Line 139 we have a case statement: >??????? ((i, t) : its') -> case (m, t) of >????????? (Lay _ j, _) | not (null acc) && i <= j -> (reverse acc, its) >????????? (Lay _ _, Semi) -> (reverse acc, its) >????????? (Lay k _, KW e) | elem (k, e) layDKillaz -> (reverse acc, its) >????????? (Lay _ _, Clo _) -> (reverse acc, its) >????????? (Bra b, Clo b') | b == b' -> (reverse acss, its') >????????? (m, Ope b) -> case getChunks (Bra b) [] its' of >??????????? (cs, its) -> getChunks m (B b cs : acss) its >????????? (m, KW e) | elem e lakeys -> case getLines (Seek m e) [] its' of >??????????? (css, its) -> getChunks m ((L e css) : acss) its >????????? _ -> getChunks m (t : acss) its' Maybe we would want to re-factor this like so: >??????? ((i, t) : its') -> case (m, t) of >????????? layTup@(Lay{}, _) | layTest layTup -> (reverse acc, its) >????????? (Bra b, Clo b') | b == b' -> (reverse acss, its') >????????? (m, Ope b) -> case getChunks (Bra b) [] its' of >??????????? (cs, its) -> getChunks m (B b cs : acss) its >????????? (m, KW e) | elem e lakeys -> case getLines (Seek m e) [] its' of >??????????? (css, its) -> getChunks m ((L e css) : acss) its >????????? _ -> getChunks m (t : acss) its' >??? where >???? layTest :: (ChunkMode,Tok) -> Bool >???? layTest (Lay _ j, _) | not (null acc) && i <= j = True >???? layTest (Lay _ _, Semi) = True >???? layTest (Lay k _, KW e) | elem (k, e) layDKillaz = True >???? layTest (Lay _ _, Clo _) = True >???? layTest _ = False You see what's wrong with layTest's type?? It shouldn't be taking a (ChunkMode,Tok) but rather a (Lay,Tok).? You ALWAYS run into this.? Perhaps you would understand the problem better, if I hadn't said that the data union of types is too ugly, but that the normal data is too pretty?? Everyone ends up getting caught in this trap.? And the only way out is to re -write your code with better typing. Timothy Od: Tim Docker Datum: 2. 9. 2012 P?edm?t: Re: [Haskell-cafe] Over general types are too easy to make. ---------- P?vodn? zpr?va ---------- "On 01/09/12 04:00, timothyhobbs at seznam.cz wrote: > I'd have to say that there is one(and only one) issue in Haskell that > bugs me to the point where I start to think it's a design flaw: > > It's much easier to type things over generally than it is to type > things correctly. > > Say we have a > > >data BadFoo = > > BadBar{ > > badFoo::Int} | > > BadFrog{ > > badFrog::String, > > badChicken::Int} > > This is fine, until we want to write a function that acts on Frogs but > not on Bars. The best we can do is throw a runtime error when passed > a Bar and not a Foo: > > >deBadFrog :: BadFoo -> String > >deBadFrog (BadFrog s _) = s > >deBadFrog BadBar{} = error "Error: This is not a frog." > > We cannot type our function such that it only takes Frogs and not > Bars. This makes what should be a trivial compile time error into a > nasty runtime one :( > > The only solution I have found to this is a rather ugly one: > > >data Foo = Bar BarT | Frog FrogT > > If I then create new types for each data constructor. > > >data FrogT = FrogT{ > > frog::String, > > chicken::Int} > > >data BarT = BarT{ > > foo :: Int} > > Then I can type deFrog correctly. > > >deFrog :: FrogT -> String > >deFrog (FrogT s _) = s > I'm curious as to what you find ugly about this. It appears you need to distinguish between Bars and Frogs, so making them separate types (and having a 3rd type representing the union) is a natural haskell solution: data Bar = .. data Frog = .. fn1 :: Bar -> .. fn2 :: Frog -> .. fn3 :: Either Bar Frog -> .. Perhaps a more concrete example would better illustrate your problem? Tim _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe at haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe (http://www.haskell.org/mailman/listinfo/haskell-cafe)" -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.solla at gmail.com Sun Sep 2 19:06:04 2012 From: alex.solla at gmail.com (Alexander Solla) Date: Sun, 2 Sep 2012 10:06:04 -0700 Subject: [Haskell-cafe] Over general types are too easy to make. In-Reply-To: References: <5043314E.4000206@dockerz.net> Message-ID: On Sun, Sep 2, 2012 at 9:40 AM, wrote: > The thing is, that one ALWAYS wants to create a union of types, and not > merely an ad-hock list of data declarations. So why does it take more code > to do "the right thing(tm)" than to do "the wrong thing(r)"? > Because a union type is a complex union of parts, and the parts need to be deconstructed in order to be acted upon. There is not a unique way to do this -- different "unwrappings" have different properties and must match your use case. Perhaps you should read "Data types ala carte" (W. Swiestra) [1], which provides an approach to constructing "open" data types (i.e., sum types to which new summands can be added) [1] http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesALaCarte.pdf -------------- next part -------------- An HTML attachment was scrubbed... URL: From danny.b.eml at gmail.com Sun Sep 2 20:25:08 2012 From: danny.b.eml at gmail.com (Danny B) Date: Mon, 03 Sep 2012 05:25:08 +1100 Subject: [Haskell-cafe] hellno - a somewhat different approach to tackling cabal hell Message-ID: <5043A484.2040804@gmail.com> Like many of us, I've suffered from cabal dependency hell and sought relief. I wasn't exactly happy with sandboxes - because using per-project ones meant package duplication and shared sandboxes suffer from the same issues as the GHC package database itself, i.e. reinstalls can break other projects, etc. So I wrote hellno, which is so named because that's the expression one makes when seeing cabal hell suddenly manifest itself and that's also the expression one makes upon encountering yet ANOTHER cabal wrapper. To quote the README: > Generally, with hellno you'll get the same result as for blowing away your user > package database and doing a nice clean install but without having to recompile > everything and with ability to easily revert back and change between projects. Hellno works by keeping all the compiled packages to itself in a database, so that when you ask it to bring in the dependencies of a project, it will use the precompiled packages if available or install the deps and save them for later reuse. Hellno puts symlinks in the user package database pointing to packages in its storage to make them visible. Mutating the user db is hardly elegant, although shouldn't result in much trouble. It's been working fine for me, so I figured it may be useful to others. You can get hellno from GitHub: https://github.com/db81/hellno I don't mean to say that sandboxing is inherently bad or should not be used, but I guess it's better to consider more than one way. From mail at nh2.me Sun Sep 2 20:51:00 2012 From: mail at nh2.me (=?UTF-8?B?TmlrbGFzIEhhbWLDvGNoZW4=?=) Date: Sun, 02 Sep 2012 19:51:00 +0100 Subject: [Haskell-cafe] hellno - a somewhat different approach to tackling cabal hell In-Reply-To: <5043A484.2040804@gmail.com> References: <5043A484.2040804@gmail.com> Message-ID: <5043AA94.1030405@nh2.me> Hell yeah! Looks like a nice approach. On Sun 02 Sep 2012 19:25:08 BST, Danny B wrote: > Like many of us, I've suffered from cabal dependency hell and sought relief. > > I wasn't exactly happy with sandboxes - because using per-project ones > meant package duplication and shared sandboxes suffer from the same > issues as the GHC package database itself, i.e. reinstalls can break > other projects, etc. So I wrote hellno, which is so named because that's > the expression one makes when seeing cabal hell suddenly manifest itself > and that's also the expression one makes upon encountering yet ANOTHER > cabal wrapper. > > To quote the README: >> Generally, with hellno you'll get the same result as for blowing away your user >> package database and doing a nice clean install but without having to recompile >> everything and with ability to easily revert back and change between projects. > > Hellno works by keeping all the compiled packages to itself in a > database, so that when you ask it to bring in the dependencies of a > project, it will use the precompiled packages if available or install > the deps and save them for later reuse. > > Hellno puts symlinks in the user package database pointing to packages > in its storage to make them visible. Mutating the user db is hardly > elegant, although shouldn't result in much trouble. > > It's been working fine for me, so I figured it may be useful to others. > You can get hellno from GitHub: > https://github.com/db81/hellno > > I don't mean to say that sandboxing is inherently bad or should not be > used, but I guess it's better to consider more than one way. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From krismicinski at gmail.com Sun Sep 2 21:10:20 2012 From: krismicinski at gmail.com (Kristopher Micinski) Date: Sun, 2 Sep 2012 14:10:20 -0500 Subject: [Haskell-cafe] Over general types are too easy to make. In-Reply-To: References: <5043314E.4000206@dockerz.net> Message-ID: On Sun, Sep 2, 2012 at 12:06 PM, Alexander Solla wrote: > > > On Sun, Sep 2, 2012 at 9:40 AM, wrote: >> >> The thing is, that one ALWAYS wants to create a union of types, and not >> merely an ad-hock list of data declarations. So why does it take more code >> to do "the right thing(tm)" than to do "the wrong thing(r)"? > > > Because a union type is a complex union of parts, and the parts need to be > deconstructed in order to be acted upon. There is not a unique way to do > this -- different "unwrappings" have different properties and must match > your use case. > > Perhaps you should read "Data types ala carte" (W. Swiestra) [1], which > provides an approach to constructing "open" data types (i.e., sum types to > which new summands can be added) > > > [1] http://www.cs.ru.nl/~W.Swierstra/Publications/DataTypesALaCarte.pdf > If you're going to suggest that line of thinking you might also the concept of rows in general.., though I'm not sure that's really quite what he wants. kris From carter.schonwald at gmail.com Sun Sep 2 21:47:04 2012 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Sun, 2 Sep 2012 15:47:04 -0400 Subject: [Haskell-cafe] hellno - a somewhat different approach to tackling cabal hell In-Reply-To: <5043AA94.1030405@nh2.me> References: <5043A484.2040804@gmail.com> <5043AA94.1030405@nh2.me> Message-ID: awesome! I look forward to playing with this and hopefully saying "hell yeah" when i'm done :) -Carter On Sun, Sep 2, 2012 at 2:51 PM, Niklas Hamb?chen wrote: > Hell yeah! > > Looks like a nice approach. > > On Sun 02 Sep 2012 19:25:08 BST, Danny B wrote: > > Like many of us, I've suffered from cabal dependency hell and sought > relief. > > > > I wasn't exactly happy with sandboxes - because using per-project ones > > meant package duplication and shared sandboxes suffer from the same > > issues as the GHC package database itself, i.e. reinstalls can break > > other projects, etc. So I wrote hellno, which is so named because that's > > the expression one makes when seeing cabal hell suddenly manifest itself > > and that's also the expression one makes upon encountering yet ANOTHER > > cabal wrapper. > > > > To quote the README: > >> Generally, with hellno you'll get the same result as for blowing away > your user > >> package database and doing a nice clean install but without having to > recompile > >> everything and with ability to easily revert back and change between > projects. > > > > Hellno works by keeping all the compiled packages to itself in a > > database, so that when you ask it to bring in the dependencies of a > > project, it will use the precompiled packages if available or install > > the deps and save them for later reuse. > > > > Hellno puts symlinks in the user package database pointing to packages > > in its storage to make them visible. Mutating the user db is hardly > > elegant, although shouldn't result in much trouble. > > > > It's been working fine for me, so I figured it may be useful to others. > > You can get hellno from GitHub: > > https://github.com/db81/hellno > > > > I don't mean to say that sandboxing is inherently bad or should not be > > used, but I guess it's better to consider more than one way. > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cdsmith at gmail.com Sun Sep 2 22:22:01 2012 From: cdsmith at gmail.com (Chris Smith) Date: Sun, 2 Sep 2012 13:22:01 -0700 Subject: [Haskell-cafe] Over general types are too easy to make. In-Reply-To: References: <5043314E.4000206@dockerz.net> Message-ID: On Sun, Sep 2, 2012 at 9:40 AM, wrote: > The thing is, that one ALWAYS wants to create a union of types, and not > merely an ad-hock list of data declarations. So why does it take more code > to do "the right thing(tm)" than to do "the wrong thing(r)"? You've said this a few times, that you run into this constantly, or even that everyone runs into this. But I don't think that's the case. It's something that happens sometimes, yes, but if you're running into this issue for every data type that you declare, that is certainly NOT just normal in Haskell programming. So in that sense, many of the answers you've gotten - to use a GADT, in particular - might be great advice in the small subset of cases where average Haskell programmers want more complex constraints on types; but it's certainly not a good idea to do to every data type in your application. I don't have the answer for you about why this always happens to you, but it's clear that there's something there - perhaps a stylistic issue, or a domain-specific pattern, or something... - that's causing you to face this a lot more frequently than others do. If I had to take a guess, I'd say that you're breaking things down into fairly complex monolithic parts, where a lot of Haskell programmers will have a tendency to work with simpler types and break things down into smaller pieces. But... who knows... I haven't seen the many cases where this has happened to you. -- Chris From timothyhobbs at seznam.cz Sun Sep 2 23:57:28 2012 From: timothyhobbs at seznam.cz (timothyhobbs at seznam.cz) Date: Sun, 02 Sep 2012 23:57:28 +0200 (CEST) Subject: [Haskell-cafe] Over general types are too easy to make. References: <5043314E.4000206@dockerz.net> Message-ID: Looks like I failed to reply all ---------- P?vodn? zpr?va ---------- Od: timothyhobbs at seznam.cz Datum: 2. 9. 2012 P?edm?t: Re: Re: [Haskell-cafe] Over general types are too easy to make. " Care to link me to a code repository that doesn't have this problem? The only Haskell program that I have in my github that hasn't suffered this doesn't actually have any data declarations in it. Sure, if you're using data as a Boolean/Ternian replacement you won't have a trouble. But any multi record data constructor should be it's own type. I was going to go try and find an example from GHC, but you said that you think this problem is domain specific, and it's true that all of my work has had to do with code parsing/generation. So I went to look in darcs... Even with the shallow types of darcs we can still find examples of this problem: http://hackage.haskell.org/packages/archive/darcs/2.8.1/doc/html/src/Darcs- Match.html (http://hackage.haskell.org/packages/archive/darcs/2.8.1/doc/html/src/Darcs-Match.html) take a look at the function nonrangeMatcher, specifically OneTag, OneMatch, SeveralPatch... You can inspect the data declaration for DarcsFlag here http://hackage.haskell.org/packages/archive/darcs/2.8.1/doc/html/src/Darcs- Flags.html ... Now ask yourself, what are the types for tagmatch and mymatch. They take Strings as arguments. Obviously they are typed incorrectly. tagmatch SHOULD have the type :: OneTag -> Matcher p. and mymatch SHOULD have the type PatchU -> Matcher p where data PatchU = OnePatchU OnePatch | SeveralPatchU SeveralPatch... But we can't just easily go and change the types. Because unfortunately GADT data declarations are not used here. You've probably come across this many times. You just never realized it, because it's a case of GHC letting you do something you shouldn't be doing, rather than GHC stopping you from doing something you wish to. Timothy ---------- P?vodn? zpr?va ---------- Od: Chris Smith Datum: 2. 9. 2012 P?edm?t: Re: [Haskell-cafe] Over general types are too easy to make. "On Sun, Sep 2, 2012 at 9:40 AM, wrote: > The thing is, that one ALWAYS wants to create a union of types, and not > merely an ad-hock list of data declarations. So why does it take more code > to do "the right thing(tm)" than to do "the wrong thing(r)"? You've said this a few times, that you run into this constantly, or even that everyone runs into this. But I don't think that's the case. It's something that happens sometimes, yes, but if you're running into this issue for every data type that you declare, that is certainly NOT just normal in Haskell programming. So in that sense, many of the answers you've gotten - to use a GADT, in particular - might be great advice in the small subset of cases where average Haskell programmers want more complex constraints on types; but it's certainly not a good idea to do to every data type in your application. I don't have the answer for you about why this always happens to you, but it's clear that there's something there - perhaps a stylistic issue, or a domain-specific pattern, or something... - that's causing you to face this a lot more frequently than others do. If I had to take a guess, I'd say that you're breaking things down into fairly complex monolithic parts, where a lot of Haskell programmers will have a tendency to work with simpler types and break things down into smaller pieces. But... who knows... I haven't seen the many cases where this has happened to you. -- Chris" " -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.feuer at gmail.com Mon Sep 3 01:02:30 2012 From: david.feuer at gmail.com (David Feuer) Date: Sun, 2 Sep 2012 19:02:30 -0400 Subject: [Haskell-cafe] hstats median algorithm In-Reply-To: <5042B392.5030401@gmail.com> References: <5042B392.5030401@gmail.com> Message-ID: I was thinking it should offer a randomized version (taking a generator), since randomized median algorithms provide the best expected performance. It could also offer a deterministic version using some variant of median-of-medians, intended for long lists. I guess it probably should retain the naive version for short lists. Some benchmarking would suggest a good cutoff. Has anyone come up with a better practical deterministic O(n) algorithm since median-of-medians? I saw a paper by Dorit Dor on reducing the number of comparisons to a bit under 3n, which also showed a lower bound of a bit over 2n, but the algorithm she gives strikes me as far too complex to be practical. On Sep 1, 2012 9:17 PM, "Gershom Bazerman" wrote: > In my experience, doing much better than the naive algorithm for median is > surprisingly hard, and involves a choice from a range of trade-offs. Did > you have a particular better algorithm in mind? > > If you did, you could write it, and contact the package author with a > patch. > > You also may be able to find something of use in Edward Kmett's > order-statistics package: http://hackage.haskell.org/** > package/order-statistics > > Cheers, > Gershom > > On 9/1/12 3:26 PM, David Feuer wrote: > >> The median function in the hstats package uses a naive O(n log n) >> algorithm. Is there another package providing an O(n) option? If not, >> what would it take to get the package upgraded? >> >> ______________________________**_________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/**mailman/listinfo/haskell-cafe >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timothyhobbs at seznam.cz Mon Sep 3 03:00:22 2012 From: timothyhobbs at seznam.cz (timothyhobbs at seznam.cz) Date: Mon, 03 Sep 2012 03:00:22 +0200 (CEST) Subject: [Haskell-cafe] hstats median algorithm References: <5042B392.5030401@gmail.com> Message-ID: It really depends on how you are reading in the data and what you plan to do with it besides taking the median.? Obviously, if you read in your data as an ordered list things can be done O(n) without any trouble. In another case, if you already know the range, you can make a hash table and start at the middle bucket and move outwards.? That will be O(n) + O (bucketsize log(bucketsize)) given that the middle bucket is non empty and I'm not horribly mistaken.? Tim ---------- P?vodn? zpr?va ---------- Od: David Feuer Datum: 3. 9. 2012 P?edm?t: Re: [Haskell-cafe] hstats median algorithm " I was thinking it should offer a randomized version (taking a generator), since randomized median algorithms provide the best expected performance. It could also offer a deterministic version using some variant of median-of- medians, intended for long lists. I guess it probably should retain the naive version for short lists. Some benchmarking would suggest a good cutoff. Has anyone come up with a better practical deterministic O(n) algorithm since median-of-medians? I saw a paper by Dorit Dor on reducing the number of comparisons to a bit under 3n, which also showed a lower bound of a bit over 2n, but the algorithm she gives strikes me as far too complex to be practical. On Sep 1, 2012 9:17 PM, "Gershom Bazerman" wrote: " In my experience, doing much better than the naive algorithm for median is surprisingly hard, and involves a choice from a range of trade-offs. Did you have a particular better algorithm in mind? If you did, you could write it, and contact the package author with a patch. You also may be able to find something of use in Edward Kmett's order- statistics package: http://hackage.haskell.org/package/order-statistics (http://hackage.haskell.org/package/order-statistics) Cheers, Gershom On 9/1/12 3:26 PM, David Feuer wrote: " The median function in the hstats package uses a naive O(n log n) algorithm. Is there another package providing an O(n) option? If not, what would it take to get the package upgraded? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe at haskell.org(mailto:Haskell-Cafe at haskell.org) http://www.haskell.org/mailman/listinfo/haskell-cafe (http://www.haskell.org/mailman/listinfo/haskell-cafe) " " " -------------- next part -------------- An HTML attachment was scrubbed... URL: From agentm at themactionfaction.com Mon Sep 3 03:01:11 2012 From: agentm at themactionfaction.com (A.M.) Date: Sun, 02 Sep 2012 21:01:11 -0400 Subject: [Haskell-cafe] Compiling a haskell project as a shared library and loading it in C/C++ In-Reply-To: References: Message-ID: <50440157.5020308@themactionfaction.com> On 09/01/2012 12:13 AM, Farid Neshat wrote: > So I'm trying to follow [this blog][1]. So I tried the code, couldn't > compile the haskell part, probably due to the fact the guide uses > version 6, but I have version 7 of ghc. By changing the paramaters I > could compile it with the following: > > ghc --make -dynamic -shared -fPIC -no-hs-main -optl '-shared' -optc > '-DMODULE=Test' -o Test.so Test.hs module_init.c You need to link against the haskell runtime: ghc --make -dynamic -shared -fPIC -no-hs-main -o X.so -optl-Wl,-rpath,/usr/lib/ghc/ -lHSrts_debug-ghc7.4.1 Cheers, M From timothyhobbs at seznam.cz Mon Sep 3 03:07:35 2012 From: timothyhobbs at seznam.cz (timothyhobbs at seznam.cz) Date: Mon, 03 Sep 2012 03:07:35 +0200 (CEST) Subject: [Haskell-cafe] hstats median algorithm References: <5042B392.5030401@gmail.com> Message-ID: Sorry, I am horribly mistaken.? Hash table is O(n)+O(numbuckets)+O (middlebucketsize log(middlebucketsize))...? It's too late for this stuff... Tim ---------- P?vodn? zpr?va ---------- Od: timothyhobbs at seznam.cz Datum: 3. 9. 2012 P?edm?t: Re: [Haskell-cafe] hstats median algorithm " It really depends on how you are reading in the data and what you plan to do with it besides taking the median.? Obviously, if you read in your data as an ordered list things can be done O(n) without any trouble. In another case, if you already know the range, you can make a hash table and start at the middle bucket and move outwards.? That will be O(n) + O (bucketsize log(bucketsize)) given that the middle bucket is non empty and I'm not horribly mistaken.? Tim ---------- P?vodn? zpr?va ---------- Od: David Feuer Datum: 3. 9. 2012 P?edm?t: Re: [Haskell-cafe] hstats median algorithm " I was thinking it should offer a randomized version (taking a generator), since randomized median algorithms provide the best expected performance. It could also offer a deterministic version using some variant of median-of- medians, intended for long lists. I guess it probably should retain the naive version for short lists. Some benchmarking would suggest a good cutoff. Has anyone come up with a better practical deterministic O(n) algorithm since median-of-medians? I saw a paper by Dorit Dor on reducing the number of comparisons to a bit under 3n, which also showed a lower bound of a bit over 2n, but the algorithm she gives strikes me as far too complex to be practical. On Sep 1, 2012 9:17 PM, "Gershom Bazerman" wrote: " In my experience, doing much better than the naive algorithm for median is surprisingly hard, and involves a choice from a range of trade-offs. Did you have a particular better algorithm in mind? If you did, you could write it, and contact the package author with a patch. You also may be able to find something of use in Edward Kmett's order- statistics package: http://hackage.haskell.org/package/order-statistics (http://hackage.haskell.org/package/order-statistics) Cheers, Gershom On 9/1/12 3:26 PM, David Feuer wrote: " The median function in the hstats package uses a naive O(n log n) algorithm. Is there another package providing an O(n) option? If not, what would it take to get the package upgraded? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe at haskell.org(mailto:Haskell-Cafe at haskell.org) http://www.haskell.org/mailman/listinfo/haskell-cafe (http://www.haskell.org/mailman/listinfo/haskell-cafe) " " " " -------------- next part -------------- An HTML attachment was scrubbed... URL: From trivmanish at gmail.com Mon Sep 3 03:26:23 2012 From: trivmanish at gmail.com (Manish Trivedi) Date: Sun, 2 Sep 2012 18:26:23 -0700 Subject: [Haskell-cafe] Installation issues with Centos Message-ID: # uname -a Linux <> 2.6.32-220.2.1.el6.centos.plus.x86_64 #1 SMP Thu Dec 22 23:32:31 GMT 2011 x86_64 x86_64 x86_64 GNU/Linux # cat /proc/version Linux version 2.6.32-220.2.1.el6.centos.plus.x86_64 ( mockbuild at c6b18n3.bsys.dev.centos.org) (gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) ) #1 SMP Thu Dec 22 23:32:31 GMT 2011 I am trying to install Haskell framework on this server. - Installation for GHC went ok. no error - Installed ghc-7.4.1 from "ghc-7.4.1-x86_64-unknown-linux.tar" then while trying to install (in configure step) Haskell platform version 2012.2.0.0. I get following error: [root at qa-engine1 haskell-platform-2012.2.0.0]# ./configure ************************************************** * * Haskell Platform Source Installer * * For the Haskell Platform 2012.2.0.0 and GHC 7.4.1 * ************************************************** checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu checking for ghc... /usr/local/lib/ghc-7.4.1/ghc checking for ghc-pkg... /usr/local/lib/ghc-7.4.1/ghc-pkg checking for hsc2hs... /usr/local/lib/ghc-7.4.1/hsc2hs checking version of ghc... 7.4.1 checking version of ghc-pkg matches... yes checking ghc actually works... no configure: error: Your installation of ghc does not appear to work. It cannot compile a simple program (see config.log for the details). If you installed ghc from a generic binary tarball then it is worth checking that you have the 'gmp' C library and header files installed. (On Debian-based systems this package is called libgmp3-dev.) ==================================== I have made sure that libc and gmp are indeed installed. while trying use yum to make sure I have gmp installed. ==================================== [root at qa-engine1 haskell-platform-2012.2.0.0]# yum install gmp Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.stanford.edu * extras: centos.mirror.facebook.net * updates: mirror.stanford.edu Setting up Install Process Package gmp-4.3.1-7.el6_2.2.x86_64 already installed and latest version Nothing to do ======================================== Any help is appreciated. Btw, I could make haskell latest version work on my mac osx. -Manish -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Mon Sep 3 03:52:36 2012 From: allbery.b at gmail.com (Brandon Allbery) Date: Sun, 2 Sep 2012 21:52:36 -0400 Subject: [Haskell-cafe] Installation issues with Centos In-Reply-To: References: Message-ID: On Sun, Sep 2, 2012 at 9:26 PM, Manish Trivedi wrote: > [root at qa-engine1 haskell-platform-2012.2.0.0]# yum install gmp > This is just the runtime library; you will also need the compile/link-time library provided by gmp-devel. That said, the contents of the config.log mentioned in the error message would be helpful. -- brandon s allbery allbery.b at gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms -------------- next part -------------- An HTML attachment was scrubbed... URL: From trivmanish at gmail.com Mon Sep 3 04:49:55 2012 From: trivmanish at gmail.com (Manish Trivedi) Date: Sun, 2 Sep 2012 19:49:55 -0700 Subject: [Haskell-cafe] Installation issues with Centos In-Reply-To: References: Message-ID: Hi Brandon, Appreciate your reply. some more info. I just confirmed that gmp-devel is installed too. yum message shows "Package gmp-devel-4.3.1-7.el6_2.2.x86_64 already installed and latest version". I am attaching the config.log in the email. Thanks in advance! -Manish On Sun, Sep 2, 2012 at 6:52 PM, Brandon Allbery wrote: > On Sun, Sep 2, 2012 at 9:26 PM, Manish Trivedi wrote: > >> [root at qa-engine1 haskell-platform-2012.2.0.0]# yum install gmp >> > > This is just the runtime library; you will also need the compile/link-time > library provided by gmp-devel. That said, the contents of the config.log > mentioned in the error message would be helpful. > > -- > brandon s allbery allbery.b at gmail.com > wandering unix systems administrator (available) (412) 475-9364 vm/sms > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: config.log Type: application/octet-stream Size: 5077 bytes Desc: not available URL: From allbery.b at gmail.com Mon Sep 3 05:05:55 2012 From: allbery.b at gmail.com (Brandon Allbery) Date: Sun, 2 Sep 2012 23:05:55 -0400 Subject: [Haskell-cafe] Installation issues with Centos In-Reply-To: References: Message-ID: On Sun, Sep 2, 2012 at 10:49 PM, Manish Trivedi wrote: > I am attaching the config.log in the email. > You didn't install ghc properly, or you did and you then added its internal directory to your $PATH. The executables in /usr/local/lib/ghc-7.4.1 should not be run directly, as they require setup which is done by wrapper scripts that should be installed in /usr/local/bin if you installed it correctly. configure:2198: checking ghc actually works > > configure:2207: /usr/local/lib/ghc-7.4.1/ghc -o conftest conftest.hs > > ghc: missing -B option > > -- brandon s allbery allbery.b at gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms -------------- next part -------------- An HTML attachment was scrubbed... URL: From rwallace at thewallacepack.net Mon Sep 3 05:15:49 2012 From: rwallace at thewallacepack.net (Richard Wallace) Date: Sun, 2 Sep 2012 20:15:49 -0700 Subject: [Haskell-cafe] hellno - a somewhat different approach to tackling cabal hell In-Reply-To: <5043A484.2040804@gmail.com> References: <5043A484.2040804@gmail.com> Message-ID: I like the approach so far. But hellno itself seems to have several dependencies itself. So installing with cabal pulls these in as "fixed" libraries ("text", "mtl", "transformers", and "parsec"). Any plans to make these not have to be fixed? Or is there a trick I'm missing? On Sun, Sep 2, 2012 at 11:25 AM, Danny B wrote: > Like many of us, I've suffered from cabal dependency hell and sought relief. > > I wasn't exactly happy with sandboxes - because using per-project ones > meant package duplication and shared sandboxes suffer from the same > issues as the GHC package database itself, i.e. reinstalls can break > other projects, etc. So I wrote hellno, which is so named because that's > the expression one makes when seeing cabal hell suddenly manifest itself > and that's also the expression one makes upon encountering yet ANOTHER > cabal wrapper. > > To quote the README: >> Generally, with hellno you'll get the same result as for blowing away your user >> package database and doing a nice clean install but without having to recompile >> everything and with ability to easily revert back and change between projects. > > Hellno works by keeping all the compiled packages to itself in a > database, so that when you ask it to bring in the dependencies of a > project, it will use the precompiled packages if available or install > the deps and save them for later reuse. > > Hellno puts symlinks in the user package database pointing to packages > in its storage to make them visible. Mutating the user db is hardly > elegant, although shouldn't result in much trouble. > > It's been working fine for me, so I figured it may be useful to others. > You can get hellno from GitHub: > https://github.com/db81/hellno > > I don't mean to say that sandboxing is inherently bad or should not be > used, but I guess it's better to consider more than one way. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From carter.schonwald at gmail.com Mon Sep 3 05:50:30 2012 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Sun, 2 Sep 2012 23:50:30 -0400 Subject: [Haskell-cafe] hellno - a somewhat different approach to tackling cabal hell In-Reply-To: References: <5043A484.2040804@gmail.com> Message-ID: perhaps the *right* solution is to view that as a bootstrap build, and then have hellno build itself? :) That said, its also an executable rather than library, so its not quite the same problem. On Sun, Sep 2, 2012 at 11:15 PM, Richard Wallace < rwallace at thewallacepack.net> wrote: > I like the approach so far. But hellno itself seems to have several > dependencies itself. So installing with cabal pulls these in as > "fixed" libraries ("text", "mtl", "transformers", and "parsec"). Any > plans to make these not have to be fixed? Or is there a trick I'm > missing? > > On Sun, Sep 2, 2012 at 11:25 AM, Danny B wrote: > > Like many of us, I've suffered from cabal dependency hell and sought > relief. > > > > I wasn't exactly happy with sandboxes - because using per-project ones > > meant package duplication and shared sandboxes suffer from the same > > issues as the GHC package database itself, i.e. reinstalls can break > > other projects, etc. So I wrote hellno, which is so named because that's > > the expression one makes when seeing cabal hell suddenly manifest itself > > and that's also the expression one makes upon encountering yet ANOTHER > > cabal wrapper. > > > > To quote the README: > >> Generally, with hellno you'll get the same result as for blowing away > your user > >> package database and doing a nice clean install but without having to > recompile > >> everything and with ability to easily revert back and change between > projects. > > > > Hellno works by keeping all the compiled packages to itself in a > > database, so that when you ask it to bring in the dependencies of a > > project, it will use the precompiled packages if available or install > > the deps and save them for later reuse. > > > > Hellno puts symlinks in the user package database pointing to packages > > in its storage to make them visible. Mutating the user db is hardly > > elegant, although shouldn't result in much trouble. > > > > It's been working fine for me, so I figured it may be useful to others. > > You can get hellno from GitHub: > > https://github.com/db81/hellno > > > > I don't mean to say that sandboxing is inherently bad or should not be > > used, but I guess it's better to consider more than one way. > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From chrisyco+haskell-cafe at gmail.com Mon Sep 3 06:03:03 2012 From: chrisyco+haskell-cafe at gmail.com (Chris Wong) Date: Mon, 3 Sep 2012 16:03:03 +1200 Subject: [Haskell-cafe] hellno - a somewhat different approach to tackling cabal hell In-Reply-To: References: <5043A484.2040804@gmail.com> Message-ID: On Mon, Sep 3, 2012 at 3:15 PM, Richard Wallace wrote: > I like the approach so far. But hellno itself seems to have several > dependencies itself. So installing with cabal pulls these in as > "fixed" libraries ("text", "mtl", "transformers", and "parsec"). Any > plans to make these not have to be fixed? Or is there a trick I'm > missing? All of those libraries are included in the Haskell Platform anyway. The majority of users shouldn't need to install extra packages to get it to work. > On Sun, Sep 2, 2012 at 11:25 AM, Danny B wrote: >> Like many of us, I've suffered from cabal dependency hell and sought relief. >> >> I wasn't exactly happy with sandboxes - because using per-project ones >> meant package duplication and shared sandboxes suffer from the same >> issues as the GHC package database itself, i.e. reinstalls can break >> other projects, etc. So I wrote hellno, which is so named because that's >> the expression one makes when seeing cabal hell suddenly manifest itself >> and that's also the expression one makes upon encountering yet ANOTHER >> cabal wrapper. >> >> To quote the README: >>> Generally, with hellno you'll get the same result as for blowing away your user >>> package database and doing a nice clean install but without having to recompile >>> everything and with ability to easily revert back and change between projects. >> >> Hellno works by keeping all the compiled packages to itself in a >> database, so that when you ask it to bring in the dependencies of a >> project, it will use the precompiled packages if available or install >> the deps and save them for later reuse. >> >> Hellno puts symlinks in the user package database pointing to packages >> in its storage to make them visible. Mutating the user db is hardly >> elegant, although shouldn't result in much trouble. >> >> It's been working fine for me, so I figured it may be useful to others. >> You can get hellno from GitHub: >> https://github.com/db81/hellno >> >> I don't mean to say that sandboxing is inherently bad or should not be >> used, but I guess it's better to consider more than one way. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From chris at chrisdornan.com Mon Sep 3 09:54:28 2012 From: chris at chrisdornan.com (Chris Dornan) Date: Mon, 3 Sep 2012 08:54:28 +0100 Subject: [Haskell-cafe] Installation issues with Centos In-Reply-To: References: Message-ID: <0a6f01cd89a9$5915c650$0b4152f0$@chrisdornan.com> Hi Manish, Are you aware of the CentOS distro I am maintaining at justhub.org /download? Even if you want to build your own installations it will probably be useful for getting you going. (It should soon appear on the Haskell Platform Linux page - or at least we have a ticket for it!) Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: From trivmanish at gmail.com Mon Sep 3 11:57:34 2012 From: trivmanish at gmail.com (Manish Trivedi) Date: Mon, 3 Sep 2012 02:57:34 -0700 Subject: [Haskell-cafe] Installation issues with Centos In-Reply-To: <0a6f01cd89a9$5915c650$0b4152f0$@chrisdornan.com> References: <0a6f01cd89a9$5915c650$0b4152f0$@chrisdornan.com> Message-ID: Thank you Chris! extremely delighted. worked like a charm. I wish your distro appear on haskell wiki. very helpful. regards, manish On Mon, Sep 3, 2012 at 12:54 AM, Chris Dornan wrote: > Hi Manish,**** > > ** ** > > Are you aware of the CentOS distro I am maintaining at justhub.org/download? Even if you want to build your own installations it will > probably be useful for getting you going.**** > > ** ** > > (It should soon appear on the Haskell Platform Linux page ? or at least we > have a ticket for it!)**** > > ** ** > > Chris**** > > ** ** > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roma at ro-che.info Mon Sep 3 12:00:36 2012 From: roma at ro-che.info (Roman Cheplyaka) Date: Mon, 3 Sep 2012 13:00:36 +0300 Subject: [Haskell-cafe] SYB with class: Bug in Derive.hs module Message-ID: <20120903100036.GA20546@sniper> There's a bug in syb-with-class reported by Alexey Rodriguez Yakushev in 2008 [1]. I can confirm that the bug is still there (syb-with-class-0.6.1.3, ghc 7.4.1). [1]: http://www.haskell.org/pipermail/haskell-cafe/2008-March/041179.html Here's an even simpler test case: {-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, UndecidableInstances, TemplateHaskell, OverlappingInstances, DeriveDataTypeable #-} import Data.Generics.SYB.WithClass.Basics import Data.Generics.SYB.WithClass.Derive data Foo = Foo Foo | Bar deriving (Typeable, Show) deriveData [''Foo] f :: (Data NoCtx ast, Typeable ast) => ast -> TypeRep f = typeOf main = print $ f $ Foo Bar The cause of this bug is a self-referencing instance created by deriveData: instance (Data ctx Foo, Sat (ctx Foo)) => Data ctx Foo where ... What's the proper way to fix it? -- Roman I. Cheplyaka :: http://ro-che.info/ From jims at stuttard.org Mon Sep 3 12:34:04 2012 From: jims at stuttard.org (jims at stuttard.org) Date: Mon, 03 Sep 2012 04:34:04 -0600 Subject: [Haskell-cafe] Installation issues with Centos In-Reply-To: <0a6f01cd89a9$5915c650$0b4152f0$@chrisdornan.com> References: <0a6f01cd89a9$5915c650$0b4152f0$@chrisdornan.com> Message-ID: <20120903043404.91567hfyqc4uk5ng@stuttard.org> Quoting Chris Dornan : > Hi Manish, > > Are you aware of the CentOS distro I am maintaining at justhub.org > /download? Even if you want to build your own installations it will probably > be useful for getting you going. Great and spot on time for me. I'm trying to install Snap on my Centos-6.0 ISP (bluehost.com) which has shell but not root access and no OpenGL or GLUT. HP has (IMHO wrongly) included OpenGL and GLUT so I've cut the gl and glut sections from the HP configure script and platform.packages list with a variety of build failures so far. Previously I've been able to install and use ghc and HP in ~/ without problems. Is there any reason why this couldn't be done with your justhub package? As I've never tried this brute surgery on such a magnus opus before I'm not sure this is at all feasible? I hope this isn't too off topic. Cheers > > (It should soon appear on the Haskell Platform Linux page - or at least we > have a ticket for it!) > > Chris > > From sanzhiyan at gmail.com Mon Sep 3 12:50:03 2012 From: sanzhiyan at gmail.com (Andrea Vezzosi) Date: Mon, 3 Sep 2012 12:50:03 +0200 Subject: [Haskell-cafe] SYB with class: Bug in Derive.hs module In-Reply-To: <20120903100036.GA20546@sniper> References: <20120903100036.GA20546@sniper> Message-ID: On Mon, Sep 3, 2012 at 12:00 PM, Roman Cheplyaka wrote: > There's a bug in syb-with-class reported by Alexey Rodriguez Yakushev in > 2008 [1]. I can confirm that the bug is still there (syb-with-class-0.6.1.3, > ghc 7.4.1). > > [1]: http://www.haskell.org/pipermail/haskell-cafe/2008-March/041179.html > > Here's an even simpler test case: > > {-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, > UndecidableInstances, TemplateHaskell, OverlappingInstances, > DeriveDataTypeable #-} > import Data.Generics.SYB.WithClass.Basics > import Data.Generics.SYB.WithClass.Derive > > data Foo = Foo Foo | Bar > deriving (Typeable, Show) > > deriveData [''Foo] > > f :: (Data NoCtx ast, Typeable ast) => ast -> TypeRep > f = typeOf > > main = print $ f $ Foo Bar This is pretty similar to what ended up being a ghc bug, fixed in 7.0 though: http://hackage.haskell.org/trac/ghc/ticket/3731 > The cause of this bug is a self-referencing instance created by > deriveData: > > instance (Data ctx Foo, Sat (ctx Foo)) => Data ctx Foo where ... > > What's the proper way to fix it? From hjgtuyl at chello.nl Mon Sep 3 13:09:15 2012 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Mon, 03 Sep 2012 13:09:15 +0200 Subject: [Haskell-cafe] Installation issues with Centos In-Reply-To: References: <0a6f01cd89a9$5915c650$0b4152f0$@chrisdornan.com> Message-ID: On Mon, 03 Sep 2012 11:57:34 +0200, Manish Trivedi wrote: > Thank you Chris! extremely delighted. worked like a charm. > I wish your distro appear on haskell wiki. very helpful. I just added this to the Linux page[0]. Regards, Henk-Jan van Tuyl [0] http://www.haskell.org/haskellwiki/GNU/Linux#RHEL.2C_CentOS.2C_Scientific_Linux_5_and_6_and_Fedora_16_and_17 -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming -- From chris at chrisdornan.com Mon Sep 3 14:12:34 2012 From: chris at chrisdornan.com (Chris Dornan) Date: Mon, 3 Sep 2012 13:12:34 +0100 Subject: [Haskell-cafe] Installation issues with Centos In-Reply-To: <20120903043404.91567hfyqc4uk5ng@stuttard.org> References: <0a6f01cd89a9$5915c650$0b4152f0$@chrisdornan.com> <20120903043404.91567hfyqc4uk5ng@stuttard.org> Message-ID: <0a9d01cd89cd$67ee64b0$37cb2e10$@chrisdornan.com> Hi Jim, > Previously I've been able to install and use ghc and HP in ~/ without problems. Is there any reason > why this couldn't be done with your justhub package? > > As I've never tried this brute surgery on such a magnus opus before I'm not sure this is at all feasible? I wouldn't recommend trying to install the justhub package in user-space. Starting from the GHC bindists and the sources for everything else (platform and hub wrapper) you can relocate everything of course. In theory I believe it would also be possible to make all the RPMs relocatable, but because of all of the moving parts it's not so easy in practice. It is on my list of things to do -- obviously the more requests I get the higher it will go on the priority list, and the number of requests has now just doubled, to two (but I will bet there are more -- I take it seriously). Chris From chris at chrisdornan.com Mon Sep 3 14:19:47 2012 From: chris at chrisdornan.com (Chris Dornan) Date: Mon, 3 Sep 2012 13:19:47 +0100 Subject: [Haskell-cafe] Installation issues with Centos In-Reply-To: References: <0a6f01cd89a9$5915c650$0b4152f0$@chrisdornan.com> Message-ID: <0a9e01cd89ce$699604c0$3cc20e40$@chrisdornan.com> Thanks Henk! > I just added this to the Linux page[0]. The action on that HP ticket was to put a link here, http://hackage.haskell.org/platform/linux.html, which should happen by the next platform release. Chris From roma at ro-che.info Mon Sep 3 14:53:45 2012 From: roma at ro-che.info (Roman Cheplyaka) Date: Mon, 3 Sep 2012 15:53:45 +0300 Subject: [Haskell-cafe] SYB with class: Bug in Derive.hs module In-Reply-To: References: <20120903100036.GA20546@sniper> Message-ID: <20120903125345.GA22188@sniper> * Andrea Vezzosi [2012-09-03 12:50:03+0200] > On Mon, Sep 3, 2012 at 12:00 PM, Roman Cheplyaka wrote: > > There's a bug in syb-with-class reported by Alexey Rodriguez Yakushev in > > 2008 [1]. I can confirm that the bug is still there (syb-with-class-0.6.1.3, > > ghc 7.4.1). > > > > [1]: http://www.haskell.org/pipermail/haskell-cafe/2008-March/041179.html > > > > Here's an even simpler test case: > > > > {-# LANGUAGE FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, > > UndecidableInstances, TemplateHaskell, OverlappingInstances, > > DeriveDataTypeable #-} > > import Data.Generics.SYB.WithClass.Basics > > import Data.Generics.SYB.WithClass.Derive > > > > data Foo = Foo Foo | Bar > > deriving (Typeable, Show) > > > > deriveData [''Foo] > > > > f :: (Data NoCtx ast, Typeable ast) => ast -> TypeRep > > f = typeOf > > > > main = print $ f $ Foo Bar > > This is pretty similar to what ended up being a ghc bug, fixed in 7.0 though: > http://hackage.haskell.org/trac/ghc/ticket/3731 The difference between my test case and the one attached to the ticket is that here there's an explicitly circular instance generated by TH. In the "SYB with class" paper it is specifically said to be broken. So it looks more like a problem in the TH code rather than in GHC. > > The cause of this bug is a self-referencing instance created by > > deriveData: > > > > instance (Data ctx Foo, Sat (ctx Foo)) => Data ctx Foo where ... > > > > What's the proper way to fix it? > > From a few tests it seems we no longer need the circular context hack > in ghc-7.4.1 to get the instance to typecheck, so we could side-step > the issue entirely by removing it from the generated code. Not sure what hack you're referring to. As I understand it, the circular context arises as a special case of the context that includes all the "inner" types of a data type. It's not possible to get rid of this context entirely ? for example, consider data X a = X (Y a) where we really need the "Data ctx (Y a)" context (but perhaps it could be "Data ctx a" instead?). So we need some criterion to decide whether a structural part of a data type should be included into the instance context. Does this make sense, or am I on the completely wrong track? -- Roman I. Cheplyaka :: http://ro-che.info/ From timothyhobbs at seznam.cz Mon Sep 3 14:57:53 2012 From: timothyhobbs at seznam.cz (timothyhobbs at seznam.cz) Date: Mon, 03 Sep 2012 14:57:53 +0200 (CEST) Subject: [Haskell-cafe] hstats median algorithm References: <5042B392.5030401@gmail.com> Message-ID: So I've been playing with the median problem today.? Not sure why, but it stuck in my head. >import Data.List >import Control.Monad.ST >import Data.STRef >import Control.Monad I've been using the hashing algorithm that I described last night, but it's quite slow.? I must be missing something obvious.? It really shouldn't be slow at all! So I have a median function: >median First I assume you know the range of your data. > (min,max) Then I ask you to figure out how many buckets you want to create, and which of those buckets you actually want to fill.? You should only fill the buckets near the middle, based on an educated guess of the distribution of your data, otherwise, you will end up wasting memory.? I you guessed the middle correctly, you will get back (Just median) otherwise, you will get back Nothing. > numBuckets guessedMiddle Then you are to pass it your list. > list = > let First I seperate out the values into a list of buckets, each one holding values which are near to eachother.? I can figure out the length of the list at the same time, since I have to go through the whole thing anyways. >? (myBuckets,length) = >?? buckets >??? (min,max) >??? numBuckets >??? guessedMiddle >??? list The buckets are set up, so that the first bucket has the lowest values, and the last bucket has the highest values. Each bucket, is a tuple, of it's length and it's contents.? We fold across the list of buckets, accumulating the "index so far", until we find the bucket in which the median must reside. >? Right (medianBucket,stubLen) = >?? foldr >??? (\thisBucket@(thisBucketLen,_) eitheriOrMedianBucket -> >???? case eitheriOrMedianBucket of >????? Left i -> >?????? if i + thisBucketLen > (length `div` 2) >??????? then Right (thisBucket, thisBucketLen-((length `div` 2) - i)) >??????? else Left (i + thisBucketLen) >????? _ -> eitheriOrMedianBucket) >??? (Left 0) >??? myBuckets > in We then sort the bucket in which the median must reside, and we then find the median the normal way.? This should be faster, since we only had to sort one bucket, rather than the entire list.? It is not, so there must be something horrible going on. >? case snd medianBucket of >?? Just medianBucket' -> >??? Just (sort medianBucket' `genericIndex` stubLen) >?? Nothing -> Nothing Here is my actual function for seperating the values out into buckets. >buckets > (min,max) > numBuckets > (guessedMiddleStart,guessedMiddleEnd) > list = > runST $ do >? lengthRef <- newSTRef 0 First we create a list of empty buckets.? Since it would be a waste of memory to actually fill the buckets near the edges of our distribution(where we are not likely to find our median), our buckets contain Maybe lists, and the buckets which are outside of our guessed bucket range will be filled with Nothing. >? buckets' <- mapM >?????????????? (\n-> >???????????????? newSTRef >?????????????????? (0, >??????????????????? if n >= guessedMiddleStart && n <= guessedMiddleEnd >????????????????????? then Just [] >????????????????????? else Nothing)) >?????????????? [0..numBuckets] Then we go through the buckets, figuring out which bucket to put a given value into.? We calculate the length at the same time. >? forM_ list $ \number -> do >??? let Figure out which bucket to put this into. >???? bucket = >????? whichBucket >?????? (min,max) >?????? numBuckets >?????? number Increment length. >??? modifySTRef >???? lengthRef >???? (+1) Put the value into the appropriate bucket. >??? modifySTRef >???? (buckets' `genericIndex` bucket) --Obvious optimization, use an array and not a list. >???? (\(oldLen,oldListMaybe)-> >?????? case oldListMaybe of >??????? Just oldList -> >???????? (oldLen+1,Just (number:oldList)) >??????? Nothing -> (oldLen + 1, Nothing)) >? filledBuckets <- mapM readSTRef buckets' >? length <- readSTRef lengthRef >? return (filledBuckets,length) >whichBucket (min,max) numBuckets number = > (number - min) >??? `div` >? ((max - min) `div` numBuckets) So I created a little test scenario. >someListNumBuckets = 100 >someListGuessedMiddle = (45,55) >someListLength = genericLength someList And found that this: >realMedian = sort someList `genericIndex` (someListLength `div` 2) Is actually faster ^_^ :O *Main> realMedian 500 (7.18 secs, 2031543472 bytes) Than this: >someListMedian = > median >? (someListMin,someListMax) >? someListNumBuckets >? someListGuessedMiddle >? someList *Main> someListMedian Just 500 (37.77 secs, 15376209200 bytes) >someListMin :: Integer >someListMin = 0 >someListMax :: Integer >someListMax = 1000 >someList :: [Integer] >someList = > concatMap >? (\n->intersperse n [someListMin..someListMax]) >? [someListMax,someListMax-1..someListMin] ---------- P?vodn? zpr?va ---------- Od: timothyhobbs at seznam.cz Datum: 3. 9. 2012 P?edm?t: Re: [Haskell-cafe] hstats median algorithm " It really depends on how you are reading in the data and what you plan to do with it besides taking the median.? Obviously, if you read in your data as an ordered list things can be done O(n) without any trouble. In another case, if you already know the range, you can make a hash table and start at the middle bucket and move outwards.? That will be O(n) + O (bucketsize log(bucketsize)) given that the middle bucket is non empty and I'm not horribly mistaken.? Tim ---------- P?vodn? zpr?va ---------- Od: David Feuer Datum: 3. 9. 2012 P?edm?t: Re: [Haskell-cafe] hstats median algorithm " I was thinking it should offer a randomized version (taking a generator), since randomized median algorithms provide the best expected performance. It could also offer a deterministic version using some variant of median-of- medians, intended for long lists. I guess it probably should retain the naive version for short lists. Some benchmarking would suggest a good cutoff. Has anyone come up with a better practical deterministic O(n) algorithm since median-of-medians? I saw a paper by Dorit Dor on reducing the number of comparisons to a bit under 3n, which also showed a lower bound of a bit over 2n, but the algorithm she gives strikes me as far too complex to be practical. On Sep 1, 2012 9:17 PM, "Gershom Bazerman" wrote: " In my experience, doing much better than the naive algorithm for median is surprisingly hard, and involves a choice from a range of trade-offs. Did you have a particular better algorithm in mind? If you did, you could write it, and contact the package author with a patch. You also may be able to find something of use in Edward Kmett's order- statistics package: http://hackage.haskell.org/package/order-statistics (http://hackage.haskell.org/package/order-statistics) Cheers, Gershom On 9/1/12 3:26 PM, David Feuer wrote: " The median function in the hstats package uses a naive O(n log n) algorithm. Is there another package providing an O(n) option? If not, what would it take to get the package upgraded? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe at haskell.org(mailto:Haskell-Cafe at haskell.org) http://www.haskell.org/mailman/listinfo/haskell-cafe (http://www.haskell.org/mailman/listinfo/haskell-cafe) " " " " -------------- next part -------------- An HTML attachment was scrubbed... URL: From jims at stuttard.org Mon Sep 3 16:01:05 2012 From: jims at stuttard.org (jims at stuttard.org) Date: Mon, 03 Sep 2012 08:01:05 -0600 Subject: [Haskell-cafe] Installation issues with Centos In-Reply-To: <0a9d01cd89cd$67ee64b0$37cb2e10$@chrisdornan.com> References: <0a6f01cd89a9$5915c650$0b4152f0$@chrisdornan.com> <20120903043404.91567hfyqc4uk5ng@stuttard.org> <0a9d01cd89cd$67ee64b0$37cb2e10$@chrisdornan.com> Message-ID: <20120903080105.16459z0i8mj8sdnl@stuttard.org> Quoting Chris Dornan : > Hi Jim, Thanks for such a quick response. >> Previously I've been able to install and use ghc and HP in ~/ without > problems. Is there any reason >> why this couldn't be done with your justhub package? >> >> As I've never tried this brute surgery on such a magnus opus before I'm > not sure this is at all feasible? > > I wouldn't recommend trying to install the justhub package in user-space. > > Starting from the GHC bindists and the sources for everything else (platform > and hub wrapper) you can relocate everything of course. In theory I believe > it would also be possible to make all the RPMs relocatable, but because of > all of the moving parts it's not so easy in practice. Sure. Too scary for me. However sandboxing everything ghc in user space seems to me a good idea at the moment. > > It is on my list of things to do -- obviously the more requests I get the > higher it will go on the priority list, and the number of requests has now > just doubled, to two (but I will bet there are more -- I take it seriously). BTW my ISP doesn't allow the use of yum. I can build a Snap server by manually installing the needed deps from HP but it silently crashes every couple of hours and I failed to build it with library-profiling. I'd like to get Snap working on this ISP as it's for a voluntary environmental science group and previous Snap installations on my home machine have seemingly worked perfectly. Cheers > Chris > > > From felipe.lessa at gmail.com Mon Sep 3 16:18:30 2012 From: felipe.lessa at gmail.com (Felipe Almeida Lessa) Date: Mon, 3 Sep 2012 11:18:30 -0300 Subject: [Haskell-cafe] hstats median algorithm In-Reply-To: References: <5042B392.5030401@gmail.com> Message-ID: Some comments wrt. performance: On Mon, Sep 3, 2012 at 9:57 AM, wrote: >> Right (medianBucket,stubLen) = >> foldr >> (\thisBucket@(thisBucketLen,_) eitheriOrMedianBucket -> >> case eitheriOrMedianBucket of >> Left i -> >> if i + thisBucketLen > (length `div` 2) >> then Right (thisBucket, thisBucketLen-((length `div` 2) - i)) >> else Left (i + thisBucketLen) >> _ -> eitheriOrMedianBucket) >> (Left 0) >> myBuckets Use a let to store length `div` 2, GHC probably won't do this for you automatically. Ditto for i + thisBucketLen. >> buckets' <- mapM >> (\n-> >> newSTRef >> (0, >> if n >= guessedMiddleStart && n <= guessedMiddleEnd >> then Just [] >> else Nothing)) >> [0..numBuckets] You should really use a mutable array here instead of a list of STRefs (I recommend vector's STVector [1]). [1] http://hackage.haskell.org/packages/archive/vector/0.9.1/doc/html/Data-Vector-Mutable.html > Increment length. > >> modifySTRef >> lengthRef >> (+1) This will create a big thunk for the length, you should use oldLength <- readSTRef lengthRef writeSTRef lengthRef $! oldLength + 1 (I'm not sure if a strict modifySTRef exists somewhere...) > Put the value into the appropriate bucket. > >> modifySTRef >> (buckets' `genericIndex` bucket) --Obvious optimization, use an array >> and not a list. >> (\(oldLen,oldListMaybe)-> >> case oldListMaybe of >> Just oldList -> >> (oldLen+1,Just (number:oldList)) >> Nothing -> (oldLen + 1, Nothing)) Ditto for oldLen here. Also, you can simplify this lambda a lot: import Control.Applicative ((<$>)) \(oldLen, oldVal) -> let newLen = oldLen + 1 newVal = (number:) <$> oldVal in newLen `seq` newVal `seq` (newLen, newVal) HTH! Cheers, -- Felipe. From felipe.lessa at gmail.com Mon Sep 3 16:19:22 2012 From: felipe.lessa at gmail.com (Felipe Almeida Lessa) Date: Mon, 3 Sep 2012 11:19:22 -0300 Subject: [Haskell-cafe] hstats median algorithm In-Reply-To: References: <5042B392.5030401@gmail.com> Message-ID: On Mon, Sep 3, 2012 at 11:18 AM, Felipe Almeida Lessa wrote: > Ditto for oldLen here. Also, you can simplify this lambda a lot: > > import Control.Applicative ((<$>)) > > \(oldLen, oldVal) -> > let newLen = oldLen + 1 > newVal = (number:) <$> oldVal > in newLen `seq` newVal `seq` (newLen, newVal) Or, using BangPatterns, \(oldLen, oldVal) -> let !newLen = oldLen + 1 !newVal = (number:) <$> oldVal in (newLen, newVal) Cheers, -- Felipe. From danny.b.eml at gmail.com Mon Sep 3 17:01:46 2012 From: danny.b.eml at gmail.com (Danny B) Date: Tue, 04 Sep 2012 02:01:46 +1100 Subject: [Haskell-cafe] hellno - a somewhat different approach to tackling cabal hell In-Reply-To: References: <5043A484.2040804@gmail.com> Message-ID: <5044C65A.7080103@gmail.com> On 09/03/2012 02:15 PM, Richard Wallace wrote: > I like the approach so far. But hellno itself seems to have several > dependencies itself. So installing with cabal pulls these in as > "fixed" libraries ("text", "mtl", "transformers", and "parsec"). Any > plans to make these not have to be fixed? Or is there a trick I'm > missing? You can simply delete them manually after installing hellno due to GHC using static linkage. Or if you want a dirty and hackish trick, you can load up the source in GHCi and call grabPackage with their PackageIds :) I thought about making a command that would allow you to do this, but after using it you can easily end up with your fixed package set being broken, so I'm not sure. > On Sun, Sep 2, 2012 at 11:25 AM, Danny B wrote: >> Like many of us, I've suffered from cabal dependency hell and sought relief. >> >> I wasn't exactly happy with sandboxes - because using per-project ones >> meant package duplication and shared sandboxes suffer from the same >> issues as the GHC package database itself, i.e. reinstalls can break >> other projects, etc. So I wrote hellno, which is so named because that's >> the expression one makes when seeing cabal hell suddenly manifest itself >> and that's also the expression one makes upon encountering yet ANOTHER >> cabal wrapper. >> >> To quote the README: >>> Generally, with hellno you'll get the same result as for blowing away your user >>> package database and doing a nice clean install but without having to recompile >>> everything and with ability to easily revert back and change between projects. >> >> Hellno works by keeping all the compiled packages to itself in a >> database, so that when you ask it to bring in the dependencies of a >> project, it will use the precompiled packages if available or install >> the deps and save them for later reuse. >> >> Hellno puts symlinks in the user package database pointing to packages >> in its storage to make them visible. Mutating the user db is hardly >> elegant, although shouldn't result in much trouble. >> >> It's been working fine for me, so I figured it may be useful to others. >> You can get hellno from GitHub: >> https://github.com/db81/hellno >> >> I don't mean to say that sandboxing is inherently bad or should not be >> used, but I guess it's better to consider more than one way. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe From bo at ct.de Mon Sep 3 18:31:16 2012 From: bo at ct.de (=?ISO-8859-15?Q?Harald_B=F6geholz?=) Date: Mon, 03 Sep 2012 18:31:16 +0200 Subject: [Haskell-cafe] Asking for advice on programming style and also performance Message-ID: <5044DB54.8000901@ct.de> Dear Haskell Cafe, I am working on a solver for Slitherlink puzzles in Haskell. Today I am completely puzzled that a small change I made had a huge performance impact. I thought the change to be merely cosmetic to make a function a little more elegant and the code more readable. But this change slowed down my program by a factor of 100! I would greatly appreciate advice from experienced Haskellers why this has happened. The program is hosted on github; this is the direct link to the change with unexpected outcome: https://github.com/ctbo/slitherlink/commit/b6f58699258ef68ddee21a1346bd184465aaaba2 The program itself isn't commented at all, but I have written a sketch of how it works in the wiki: https://github.com/ctbo/slitherlink/wiki/How-it-works While I am at it: I would also appreciate any advice you might have on the programming style in general. I am relatively new to Haskell and this is my first nontrivial program. So any suggestions for improvements are welcome! Thanks for your time, -- Harald B?geholz (PGP key available from servers) Redaktion c't Tel.: +49 511 5352-300 Fax: +49 511 5352-417 http://www.ct.de/ int f[9814],b,c=9814,g,i;long a=1e4,d,e,h; main(){for(;b=c,c-=14;i=printf("%04d",e+d/a),e=d%a) while(g=--b*2)d=h*b+a*(i?f[b]:a/5),h=d/--g,f[b]=d%g;} (Arndt/Haenel) Affe Apfel Vergaser /* Heise Zeitschriften Verlag GmbH & Co. KG * Karl-Wiechert-Allee 10 * 30625 Hannover * Registergericht: Amtsgericht Hannover HRA 26709 * Pers?nlich haftende Gesellschafterin: Heise Zeitschriften Verlag * Gesch?ftsf?hrung GmbH * Registergericht: Amtsgericht Hannover, HRB 60405 * Gesch?ftsf?hrer: Ansgar Heise, Dr. Alfons Schr?der */ From timothyhobbs at seznam.cz Mon Sep 3 21:00:14 2012 From: timothyhobbs at seznam.cz (timothyhobbs at seznam.cz) Date: Mon, 03 Sep 2012 21:00:14 +0200 (CEST) Subject: [Haskell-cafe] hstats median algorithm References: <5042B392.5030401@gmail.com> Message-ID: Thanks for the advice.? After taking most of it it is faster.? But it is still many times slower than it ought to be!? This algorithm should be much faster than simply sorting the list, and yet it is more than twice as slow! One note, you said: """" > Increment length. > >> modifySTRef >> lengthRef >> (+1) This will create a big thunk for the length, you should use oldLength <- readSTRef lengthRef writeSTRef lengthRef $! oldLength + 1 (I'm not sure if a strict modifySTRef exists somewhere...)"""" Actually, replacing modifySTRef with that code is just a hair slower...? Not sure why. I'm attaching the super optimized version. Along with the profiler output.? I just can't understand what is slow here :( Timothy ---------- P?vodn? zpr?va ---------- Od: Felipe Almeida Lessa Datum: 3. 9. 2012 P?edm?t: Re: [Haskell-cafe] hstats median algorithm "On Mon, Sep 3, 2012 at 11:18 AM, Felipe Almeida Lessa wrote: > Ditto for oldLen here. Also, you can simplify this lambda a lot: > > import Control.Applicative ((<$>)) > > \(oldLen, oldVal) -> > let newLen = oldLen + 1 > newVal = (number:) <$> oldVal > in newLen `seq` newVal `seq` (newLen, newVal) Or, using BangPatterns, \(oldLen, oldVal) -> let !newLen = oldLen + 1 !newVal = (number:) <$> oldVal in (newLen, newVal) Cheers, -- Felipe." -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- Mon Sep 3 20:54 2012 Time and Allocation Profiling Report (Final) medians +RTS -p -K400m -RTS total time = 7.40 secs (7397 ticks @ 1000 us, 1 processor) total alloc = 2,805,885,192 bytes (excludes profiling overheads) COST CENTRE MODULE %time %alloc whichBucket Main 46.8 49.5 buckets.\ Main 35.0 30.1 buckets Main 7.7 4.6 buckets.\.bucket Main 5.8 5.7 someList.\ Main 2.7 5.7 someList Main 1.7 4.0 individual inherited COST CENTRE MODULE no. entries %time %alloc %time %alloc MAIN MAIN 55 0 0.0 0.0 100.0 100.0 CAF Main 109 0 0.0 0.0 100.0 100.0 someListMin Main 123 1 0.0 0.0 0.0 0.0 someListMax Main 122 1 0.0 0.0 0.0 0.0 someList Main 121 1 1.7 4.0 4.4 9.7 someList.\ Main 124 1001 2.7 5.7 2.7 5.7 someListNumBuckets Main 119 1 0.0 0.0 0.0 0.0 someListGuessedMiddle Main 118 1 0.0 0.0 0.0 0.0 someListMedian Main 111 1 0.0 0.0 95.6 90.3 median Main 112 1 0.3 0.4 95.6 90.3 median.stubLen Main 134 1 0.0 0.0 0.0 0.0 median.length Main 133 1 0.0 0.0 0.0 0.0 median.halfLength Main 132 1 0.0 0.0 0.0 0.0 median.(...) Main 116 1 0.0 0.0 95.3 89.9 buckets Main 117 1 7.7 4.6 95.3 89.9 buckets.\ Main 129 100 0.0 0.0 0.0 0.0 buckets.bottom Main 128 1 0.0 0.0 0.0 0.0 buckets.\ Main 125 2003001 35.0 30.1 87.6 85.3 buckets.\.bucket Main 126 2003001 5.8 5.7 52.6 55.2 whichBucket Main 127 2003001 46.8 49.5 46.8 49.5 buckets.\ Main 120 100 0.0 0.0 0.0 0.0 median.myBuckets Main 115 1 0.0 0.0 0.0 0.0 median.(...) Main 114 1 0.0 0.0 0.0 0.0 median.(...).\ Main 130 100 0.0 0.0 0.0 0.0 median.(...).\.nextI Main 131 51 0.0 0.0 0.0 0.0 median.medianBucketVals Main 113 1 0.0 0.0 0.0 0.0 main Main 110 1 0.0 0.0 0.0 0.0 CAF GHC.Conc.Signal 95 0 0.0 0.0 0.0 0.0 CAF GHC.IO.Handle.FD 91 0 0.0 0.0 0.0 0.0 CAF GHC.IO.Encoding 86 0 0.0 0.0 0.0 0.0 CAF GHC.IO.Encoding.Iconv 72 0 0.0 0.0 0.0 0.0 -------------- next part -------------- A non-text attachment was scrubbed... Name: medians.lhs Type: text/x-literate-haskell Size: 5254 bytes Desc: not available URL: From sanzhiyan at gmail.com Mon Sep 3 21:17:49 2012 From: sanzhiyan at gmail.com (Andrea Vezzosi) Date: Mon, 3 Sep 2012 21:17:49 +0200 Subject: [Haskell-cafe] SYB with class: Bug in Derive.hs module In-Reply-To: <20120903125345.GA22188@sniper> References: <20120903100036.GA20546@sniper> <20120903125345.GA22188@sniper> Message-ID: On Mon, Sep 3, 2012 at 2:53 PM, Roman Cheplyaka wrote: > * Andrea Vezzosi [2012-09-03 12:50:03+0200] >> > [...] >> >> This is pretty similar to what ended up being a ghc bug, fixed in 7.0 though: >> http://hackage.haskell.org/trac/ghc/ticket/3731 > > The difference between my test case and the one attached to the ticket > is that here there's an explicitly circular instance generated by TH. > In the "SYB with class" paper it is specifically said to be broken. So > it looks more like a problem in the TH code rather than in GHC. Right, it's debatable whether ghc should support these instances, though in our case they are well-founded, it only has to produce code that's lazy enough on the dictionaries as far as i can tell. >> > The cause of this bug is a self-referencing instance created by >> > deriveData: >> > >> > instance (Data ctx Foo, Sat (ctx Foo)) => Data ctx Foo where ... >> > >> > What's the proper way to fix it? >> >> From a few tests it seems we no longer need the circular context hack >> in ghc-7.4.1 to get the instance to typecheck, so we could side-step >> the issue entirely by removing it from the generated code. > > Not sure what hack you're referring to. I was going from memory and remembering that the additional Data ctx Foo in the context was necessary to make the instance typecheck, and calling that an hack. (Now I think I was remembering some HappS code using syb-wc which had to do that instead). > As I understand it, the circular context arises as a special case of the > context that includes all the "inner" types of a data type. It's not > possible to get rid of this context entirely ? for example, consider > > data X a = X (Y a) > > where we really need the "Data ctx (Y a)" context (but perhaps it could > be "Data ctx a" instead?). (I don't think I like changing the produced code on the basis of which instances are in scope, so I'd stick with "Data ctx (Y a)") > So we need some criterion to decide whether a structural part of a data > type should be included into the instance context. > > Does this make sense, or am I on the completely wrong track? Yes that's correct, I meant to only filter out Data ctx (X a) in this case, in general I propose to eliminate all the "Data ctx (X ..)" from the context, when X is the data constructor for which we are making the instance, but keep the corresponding "Sat (ctx (X ..))", do you think this would break any instances that would otherwise work? It'd be interesting to find out if we can make a sensible instance for non-regular types like the following though: data Z a = Z (Z (a,a)) | Leaf a the instance we produce currently makes instance resolution non-terminate and the instance we'd produce under my proposal wouldn't typecheck. -- Andrea Vezzosi From timothyhobbs at seznam.cz Mon Sep 3 21:55:17 2012 From: timothyhobbs at seznam.cz (timothyhobbs at seznam.cz) Date: Mon, 03 Sep 2012 21:55:17 +0200 (CEST) Subject: [Haskell-cafe] hstats median algorithm References: <5042B392.5030401@gmail.com> Message-ID: Aha!!!? Now it's working.? Just had to compile with -O2 :D :D Now I'm over twice as fast for a list of 2 million!? With better length based analysis of how many buckets should be used, this number can be improved. You can feel free to use my code however you like.? I've attached the final version. That was fun :D Timothy ?---------- P?vodn? zpr?va ---------- Od: timothyhobbs at seznam.cz Datum: 3. 9. 2012 P?edm?t: Re: [Haskell-cafe] hstats median algorithm " Thanks for the advice.? After taking most of it it is faster.? But it is still many times slower than it ought to be!? This algorithm should be much faster than simply sorting the list, and yet it is more than twice as slow! One note, you said: """" > Increment length. > >> modifySTRef >> lengthRef >> (+1) This will create a big thunk for the length, you should use oldLength <- readSTRef lengthRef writeSTRef lengthRef $! oldLength + 1 (I'm not sure if a strict modifySTRef exists somewhere...)"""" Actually, replacing modifySTRef with that code is just a hair slower...? Not sure why. I'm attaching the super optimized version. Along with the profiler output.? I just can't understand what is slow here :( Timothy ---------- P?vodn? zpr?va ---------- Od: Felipe Almeida Lessa Datum: 3. 9. 2012 P?edm?t: Re: [Haskell-cafe] hstats median algorithm "On Mon, Sep 3, 2012 at 11:18 AM, Felipe Almeida Lessa wrote: > Ditto for oldLen here. Also, you can simplify this lambda a lot: > > import Control.Applicative ((<$>)) > > \(oldLen, oldVal) -> > let newLen = oldLen + 1 > newVal = (number:) <$> oldVal > in newLen `seq` newVal `seq` (newLen, newVal) Or, using BangPatterns, \(oldLen, oldVal) -> let !newLen = oldLen + 1 !newVal = (number:) <$> oldVal in (newLen, newVal) Cheers, -- Felipe." " -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: medians.lhs Type: text/x-literate-haskell Size: 5546 bytes Desc: not available URL: From trivmanish at gmail.com Mon Sep 3 22:06:29 2012 From: trivmanish at gmail.com (Manish Trivedi) Date: Mon, 3 Sep 2012 13:06:29 -0700 Subject: [Haskell-cafe] tplot (out of memory) Message-ID: Hi, I am running into a weird out of memory issue. While running timeplot over an input file having ~800 rows. From below provided info, seems like machine has enough ram (1849MB). Please let me know if anyone has pointers. * # free -m * total used free shared buffers cached Mem: 3825 1975 1849 0 13 71 -/+ buffers/cache: 1891 1934 Swap: 4031 111 3920 *#time tplot -o out.png -or 1024x768 -k 'CurrentPerHour' 'lines' -k 'RequiredPerHour' 'lines' -if adgroup_delivery_chart.input -tf 'date %Y-%m-%d %H:%M:%OS' * tplot: user error (out of memory) real 0m0.026s user 0m0.018s sys 0m0.008s -Manish -------------- next part -------------- An HTML attachment was scrubbed... URL: From hesselink at gmail.com Mon Sep 3 22:42:10 2012 From: hesselink at gmail.com (Erik Hesselink) Date: Mon, 3 Sep 2012 22:42:10 +0200 Subject: [Haskell-cafe] Cabal install fails due to recent HUnit In-Reply-To: References: <5006D531.6060902@oblomov.com> <5006DC44.2090708@oblomov.com> <20120718161619.GA13432@x200> <20120720083416.GA5276@x200> <20120720090218.GA3403@soi.city.ac.uk> <20120725084348.GA4571@x200> <20120725102257.GA3458@soi.city.ac.uk> <20120730133323.GA4293@soi.city.ac.uk> Message-ID: On Tue, Aug 28, 2012 at 6:09 PM, Bryan O'Sullivan wrote: > On Mon, Aug 27, 2012 at 10:52 AM, Bryan O'Sullivan > wrote: >> >> The reason you're seeing build breakage is that the .cabal files of the >> broken packages were edited in-place without communicating with any of the >> package authors. > > Not to flog a dead horse, but: > > Just yesterday we had a communication from someone on the Gentoo Linux > packaging team that their checksum validation for the bloomfilter package > was failing. This problem arose because of the hand-editing of the package, > but confusion arose in the bug report due to misattribution of the source of > the error. > > https://github.com/haskell/cabal/issues/1017 > > Hand-editing uploaded tarballs: just don't do it, kids! Not to flog a dead horse, but: All our builds broke again yesterday due to this bug. The package was iteratee-0.8.9.3, though given the vocal opposition of Bryan O'Sullivan, I won't advocate fixing it in place just now. I've built the test in the Cabal library to reject packages with conditionals in the test-suites section. I'm just not sure if we want to implement this on hackage, and for how long. I'm not quite sure how old this cabal version is that is causing the problems, but the haskell platform it comes with is 2011.2, which means the second quarter of 2011, so that is a little over a year old. It comes with Ubuntu 11.10, which is less than a year old. I was going to argue to support versions of cabal (and GHC) for at least a year. That means that if you're on Ubuntu, which has releases every 6 months, you have 6 months to upgrade. However, that year has already expired for cabal 0.10, or is about to expire if you count the Ubuntu release it came with. So what do others think? Does the haskell community want to support anything other than the bleeding edge? If so, for how long? Regards, Erik From chris at chrisdornan.com Tue Sep 4 00:08:42 2012 From: chris at chrisdornan.com (Chris Dornan) Date: Mon, 3 Sep 2012 23:08:42 +0100 Subject: [Haskell-cafe] Cabal install fails due to recent HUnit In-Reply-To: References: <5006D531.6060902@oblomov.com> <5006DC44.2090708@oblomov.com> <20120718161619.GA13432@x200> <20120720083416.GA5276@x200> <20120720090218.GA3403@soi.city.ac.uk> <20120725084348.GA4571@x200> <20120725102257.GA3458@soi.city.ac.uk> <20120730133323.GA4293@soi.city.ac.uk> Message-ID: <0b0701cd8a20$af0eed30$0d2cc790$@chrisdornan.com> >On Tue, Aug 28, 2012 at 6:09 PM, Bryan O'Sullivan wrote: >> On Mon, Aug 27, 2012 at 10:52 AM, Bryan O'Sullivan >> >> wrote: >> >> Not to flog a dead horse, but: >> ... >Not to flog a dead horse, but: > >All our builds broke again yesterday due to this bug. The package was iteratee-0.8.9.3, though given the vocal opposition of Bryan O'Sullivan, I won't advocate fixing it in place just now. ... >I was going to argue to support versions of cabal (and GHC) for at least a year. That means that if you're on Ubuntu, which has releases every 6 months, you have 6 months to upgrade. However, that year has already expired for cabal 0.10, or is about to expire if you count the Ubuntu release it came with. > >So what do others think? Does the haskell community want to support anything other than the bleeding edge? If so, for how long? While we are all making glue, it really, really doesn't need to be like this! (Everybody is going to hate me for this and I am quite sure I am going to be ignored, but my conscience forbids me from staying quiet.) Every one of my Haskell Platform releases on justhub.org provides all the libraries and tools needed for that platform, which gets laid on top of the existing platforms (which can be removed when they are no longer needed). Each project can chooses its platform, and can pin whatever packages it needs to use without fear of being disrupted, while installing new GHC and platform releases for use with other projects. (Proper package erasure is supported too.) With trivial effort source trees can be moved around among different systems and rebuilt in the exact same configuration. The standard tools (ghc, ghci, ghc-pkg, cabal, etc.) can be used just as normal. All the developer needs to do is designate which platform (or bare ghc) to be used at the root of each work tree -- or leave it to use the platform-du-jour. I can only describe working with this kind of environment as peaceful (certainly not cabal hell). Trying to mutate and maintain coherent an ever-growing network of packages is not a scalable way of doing business. If on top of this the history gets patched up aren't things going to get even more confusing? I know that this way of doing things won't provide immediate relief (it's too radical relative to where everybody is) but I am trying to address Erik's question about what we should be aiming for. Shouldn't we be trying to find a sustainable, long-term, preferred method of delivering stable Haskell development environments? Why not a functional model? What is not to like? I will be at the CUFP if anybody would like to see a live demo or debate any of these points. Chris From arnaud.oqube at gmail.com Tue Sep 4 08:36:17 2012 From: arnaud.oqube at gmail.com (Arnaud Bailly) Date: Tue, 04 Sep 2012 08:36:17 +0200 Subject: [Haskell-cafe] tplot (out of memory) In-Reply-To: (Manish Trivedi's message of "Mon, 3 Sep 2012 13:06:29 -0700") References: Message-ID: <87vcfui9b2.fsf@gmail.com> Hi, Manish Trivedi writes: > I am running into a weird out of memory issue. While running timeplot over > an input file having ~800 rows. From below provided info, seems like > machine has enough ram (1849MB). > Please let me know if anyone has pointers. I have run tplot on much larger files than that without troubles. Which version are you using? I assume this is the one from hackage which AFAIK is the one I am also using. Could you post a sample input file? Regards, -- Arnaud Bailly FoldLabs Associate http://foldlabs.com From mail at joachim-breitner.de Tue Sep 4 09:10:49 2012 From: mail at joachim-breitner.de (Joachim Breitner) Date: Tue, 04 Sep 2012 09:10:49 +0200 Subject: [Haskell-cafe] Asking for advice on programming style and also performance In-Reply-To: <5044DB54.8000901@ct.de> References: <5044DB54.8000901@ct.de> Message-ID: <1346742649.4213.2.camel@kirk> Hi, Am Montag, den 03.09.2012, 18:31 +0200 schrieb Harald B?geholz: > I would greatly appreciate advice from experienced Haskellers why this > has happened. The program is hosted on github; this is the direct link > to the change with unexpected outcome: > > https://github.com/ctbo/slitherlink/commit/b6f58699258ef68ddee21a1346bd184465aaaba2 I?m not sure if you are notified via github, but there are comments there below the commit. Greetings, Joachim -- Joachim "nomeata" Breitner mail at joachim-breitner.de | nomeata at debian.org | GPG: 0x4743206C xmpp: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part URL: From andreas.abel at ifi.lmu.de Tue Sep 4 11:14:33 2012 From: andreas.abel at ifi.lmu.de (Andreas Abel) Date: Tue, 04 Sep 2012 11:14:33 +0200 Subject: [Haskell-cafe] Over general types are too easy to make. In-Reply-To: References: <5043314E.4000206@dockerz.net> Message-ID: <5045C679.2000502@ifi.lmu.de> I agree with Timothy. In the Agda code base, we have many occurrences of Timothy's pattern aux (OneSpecificConstructor args) = ... aux _ = __IMPOSSIBLE__ where __IMPOSSIBLE__ generates code to throw an internal error. A finer type analysis that treats each constructor as its own type would save us from the impossible catch-all clause. Type-theoretically, what you want is "proper", i.e., untagged unions of data types with disjoint sets of constructors. data C1 params = C1 args1 data C2 params = C2 args2 type D params = C1 params | C2 params Now D is the untagged union of C1 and C2. This allows you to give precise typing of aux without uglifying your data structure design with extra tags. Untagged unions are a bit nasty from the type-checking perspective, because you are moving from a name-based type discipline to a structure-based one. (Maybe this was meant by "rows".) Ocaml can do this, as far as I know, but I use Haskell... Good we discussed this. And off to limbo... Cheers, Andreas On 02.09.12 11:57 PM, timothyhobbs at seznam.cz wrote: > Looks like I failed to reply all > ---------- P?vodn? zpr?va ---------- > Od: timothyhobbs at seznam.cz > Datum: 2. 9. 2012 > P?edm?t: Re: Re: [Haskell-cafe] Over general types are too easy to make. > > Care to link me to a code repository that doesn't have this problem? > The only Haskell program that I have in my github that hasn't > suffered this doesn't actually have any data declarations in it. > Sure, if you're using data as a Boolean/Ternian replacement you > won't have a trouble. But any multi record data constructor should > be it's own type. > > I was going to go try and find an example from GHC, but you said > that you think this problem is domain specific, and it's true that > all of my work has had to do with code parsing/generation. So I went > to look in darcs... Even with the shallow types of darcs we can > still find examples of this problem: > > http://hackage.haskell.org/packages/archive/darcs/2.8.1/doc/html/src/Darcs-Match.html > > take a look at the function nonrangeMatcher, specifically OneTag, > OneMatch, SeveralPatch... You can inspect the data declaration for > DarcsFlag here > http://hackage.haskell.org/packages/archive/darcs/2.8.1/doc/html/src/Darcs-Flags.html > ... Now ask yourself, what are the types for tagmatch and mymatch. > They take Strings as arguments. Obviously they are typed > incorrectly. tagmatch SHOULD have the type :: OneTag -> Matcher p. > and mymatch SHOULD have the type PatchU -> Matcher p where data > PatchU = OnePatchU OnePatch | SeveralPatchU SeveralPatch... But we > can't just easily go and change the types. Because unfortunately > GADT data declarations are not used here. > > You've probably come across this many times. You just never realized > it, because it's a case of GHC letting you do something you > shouldn't be doing, rather than GHC stopping you from doing > something you wish to. > > Timothy > > > ---------- P?vodn? zpr?va ---------- > Od: Chris Smith > Datum: 2. 9. 2012 > P?edm?t: Re: [Haskell-cafe] Over general types are too easy to make. > > On Sun, Sep 2, 2012 at 9:40 AM, wrote: > > The thing is, that one ALWAYS wants to create a union of > types, and not > > merely an ad-hock list of data declarations. So why does it > take more code > > to do "the right thing(tm)" than to do "the wrong thing(r)"? > > You've said this a few times, that you run into this constantly, or > even that everyone runs into this. But I don't think that's the > case. > It's something that happens sometimes, yes, but if you're running > into this issue for every data type that you declare, that is > certainly NOT just normal in Haskell programming. So in that sense, > many of the answers you've gotten - to use a GADT, in particular - > might be great advice in the small subset of cases where average > Haskell programmers want more complex constraints on types; but it's > certainly not a good idea to do to every data type in your > application. > > I don't have the answer for you about why this always happens to > you, > but it's clear that there's something there - perhaps a stylistic > issue, or a domain-specific pattern, or something... - that's > causing > you to face this a lot more frequently than others do. If I had to > take a guess, I'd say that you're breaking things down into fairly > complex monolithic parts, where a lot of Haskell programmers > will have > a tendency to work with simpler types and break things down into > smaller pieces. But... who knows... I haven't seen the many cases > where this has happened to you. > > -- > Chris > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Andreas Abel <>< Du bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.abel at ifi.lmu.de http://www2.tcs.ifi.lmu.de/~abel/ From agocorona at gmail.com Tue Sep 4 12:39:20 2012 From: agocorona at gmail.com (Alberto G. Corona ) Date: Tue, 4 Sep 2012 12:39:20 +0200 Subject: [Haskell-cafe] From monads to monoids in a small category Message-ID: "Monads are monoids in the category of endofunctors" This Monoid instance for the endofunctors of the set of all elements of (m a) typematch in Haskell with FlexibleInstances: instance Monad m => Monoid (a -> m a) where mappend = (>=>) -- kleisly operator mempty = return The article can be found here: http://haskell-web.blogspot.com.es/2012/07/from-monads-to-monoids-in-small.html I would appreciate some comments. From ekirpichov at gmail.com Tue Sep 4 17:01:50 2012 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Tue, 4 Sep 2012 08:01:50 -0700 Subject: [Haskell-cafe] tplot (out of memory) In-Reply-To: References: Message-ID: Hi Manish, Please provide the input file, I'll debug this. On Mon, Sep 3, 2012 at 1:06 PM, Manish Trivedi wrote: > Hi, > > I am running into a weird out of memory issue. While running timeplot over > an input file having ~800 rows. From below provided info, seems like machine > has enough ram (1849MB). > Please let me know if anyone has pointers. > > # free -m > total used free shared buffers cached > Mem: 3825 1975 1849 0 13 71 > -/+ buffers/cache: 1891 1934 > Swap: 4031 111 3920 > > #time tplot -o out.png -or 1024x768 -k 'CurrentPerHour' 'lines' -k > 'RequiredPerHour' 'lines' -if adgroup_delivery_chart.input -tf 'date > %Y-%m-%d %H:%M:%OS' > > tplot: user error (out of memory) > > real 0m0.026s > user 0m0.018s > sys 0m0.008s > > -Manish > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov http://www.linkedin.com/in/eugenekirpichov From krismicinski at gmail.com Tue Sep 4 20:32:35 2012 From: krismicinski at gmail.com (Kristopher Micinski) Date: Tue, 4 Sep 2012 14:32:35 -0400 Subject: [Haskell-cafe] From monads to monoids in a small category In-Reply-To: References: Message-ID: Your post feels similar to another one posted recently... http://web.jaguarpaw.co.uk/~tom/blog/2012/09/02/what-is-a-monad-really.html just fyi, :-), kris On Tue, Sep 4, 2012 at 6:39 AM, Alberto G. Corona wrote: > "Monads are monoids in the category of endofunctors" > > This Monoid instance for the endofunctors of the set of all elements > of (m a) typematch in Haskell with FlexibleInstances: > > instance Monad m => Monoid (a -> m a) where > mappend = (>=>) -- kleisly operator > mempty = return > > The article can be found here: > > http://haskell-web.blogspot.com.es/2012/07/from-monads-to-monoids-in-small.html > > I would appreciate some comments. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From agocorona at gmail.com Wed Sep 5 00:12:18 2012 From: agocorona at gmail.com (Alberto G. Corona ) Date: Wed, 5 Sep 2012 00:12:18 +0200 Subject: [Haskell-cafe] From monads to monoids in a small category In-Reply-To: References: Message-ID: Not to mention the ugly formatting ;) 2012/9/5 Richard O'Keefe : > > On 4/09/2012, at 10:39 PM, Alberto G. Corona wrote: > >> "Monads are monoids in the category of endofunctors" >> >> This Monoid instance for the endofunctors of the set of all elements >> of (m a) typematch in Haskell with FlexibleInstances: >> >> instance Monad m => Monoid (a -> m a) where >> mappend = (>=>) -- kleisly operator >> mempty = return >> >> The article can be found here: >> >> http://haskell-web.blogspot.com.es/2012/07/from-monads-to-monoids-in-small.html >> >> I would appreciate some comments. > > s/kleisly/Kleisli/ > In the article, > s/Lets/Let's/ > /Here 'm b' as/ s/as/is/ > s/this_are/this are/ > s/first, is/first is/ > s/haskell/Haskell/ > s/polimorphic/polymorphic/ > s/x=/x =/ > s/let's/Let's/ > s/condition, associativity/condition, associativity,/ > /if not where that way, .* guess/ > I *think* you mean to say something like > (If it were not so, it would be impossible to > define the denotational semantics of imperative > languages in terms of monads, I guess.) > Generally, it's "according TO", not "according WITH", > and "associated WITH", not "associated TO". > > instance Functor a > doesn't seem to be legal Haskell. > > At this point I stopped reading. > > From alex.solla at gmail.com Wed Sep 5 01:21:23 2012 From: alex.solla at gmail.com (Alexander Solla) Date: Tue, 4 Sep 2012 16:21:23 -0700 Subject: [Haskell-cafe] From monads to monoids in a small category In-Reply-To: References: Message-ID: On Tue, Sep 4, 2012 at 3:39 AM, Alberto G. Corona wrote: > "Monads are monoids in the category of endofunctors" > > This Monoid instance for the endofunctors of the set of all elements > of (m a) typematch in Haskell with FlexibleInstances: > > instance Monad m => Monoid (a -> m a) where > mappend = (>=>) -- kleisly operator > mempty = return > The objects of a Kliesli category for a monad m aren't endofunctors. You want something like: instance Monad m => Monoid (m a -> m (m a)) where ... /These/ are endofunctors, in virtue of join transforming an m (m a) into an (m a). -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.solla at gmail.com Wed Sep 5 01:46:13 2012 From: alex.solla at gmail.com (Alexander Solla) Date: Tue, 4 Sep 2012 16:46:13 -0700 Subject: [Haskell-cafe] From monads to monoids in a small category In-Reply-To: References: Message-ID: On Tue, Sep 4, 2012 at 4:21 PM, Alexander Solla wrote: > > > On Tue, Sep 4, 2012 at 3:39 AM, Alberto G. Corona wrote: > >> "Monads are monoids in the category of endofunctors" >> >> This Monoid instance for the endofunctors of the set of all elements >> of (m a) typematch in Haskell with FlexibleInstances: >> >> instance Monad m => Monoid (a -> m a) where >> mappend = (>=>) -- kleisly operator >> mempty = return >> > > The objects of a Kliesli category for a monad m aren't endofunctors. You > want something like: > > instance Monad m => Monoid (m a -> m (m a)) where ... > > /These/ are endofunctors, in virtue of join transforming an m (m a) into > an (m a). > Actually, even these aren't endofunctors, for a similar reason that : you "really" want something like instance Monad m => Monoid (m a -> m a) where mempty = id mappend = undefined -- exercise left to the reader (i.e., you want to do plumbing through the Eilenberg-Moore category for a monad, instead of the Kliesli category for a monad -- my last message exposes the kind of plumping you want, but not the right types.) -------------- next part -------------- An HTML attachment was scrubbed... URL: From radical at google.com Wed Sep 5 02:01:47 2012 From: radical at google.com (Alvaro Gutierrez) Date: Tue, 4 Sep 2012 20:01:47 -0400 Subject: [Haskell-cafe] Over general types are too easy to make. In-Reply-To: <5045C679.2000502@ifi.lmu.de> References: <5043314E.4000206@dockerz.net> <5045C679.2000502@ifi.lmu.de> Message-ID: On Tue, Sep 4, 2012 at 5:14 AM, Andreas Abel wrote: > I agree with Timothy. In the Agda code base, we have many occurrences of > Timothy's pattern > > aux (OneSpecificConstructor args) = ... > aux _ = __IMPOSSIBLE__ > > where __IMPOSSIBLE__ generates code to throw an internal error. +1 I've run into this situation quite a few times. I'm guessing it's especially irritating to fans of -Wall, in particular coupled with -Werror, the former of which includes exhaustiveness checking for patterns. Even without changing the type system it might still be useful, for example, to prevent such warnings for those cases when the missing patterns can be statically determined never to be used -- e.g. for functions known not to escape the module's scope. (Incidentally, exhaustiveness checking in lambdas doesn't seem to be enabled as of GHC version 7.2.2.) From sanzhiyan at gmail.com Wed Sep 5 03:13:56 2012 From: sanzhiyan at gmail.com (Andrea Vezzosi) Date: Wed, 5 Sep 2012 03:13:56 +0200 Subject: [Haskell-cafe] SYB with class: Bug in Derive.hs module In-Reply-To: References: <20120903100036.GA20546@sniper> <20120903125345.GA22188@sniper> Message-ID: I've pushed the discussed changes to the repo[1], it'd be good if you (and other users) could test them before they get to hackage. [1] darcs get http://patch-tag.com/r/Saizan/syb-with-class/ -- Andrea From magicloud.magiclouds at gmail.com Wed Sep 5 05:45:54 2012 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Wed, 5 Sep 2012 11:45:54 +0800 Subject: [Haskell-cafe] How to waitForProcess? Message-ID: Hi, I have code like this and it leaves lots of zombies of flow-export. Then I add waitForProcess.... Well I do not know where to put it. Before or after 'hGetContents' both make the program hung. exportCSV :: FilePath -> IO [String] exportCSV file = do csv_ <- withBinaryFile file ReadMode $ \i -> do (_, Just o, _, h) <- createProcess $ CreateProcess (RawCommand "/usr/bin/flow-export" ["-f2"]) Nothing Nothing (UseHandle i) CreatePipe Inherit True False hGetContents o return $ tail $ lines csv_ -- ??????? ??????? And for G+, please use magiclouds#gmail.com. From ivan.miljenovic at gmail.com Wed Sep 5 06:37:34 2012 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Wed, 5 Sep 2012 14:37:34 +1000 Subject: [Haskell-cafe] How to waitForProcess? In-Reply-To: References: Message-ID: On 5 September 2012 13:45, Magicloud Magiclouds wrote: > Hi, > I have code like this and it leaves lots of zombies of flow-export. > Then I add waitForProcess.... Well I do not know where to put it. > Before or after 'hGetContents' both make the program hung. You're probably being bitten by hGetContents being lazy. Force the result of hGetContents (e.g. `evaluate . length =<< hGetContents o ') and then use waitForProcess. > > exportCSV :: FilePath -> IO [String] > exportCSV file = do > csv_ <- withBinaryFile file ReadMode $ \i -> do > (_, Just o, _, h) <- createProcess $ CreateProcess (RawCommand > "/usr/bin/flow-export" ["-f2"]) Nothing Nothing (UseHandle i) > CreatePipe Inherit True False > hGetContents o > return $ tail $ lines csv_ > > -- > ??????? > ??????? > > And for G+, please use magiclouds#gmail.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From eleventynine at gmail.com Wed Sep 5 06:39:00 2012 From: eleventynine at gmail.com (Mike Ledger) Date: Wed, 5 Sep 2012 14:39:00 +1000 Subject: [Haskell-cafe] How to waitForProcess? In-Reply-To: References: Message-ID: You might have to use hGetContents, then waitForProcess, and then terminateProcess -- you can then check if the process is indeed terminated using getProcessExitCode. On Wed, Sep 5, 2012 at 1:45 PM, Magicloud Magiclouds < magicloud.magiclouds at gmail.com> wrote: > Hi, > I have code like this and it leaves lots of zombies of flow-export. > Then I add waitForProcess.... Well I do not know where to put it. > Before or after 'hGetContents' both make the program hung. > > exportCSV :: FilePath -> IO [String] > exportCSV file = do > csv_ <- withBinaryFile file ReadMode $ \i -> do > (_, Just o, _, h) <- createProcess $ CreateProcess (RawCommand > "/usr/bin/flow-export" ["-f2"]) Nothing Nothing (UseHandle i) > CreatePipe Inherit True False > hGetContents o > return $ tail $ lines csv_ > > -- > ??????? > ??????? > > And for G+, please use magiclouds#gmail.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From magicloud.magiclouds at gmail.com Wed Sep 5 06:45:10 2012 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Wed, 5 Sep 2012 12:45:10 +0800 Subject: [Haskell-cafe] How to waitForProcess? In-Reply-To: References: Message-ID: Forgot about that, just read 'readProcess' code to figure out. Thanks. On Wed, Sep 5, 2012 at 12:37 PM, Ivan Lazar Miljenovic wrote: > On 5 September 2012 13:45, Magicloud Magiclouds > wrote: >> Hi, >> I have code like this and it leaves lots of zombies of flow-export. >> Then I add waitForProcess.... Well I do not know where to put it. >> Before or after 'hGetContents' both make the program hung. > > You're probably being bitten by hGetContents being lazy. Force the > result of hGetContents (e.g. `evaluate . length =<< hGetContents o ') > and then use waitForProcess. > >> >> exportCSV :: FilePath -> IO [String] >> exportCSV file = do >> csv_ <- withBinaryFile file ReadMode $ \i -> do >> (_, Just o, _, h) <- createProcess $ CreateProcess (RawCommand >> "/usr/bin/flow-export" ["-f2"]) Nothing Nothing (UseHandle i) >> CreatePipe Inherit True False >> hGetContents o >> return $ tail $ lines csv_ >> >> -- >> ??????? >> ??????? >> >> And for G+, please use magiclouds#gmail.com. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic at gmail.com > http://IvanMiljenovic.wordpress.com -- ??????? ??????? And for G+, please use magiclouds#gmail.com. From allbery.b at gmail.com Wed Sep 5 07:34:00 2012 From: allbery.b at gmail.com (Brandon Allbery) Date: Tue, 4 Sep 2012 22:34:00 -0700 Subject: [Haskell-cafe] How to waitForProcess? In-Reply-To: References: Message-ID: On Tue, Sep 4, 2012 at 9:39 PM, Mike Ledger wrote: > You might have to use hGetContents, then waitForProcess, and then > terminateProcess -- you can then check if the process is indeed terminated > using getProcessExitCode. Er? When waitForProcess returns the process is dead; there's nothing to terminateProcess. If you do it the other way around then you may not get full output. For starters, I would not build up the CreateProcess record directly but use the "proc" record and override it with your I/O definitions. I've been bit by this before (I think some older version of System.Process lacked useful predefined records?). There is a severe gotcha here if you do things naively (like your example code does). If there is more output than will fit in a pipe, *no* ordering of read / wait in a single thread will work without deadlocking; you have no choice but to do the read in a separate thread. This is not a Haskell issue, it is how pipes work on POSIX systems. (I don't know if Windows has the same problem.) -- brandon s allbery allbery.b at gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms -------------- next part -------------- An HTML attachment was scrubbed... URL: From roma at ro-che.info Wed Sep 5 10:27:25 2012 From: roma at ro-che.info (Roman Cheplyaka) Date: Wed, 5 Sep 2012 11:27:25 +0300 Subject: [Haskell-cafe] SYB with class: Bug in Derive.hs module In-Reply-To: References: <20120903100036.GA20546@sniper> <20120903125345.GA22188@sniper> Message-ID: <20120905082725.GA9401@sniper> * Andrea Vezzosi [2012-09-05 03:13:56+0200] > I've pushed the discussed changes to the repo[1], it'd be good if you > (and other users) could test them before they get to hackage. > > [1] darcs get http://patch-tag.com/r/Saizan/syb-with-class/ I confirm that it fixed my problem. Thank you! -- Roman I. Cheplyaka :: http://ro-che.info/ From D.J.Duke at leeds.ac.uk Wed Sep 5 15:32:21 2012 From: D.J.Duke at leeds.ac.uk (David Duke) Date: Wed, 5 Sep 2012 14:32:21 +0100 Subject: [Haskell-cafe] Research Position, Leeds: Parallel functional visualization Message-ID: <331133B8-DCCC-4F70-8628-2CF473DCD47F@leeds.ac.uk> I have an open position in the Visualization group at Leeds for a researcher to work on one of two projects, the second of which is specific to Haskell: We are seeking to appoint an ambitious researcher within the Visualization and VR group at Leeds to work on one of two projects, (i) time-varying and higher-dimensional graphs, or (ii) high-performance visualization in Haskell. The post is available immediately, and lasts until 31 July 2016. 1. Time-varying and higher-dimensional graphs. We are developing powerful tools for the topological analysis of (time-varying) volumetric datasets. These produce large graphs capturing combinatorial structures and events, and visual analysis of these graphs provides significant insight into the data. Similar structures may be found in graphs resulting from optimisation problems in multi-parameter spaces. The research will investigate (i) the link between layout aesthetics and specific tasks over time-varying data; (ii) layout techniques that respect these aesthetics, for example embedding of the graph into higher-dimensional manifolds; (iii) techniques for eliding structural detail, and linking visual abstractions to other models of the data; and (iv) efficient implementation of layout algorithms, using established toolkits (e.g. VTK), and parallelisation on cluster-based hardware and/or many-core GPU architecture. You will be working with researchers on the "Multifield Extension of Topological Analysis" project, funded recently by the EPSRC. 2. Parallel functional visualization: Scientific visualization involves the application of compute-intensive algorithms to large volumes of data, often larger than can fit into core memory. Systems are still largely based on the "pipeline" model, extended to exploit different processing technologies (multi-core CPUs, GPUs, clusters), and strategies (streaming, tiling, out-of-core processing, etc). This research concerns an innovative approach that exploits laziness and parallelism in the pure functional language Haskell. Scivis "applications" will be constructed from expressions in a declarative domain-specific language, and transformed into imagery via lower-level DSLs and strategies that coordinate use of heterogeneous resources. Both projects involve fundamental computer science and interdisciplinary work alongside experts from other disciplines providing data and contributing to its analysis. The appointee will be expected to contribute to the programme described above through all stages of the research process, including basic research, programming, testing, evaluation, publication of results at the highest level, and assistance in developing proposals for funding. Work will involve collaboration with other senior members of the Leeds visualization group (Dr. Hamish Carr and Dr. Roy Ruddle), and there will be opportunities to assist with academic supervision of undergraduate and postgraduate students. CLOSING DATE: 21st September. For further information including person specification, and/or to submit an application, please see the following URL: http://jobs.leeds.ac.uk/fe/tpl_universityofleeds01.asp?s=FoQnTYvIgXJoLlXgd&jobid=87341,0258234882&key=83785920&c=566912236914&pagestamp=sewzhxglqcfnsctopm For informal inquiries, please feel free to contact me directly. David Duke Head, School of Computing, and Reader in Visualization E: D.J.Duke at leeds.ac.uk W: www.comp.leeds.ac.uk/djd/ From agarwal1975 at gmail.com Wed Sep 5 16:39:48 2012 From: agarwal1975 at gmail.com (Ashish Agarwal) Date: Wed, 5 Sep 2012 10:39:48 -0400 Subject: [Haskell-cafe] [CUFP 2012] Birds of a Feather sessions Message-ID: ========================================================= Birds of a Feather sessions (BOFs) Commercial Users of Functional Programming Workshop (CUFP 2012) http://cufp.org/bofs-2012 Copenhagen, Denmark, September 13 - 15 ========================================================= CUFP 2012 will again include Birds of a Feather sessions as in previous years. BoFs provide a place for our community to gather informally and reach consensus on matters of importance. Any CUFP attendee can propose a BoF session, and grab one of the spare rooms in the evening slots below. Attendance in the evening is open to all. BoF sessions facilitate ad-hoc discussions and provide a place to gather and start off the chat, before moving on during the evening to a local restaurant or pub. There is no deadline for proposing a session---you can even request a room on the day---but we encourage you to do so at the earliest possible time to help us with planning and to publicize your proposed discussion. Attendees are also free to show up even if you have not confirmed, but again earlier confirmation will help us with planning. Please see http://cufp.org/bofs-2012 for details on how to propose a BoF session or confirm attendance at one of them. General information on CUFP 2012 can be found at http://cufp.org/conference/2012. The conference is co-located with ICFP. You can register for CUFP at the main ICFP website http://www.icfpconference.org/icfp2012. -------------- next part -------------- An HTML attachment was scrubbed... URL: From agocorona at gmail.com Wed Sep 5 18:11:58 2012 From: agocorona at gmail.com (Alberto G. Corona ) Date: Wed, 5 Sep 2012 18:11:58 +0200 Subject: [Haskell-cafe] From monads to monoids in a small category In-Reply-To: References: Message-ID: Thanks, Kristopher 2012/9/4 Kristopher Micinski : > Your post feels similar to another one posted recently... > > http://web.jaguarpaw.co.uk/~tom/blog/2012/09/02/what-is-a-monad-really.html > > just fyi, :-), > > kris > > On Tue, Sep 4, 2012 at 6:39 AM, Alberto G. Corona wrote: >> "Monads are monoids in the category of endofunctors" >> >> This Monoid instance for the endofunctors of the set of all elements >> of (m a) typematch in Haskell with FlexibleInstances: >> >> instance Monad m => Monoid (a -> m a) where >> mappend = (>=>) -- kleisly operator >> mempty = return >> >> The article can be found here: >> >> http://haskell-web.blogspot.com.es/2012/07/from-monads-to-monoids-in-small.html >> >> I would appreciate some comments. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe From kc1956 at gmail.com Wed Sep 5 18:46:45 2012 From: kc1956 at gmail.com (KC) Date: Wed, 5 Sep 2012 09:46:45 -0700 Subject: [Haskell-cafe] Haskell seems setup for iterative numerics; i.e. a standard example is Newton's method where lazy evaluation ... Message-ID: separates control from computation. It seems as if Haskell would be better for iterative matrix methods rather than direct calculation. -- -- Regards, KC From agocorona at gmail.com Wed Sep 5 18:47:17 2012 From: agocorona at gmail.com (Alberto G. Corona ) Date: Wed, 5 Sep 2012 18:47:17 +0200 Subject: [Haskell-cafe] From monads to monoids in a small category In-Reply-To: References: Message-ID: Alexander, In my post (excuses for my dyslexia) I try to demonstrate that the codomain (m a), from the point of view of C. Theory, can be seen as 'a' plus, optionally, some additional element, so a monadic morphism (a -> m a) is part of a endofunctor in (m a -> m a) When considering the concept of arrow from category theory, (not the concept of function), a point in the domain can "send" more than one arrow to the codomain, while a function do not. I think that this is the most interesting part of the interpretation, if I?m right. About this, I found this article revealing: http://cdsmith.wordpress.com/2012/04/18/why-do-monads-matter/ Therefore, codomains of (a -> m a) which are containers with multiple a elements can be considered as multi-arrow morphisms from 'a' to 'a' with the optional addition of some special elements that denote special conditions. For example (a -> [a]) May be considered as the general signature of the morphisms from the set 'a' to the set ('a' + []) So a monadic transformation (a -> [a]) can be considered as a point transformation of a endofunctor within the set (a + []). Alberto 2012/9/5 Alexander Solla : > > > On Tue, Sep 4, 2012 at 4:21 PM, Alexander Solla > wrote: >> >> >> >> On Tue, Sep 4, 2012 at 3:39 AM, Alberto G. Corona >> wrote: >>> >>> "Monads are monoids in the category of endofunctors" >>> >>> This Monoid instance for the endofunctors of the set of all elements >>> of (m a) typematch in Haskell with FlexibleInstances: >>> >>> instance Monad m => Monoid (a -> m a) where >>> mappend = (>=>) -- kleisly operator >>> mempty = return >> >> >> The objects of a Kliesli category for a monad m aren't endofunctors. You >> want something like: >> >> instance Monad m => Monoid (m a -> m (m a)) where ... >> >> /These/ are endofunctors, in virtue of join transforming an m (m a) into >> an (m a). > > > Actually, even these aren't endofunctors, for a similar reason that : you > "really" want something like > > instance Monad m => Monoid (m a -> m a) where > mempty = id > mappend = undefined -- exercise left to the reader > > (i.e., you want to do plumbing through the Eilenberg-Moore category for a > monad, instead of the Kliesli category for a monad -- my last message > exposes the kind of plumping you want, but not the right types.) From mail at nh2.me Wed Sep 5 21:40:37 2012 From: mail at nh2.me (=?ISO-8859-1?Q?Niklas_Hamb=FCchen?=) Date: Wed, 05 Sep 2012 20:40:37 +0100 Subject: [Haskell-cafe] Monospace code in Haddock Message-ID: <5047AAB5.9040801@nh2.me> Is it possible to use inlined monospaced font in Haddock that does *not* replace < and > to links and does *not* link to Haskell functions (like @ and ' and " and ` do)? Like: -- | This function gives you @str@ something :: String The @ above of course makes everything unreadable (as it thinks span... is a link). The only thing I've found to work so far is: -- | This function gives you -- -- >@str@ something :: String Which is not inline. From sol at typeful.net Wed Sep 5 21:50:21 2012 From: sol at typeful.net (Simon Hengel) Date: Wed, 5 Sep 2012 21:50:21 +0200 Subject: [Haskell-cafe] Monospace code in Haddock In-Reply-To: <5047AAB5.9040801@nh2.me> References: <5047AAB5.9040801@nh2.me> Message-ID: <20120905195021.GA14168@x200> On Wed, Sep 05, 2012 at 08:40:37PM +0100, Niklas Hamb?chen wrote: > Is it possible to use inlined monospaced font in Haddock that does *not* > replace < and > to links and does *not* link to Haskell functions (like > @ and ' and " and ` do)? Have you tried to escape stuff within @. e.g.: @\@ I think this should work. Cheers, Simon From mail at nh2.me Wed Sep 5 21:53:26 2012 From: mail at nh2.me (=?ISO-8859-1?Q?Niklas_Hamb=FCchen?=) Date: Wed, 05 Sep 2012 20:53:26 +0100 Subject: [Haskell-cafe] Monospace code in Haddock In-Reply-To: <20120905195021.GA14168@x200> References: <5047AAB5.9040801@nh2.me> <20120905195021.GA14168@x200> Message-ID: <5047ADB6.2050904@nh2.me> OK, but how to prevent it from linking to foo if I have a function foo in my module? On 05/09/12 20:50, Simon Hengel wrote: > On Wed, Sep 05, 2012 at 08:40:37PM +0100, Niklas Hamb?chen wrote: >> Is it possible to use inlined monospaced font in Haddock that does *not* >> replace < and > to links and does *not* link to Haskell functions (like >> @ and ' and " and ` do)? > > Have you tried to escape stuff within @. e.g.: > > @\@ > > I think this should work. > > Cheers, > Simon > From carter.schonwald at gmail.com Wed Sep 5 21:59:51 2012 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Wed, 5 Sep 2012 15:59:51 -0400 Subject: [Haskell-cafe] Haskell seems setup for iterative numerics; i.e. a standard example is Newton's method where lazy evaluation ... In-Reply-To: References: Message-ID: Hello KC, you should check out the Repa library then and see how it works for you. Cheers -Carter On Wed, Sep 5, 2012 at 12:46 PM, KC wrote: > separates control from computation. > > It seems as if Haskell would be better for iterative matrix methods > rather than direct calculation. > > -- > -- > Regards, > KC > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sol at typeful.net Wed Sep 5 22:04:43 2012 From: sol at typeful.net (Simon Hengel) Date: Wed, 5 Sep 2012 22:04:43 +0200 Subject: [Haskell-cafe] Monospace code in Haddock In-Reply-To: <5047ADB6.2050904@nh2.me> References: <5047AAB5.9040801@nh2.me> <20120905195021.GA14168@x200> <5047ADB6.2050904@nh2.me> Message-ID: <20120905200443.GA15308@x200> On Wed, Sep 05, 2012 at 08:53:26PM +0100, Niklas Hamb?chen wrote: > OK, but how to prevent it from linking to foo if I have a function foo > in my module? Hmm, I'm not sure if I understand the problem. Can you give a minimal example? Cheers, Simon From jays at panix.com Wed Sep 5 22:10:45 2012 From: jays at panix.com (Jay Sulzberger) Date: Wed, 5 Sep 2012 16:10:45 -0400 (EDT) Subject: [Haskell-cafe] Pointer to clarifying page "Hask" for beginners who take too naively claims of "rigor" Was: Re: From monads to monoids in a small category In-Reply-To: References: Message-ID: On Tue, 4 Sep 2012, Alexander Solla wrote: > On Tue, Sep 4, 2012 at 4:21 PM, Alexander Solla wrote: > >> >> >> On Tue, Sep 4, 2012 at 3:39 AM, Alberto G. Corona wrote: >> >>> "Monads are monoids in the category of endofunctors" >>> >>> This Monoid instance for the endofunctors of the set of all elements >>> of (m a) typematch in Haskell with FlexibleInstances: >>> >>> instance Monad m => Monoid (a -> m a) where >>> mappend = (>=>) -- kleisly operator >>> mempty = return >>> >> >> The objects of a Kliesli category for a monad m aren't endofunctors. You >> want something like: >> >> instance Monad m => Monoid (m a -> m (m a)) where ... >> >> /These/ are endofunctors, in virtue of join transforming an m (m a) into >> an (m a). >> > > Actually, even these aren't endofunctors, for a similar reason that : you > "really" want something like > > instance Monad m => Monoid (m a -> m a) where > mempty = id > mappend = undefined -- exercise left to the reader > > (i.e., you want to do plumbing through the Eilenberg-Moore category for a > monad, instead of the Kliesli category for a monad -- my last message > exposes the kind of plumping you want, but not the right types.) This is not directly responsive to what has been written in this thread, but is a beginner's, likely mistaken, complaint: In many expositions of "monads" and other such Haskelliana, often there is missing a few words of explanation in this style: A monad in category theory is a . To define the monad M in Haskell, we must pick out a category embedded in some sense in Haskell. A category has objects and morphisms which must obey certain laws. So for M we choose . Now the directly above might pick out something which cannot be easily directly described inside the Haskell world, or even in the first layers of the onion of worlds-about-Haskell. For example we might have: The objects of our category are types whose sets of values, always taken without _|_, are finite, or if infinite, come with a partial ordering which is isomorphic to a subset of N^2, with the usual product of N ordering. Note I have no example in mind here, though certainly one can make one up. It is the style I am pointing out. We then must have a paragraph defining, in a similar style, the morphisms, the identity morphisms, and the composition of morphisms of our category, which is "embedded", by means outside of Haskell, into Haskell. Then we must have a paragraph defining the monad itself, so we have our endofunctor T, as Wikipedia calls it in the article on monads (category theory sense), and the two natural transformations \eta and \mu. And then, ah, hmunh, mmh, Oi! again I have failed to look at the standard introductory literature. The missing gentle words of clarification, and thus, encouragement, are at http://www.haskell.org/haskellwiki/Hask and the two notes there pointed to. oo--JS. From kc1956 at gmail.com Wed Sep 5 22:10:52 2012 From: kc1956 at gmail.com (KC) Date: Wed, 5 Sep 2012 13:10:52 -0700 Subject: [Haskell-cafe] Haskell seems setup for iterative numerics; i.e. a standard example is Newton's method where lazy evaluation ... In-Reply-To: References: Message-ID: The REPA package/library doesn't have LU factorization, eigenvalues, etc. On Wed, Sep 5, 2012 at 12:59 PM, Carter Schonwald wrote: > Hello KC, > you should check out the Repa library then and see how it works for you. > Cheers > -Carter > > On Wed, Sep 5, 2012 at 12:46 PM, KC wrote: >> >> separates control from computation. >> >> It seems as if Haskell would be better for iterative matrix methods >> rather than direct calculation. >> >> -- >> -- >> Regards, >> KC >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- -- Regards, KC From mail at nh2.me Wed Sep 5 22:11:47 2012 From: mail at nh2.me (=?ISO-8859-1?Q?Niklas_Hamb=FCchen?=) Date: Wed, 05 Sep 2012 21:11:47 +0100 Subject: [Haskell-cafe] Monospace code in Haddock In-Reply-To: <20120905200443.GA15308@x200> References: <5047AAB5.9040801@nh2.me> <20120905195021.GA14168@x200> <5047ADB6.2050904@nh2.me> <20120905200443.GA15308@x200> Message-ID: <5047B203.70503@nh2.me> When you write: -- | This function returns the string @hello@ and you have a function called hello in scope, haddock will hyperlink the the above hello to that function, which is confusing if your monospace string has actually nothing to do with that function. In other words: Haddock always links to your functions in inline monospaced text, and you can't turn that off. -- | Gives you @\hello\@ will therefore link to functions 'span' and 'hello' if they exist. On 05/09/12 21:04, Simon Hengel wrote: > On Wed, Sep 05, 2012 at 08:53:26PM +0100, Niklas Hamb?chen wrote: >> OK, but how to prevent it from linking to foo if I have a function foo >> in my module? > > Hmm, I'm not sure if I understand the problem. Can you give a minimal > example? > > Cheers, > Simon > From carter.schonwald at gmail.com Wed Sep 5 22:18:20 2012 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Wed, 5 Sep 2012 16:18:20 -0400 Subject: [Haskell-cafe] Haskell seems setup for iterative numerics; i.e. a standard example is Newton's method where lazy evaluation ... In-Reply-To: References: Message-ID: in the mean time I suggest using Hmatrix then :) On Wed, Sep 5, 2012 at 4:10 PM, KC wrote: > The REPA package/library doesn't have LU factorization, eigenvalues, etc. > > > On Wed, Sep 5, 2012 at 12:59 PM, Carter Schonwald > wrote: > > Hello KC, > > you should check out the Repa library then and see how it works for you. > > Cheers > > -Carter > > > > On Wed, Sep 5, 2012 at 12:46 PM, KC wrote: > >> > >> separates control from computation. > >> > >> It seems as if Haskell would be better for iterative matrix methods > >> rather than direct calculation. > >> > >> -- > >> -- > >> Regards, > >> KC > >> > >> _______________________________________________ > >> Haskell-Cafe mailing list > >> Haskell-Cafe at haskell.org > >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > > > -- > -- > Regards, > KC > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sol at typeful.net Wed Sep 5 22:29:15 2012 From: sol at typeful.net (Simon Hengel) Date: Wed, 5 Sep 2012 22:29:15 +0200 Subject: [Haskell-cafe] Monospace code in Haddock In-Reply-To: <5047B203.70503@nh2.me> References: <5047AAB5.9040801@nh2.me> <20120905195021.GA14168@x200> <5047ADB6.2050904@nh2.me> <20120905200443.GA15308@x200> <5047B203.70503@nh2.me> Message-ID: <20120905202915.GA16791@x200> On Wed, Sep 05, 2012 at 09:11:47PM +0100, Niklas Hamb?chen wrote: > When you write: > > -- | This function returns the string @hello@ > > and you have a function called hello in scope, haddock will hyperlink > the the above hello to that function, which is confusing if your > monospace string has actually nothing to do with that function. > > In other words: Haddock always links to your functions in inline > monospaced text, and you can't turn that off. > > -- | Gives you @\hello\@ > > will therefore link to functions 'span' and 'hello' if they exist. As far as I know Haddock markup is interpreted withing @-blocks. So if you write @`foo`@ it will get linked, but if you just write @foo@ it should not be linked. If you write @\`foo`@ it should again not be linked. It may be awkward at times, but I think you should be able to achieve what you want, no? Please give a self-contained minimal example that illustrates your issue, if this still does not help. Cheers, Simon From mail at nh2.me Thu Sep 6 00:54:32 2012 From: mail at nh2.me (=?ISO-8859-1?Q?Niklas_Hamb=FCchen?=) Date: Wed, 05 Sep 2012 23:54:32 +0100 Subject: [Haskell-cafe] Monospace code in Haddock In-Reply-To: <20120905202915.GA16791@x200> References: <5047AAB5.9040801@nh2.me> <20120905195021.GA14168@x200> <5047ADB6.2050904@nh2.me> <20120905200443.GA15308@x200> <5047B203.70503@nh2.me> <20120905202915.GA16791@x200> Message-ID: <5047D828.6080400@nh2.me> You are right, if I escape as you describe, it works. However, all the makes it quite hard to read in code, and as people often read the code when dealing with Haskell, I will probably stick with the non-inline approach. That also gives a nice blue highlighting in haddocks in addition to the monospace. On 05/09/12 21:29, Simon Hengel wrote: > On Wed, Sep 05, 2012 at 09:11:47PM +0100, Niklas Hamb?chen wrote: >> When you write: >> >> -- | This function returns the string @hello@ >> >> and you have a function called hello in scope, haddock will hyperlink >> the the above hello to that function, which is confusing if your >> monospace string has actually nothing to do with that function. >> >> In other words: Haddock always links to your functions in inline >> monospaced text, and you can't turn that off. >> >> -- | Gives you @\hello\@ >> >> will therefore link to functions 'span' and 'hello' if they exist. > > As far as I know Haddock markup is interpreted withing @-blocks. So if > you write @`foo`@ it will get linked, but if you just write @foo@ it > should not be linked. If you write @\`foo`@ it should again not be > linked. It may be awkward at times, but I think you should be able to > achieve what you want, no? > > Please give a self-contained minimal example that illustrates your > issue, if this still does not help. > > Cheers, > Simon > From dstcruz at gmail.com Thu Sep 6 02:39:43 2012 From: dstcruz at gmail.com (Daniel Santa Cruz) Date: Wed, 5 Sep 2012 20:39:43 -0400 Subject: [Haskell-cafe] Haskell Weekly News: Issue 234 Message-ID: Welcome to issue 243 of the HWN, an issue covering crowd-sourced bits of information about Haskell from around the web. This issue covers the week of August 26 to September 01, 2012. Quotes of the Week * companion_cube: "I don't understand this article at all" edwardk: "Well, when you finish reading it, here's a follow-up article" Top Reddit Stories * Parsing with Haskell and Attoparsec Domain: newartisans.com, Score: 64, Comments: 8 On Reddit: [1] http://goo.gl/rrlQG Original: [2] http://goo.gl/aHlTJ * FRP - Release of reactive-banana-0.7. Finally features dynamic event switching! Domain: apfelmus.nfshost.com, Score: 48, Comments: 21 On Reddit: [3] http://goo.gl/5QnBl Original: [4] http://goo.gl/8dnLg * Combinatorrent - Writing Haskell Code for Fun and Profit [InfoQ] Domain: infoq.com, Score: 46, Comments: 14 On Reddit: [5] http://goo.gl/FE4OF Original: [6] http://goo.gl/feU7U * Putting it all together -- Example project that pulls together Snap, Blaze, OpenId, IxSet, AcidState, and Sessions. Domain: self.haskell, Score: 34, Comments: 3 On Reddit: [7] http://goo.gl/huFaI Original: [8] http://goo.gl/huFaI * Invert the Inversion of Control Domain: thev.net, Score: 32, Comments: 30 On Reddit: [9] http://goo.gl/1uO5a Original: [10] http://goo.gl/89UnF * A follow up on my initial experience and why there's still something immensely attractive about Haskell Domain: binarysculpting.com, Score: 27, Comments: 19 On Reddit: [11] http://goo.gl/3RLNO Original: [12] http://goo.gl/81YF2 * Haskim -- a convenient Haskell VIM distribution Domain: github.com, Score: 25, Comments: 19 On Reddit: [13] http://goo.gl/9sJ3O Original: [14] http://goo.gl/Wq0Rq * Introducing Perdure: persistence for acyclic immutable data Domain: hackage.haskell.org, Score: 23, Comments: 12 On Reddit: [15] http://goo.gl/ACWDi Original: [16] http://goo.gl/CSi57 * Existential types and data abstraction Domain: iveselov.info, Score: 22, Comments: On Reddit: [17] http://goo.gl/K6JGl Original: [18] http://goo.gl/GBYlW * I just realized that running monads is applying a left monad action Domain: self.haskell, Score: 20, Comments: 63 On Reddit: [19] http://goo.gl/Geus4 Original: [20] http://goo.gl/Geus4 Top StackOverflow Questions * How can I recover sharing in a GADT? votes: 14, answers: 2 Read on SO: [21] http://goo.gl/I3cuW * Constructing efficient monad instances on `Set` (and other containers with constraints) using the continuation monad votes: 13, answers: 2 Read on SO: [22] http://goo.gl/Ys4Uy * Numbers as multiplicative functions (weird but entertaining) votes: 12, answers: 1 Read on SO: [23] http://goo.gl/yN8KN * Game server in Haskell votes: 10, answers: 3 Read on SO: [24] http://goo.gl/QV9de * Why doesn't sortBy take (a -> a -> Bool)? votes: 10, answers: 5 Read on SO: [25] http://goo.gl/Y7EzD * Default type instances referring to each other votes: 9, answers: 1 Read on SO: [26] http://goo.gl/6cUG7 * Applying a fixed-length-vector-function to the inital part of a longer fixed-length-vector votes: 9, answers: 2 Read on SO: [27] http://goo.gl/03KcE * Haskell: example of function of type a -> a, besides the identity votes: 9, answers: 5 Read on SO: [28] http://goo.gl/q2UDW * Stack overflow when using Haskell sort function votes: 8, answers: 2 Read on SO: [29] http://goo.gl/D31Ku * How to navigate up inside a HUET Zipper votes: 7, answers: 2 Read on SO: [30] http://goo.gl/X7dE3 * Haskell : reference to previously updated elements of list within the update function votes: 7, answers: 6 Read on SO: [31] http://goo.gl/0yRIo * Is there any way to make parsec report ?shift-reduce? conflicts? votes: 7, answers: 1 Read on SO: [32] http://goo.gl/LQeDG * Haskell: how to write a monadic variadic function, with parameters using the monadic context votes: 7, answers: 1 Read on SO: [33] http://goo.gl/ThniY * Haskell parMap and parallelism votes: 7, answers: 1 Read on SO: [34] http://goo.gl/3qQHu Until next time, Daniel Santa Cruz References 1. http://newartisans.com/2012/08/parsing-with-haskell-and-attoparsec/ 2. http://www.reddit.com/r/haskell/comments/z2lir/parsing_with_haskell_and_attoparsec/ 3. http://apfelmus.nfshost.com/blog/2012/08/26-frp-banana-0-7.html 4. http://www.reddit.com/r/haskell/comments/yv6ku/frp_release_of_reactivebanana07_finally_features/ 5. http://www.infoq.com/presentations/Combinatorrent-Haskell-casestudy 6. http://www.reddit.com/r/haskell/comments/yzdyr/combinatorrent_writing_haskell_code_for_fun_and/ 7. http://www.reddit.com/r/haskell/comments/z4iay/putting_it_all_together_example_project_that/ 8. http://www.reddit.com/r/haskell/comments/z4iay/putting_it_all_together_example_project_that/ 9. http://www.thev.net/PaulLiu/invert-inversion.html 10. http://www.reddit.com/r/haskell/comments/z4inb/invert_the_inversion_of_control/ 11. http://binarysculpting.com/2012/09/01/theres-something-about-haskell/ 12. http://www.reddit.com/r/haskell/comments/z6idz/a_follow_up_on_my_initial_experience_and_why/ 13. https://github.com/jejansse/haskim 14. http://www.reddit.com/r/haskell/comments/z3orc/haskim_a_convenient_haskell_vim_distribution/ 15. http://hackage.haskell.org/package/perdure-0.1.2 16. http://www.reddit.com/r/haskell/comments/z2sc6/introducing_perdure_persistence_for_acyclic/ 17. http://iveselov.info/posts/2012-08-30-existential-types.html 18. http://www.reddit.com/r/haskell/comments/z1ojj/existential_types_and_data_abstraction/ 19. http://www.reddit.com/r/haskell/comments/ytovd/i_just_realized_that_running_monads_is_applying_a/ 20. http://www.reddit.com/r/haskell/comments/ytovd/i_just_realized_that_running_monads_is_applying_a/ 21. http://stackoverflow.com/questions/12230088/how-can-i-recover-sharing-in-a-gadt 22. http://stackoverflow.com/questions/12183656/constructing-efficient-monad-instances-on-set-and-other-containers-with-const 23. http://stackoverflow.com/questions/12133932/numbers-as-multiplicative-functions-weird-but-entertaining 24. http://stackoverflow.com/questions/12134097/game-server-in-haskell 25. http://stackoverflow.com/questions/12152561/why-doesnt-sortby-take-a-a-bool 26. http://stackoverflow.com/questions/12199324/default-type-instances-referring-to-each-other 27. http://stackoverflow.com/questions/12221080/applying-a-fixed-length-vector-function-to-the-inital-part-of-a-longer-fixed-len 28. http://stackoverflow.com/questions/12230820/haskell-example-of-function-of-type-a-a-besides-the-identity 29. http://stackoverflow.com/questions/12203380/stack-overflow-when-using-haskell-sort-function 30. http://stackoverflow.com/questions/12129300/how-to-navigate-up-inside-a-huet-zipper 31. http://stackoverflow.com/questions/12144973/haskell-reference-to-previously-updated-elements-of-list-within-the-update-fun 32. http://stackoverflow.com/questions/12170780/is-there-any-way-to-make-parsec-report-shift-reduce-conflicts 33. http://stackoverflow.com/questions/12175912/haskell-how-to-write-a-monadic-variadic-function-with-parameters-using-the-mon 34. http://stackoverflow.com/questions/12224842/haskell-parmap-and-parallelism -------------- next part -------------- An HTML attachment was scrubbed... URL: From agocorona at gmail.com Thu Sep 6 11:37:37 2012 From: agocorona at gmail.com (Alberto G. Corona ) Date: Thu, 6 Sep 2012 11:37:37 +0200 Subject: [Haskell-cafe] From monads to monoids in a small category In-Reply-To: References: Message-ID: Moreover, `m a` is 'a' plus some terminal element , for example Nothing, [], Left _ etc, So a morphism (a -> m a) contains all the morphisms of (m a -> m a). 2012/9/5 Alberto G. Corona : > Alexander, > > > In my post (excuses for my dyslexia) I try to demonstrate that the > codomain (m a), from the point of view of C. Theory, can be seen as > 'a' plus, optionally, some additional element, so a monadic morphism > (a -> m a) is part of a endofunctor in (m a -> m a) > > When considering the concept of arrow from category theory, (not the > concept of function), a point in the domain can "send" more than one > arrow to the codomain, while a function do not. I think that this is > the most interesting part of the interpretation, if I?m right. > > About this, I found this article revealing: > > http://cdsmith.wordpress.com/2012/04/18/why-do-monads-matter/ > > Therefore, codomains of (a -> m a) which are containers with multiple > a elements can be considered as multi-arrow morphisms from 'a' to 'a' > with the optional addition of some special elements that denote > special conditions. > > > For example > > (a -> [a]) > > May be considered as the general signature of the morphisms from the > set 'a' to the set ('a' + []) > > So a monadic transformation (a -> [a]) can be considered as a point > transformation of a endofunctor within the set (a + []). > > > Alberto > > > 2012/9/5 Alexander Solla : >> >> >> On Tue, Sep 4, 2012 at 4:21 PM, Alexander Solla >> wrote: >>> >>> >>> >>> On Tue, Sep 4, 2012 at 3:39 AM, Alberto G. Corona >>> wrote: >>>> >>>> "Monads are monoids in the category of endofunctors" >>>> >>>> This Monoid instance for the endofunctors of the set of all elements >>>> of (m a) typematch in Haskell with FlexibleInstances: >>>> >>>> instance Monad m => Monoid (a -> m a) where >>>> mappend = (>=>) -- kleisly operator >>>> mempty = return >>> >>> >>> The objects of a Kliesli category for a monad m aren't endofunctors. You >>> want something like: >>> >>> instance Monad m => Monoid (m a -> m (m a)) where ... >>> >>> /These/ are endofunctors, in virtue of join transforming an m (m a) into >>> an (m a). >> >> >> Actually, even these aren't endofunctors, for a similar reason that : you >> "really" want something like >> >> instance Monad m => Monoid (m a -> m a) where >> mempty = id >> mappend = undefined -- exercise left to the reader >> >> (i.e., you want to do plumbing through the Eilenberg-Moore category for a >> monad, instead of the Kliesli category for a monad -- my last message >> exposes the kind of plumping you want, but not the right types.) From amy at nualeargais.ie Thu Sep 6 11:42:19 2012 From: amy at nualeargais.ie (Amy de =?utf-8?b?QnVpdGzDqWly?=) Date: Thu, 6 Sep 2012 09:42:19 +0000 (UTC) Subject: [Haskell-cafe] ANNOUNCE: grid-1.1 Message-ID: I'm happy to announce a new package called grid: http://hackage.haskell.org/package/grid https://github.com/mhwombat/grid/wiki (wiki) Grid provides tools for working with regular arrangements of tiles, such as might be used in a board game or self-organising map (SOM). Grid currently supports triangular, square, and hexagonal tiles, with various 2D and toroidal layouts. If you need a tile shape or layout that isn't currently provided, please let me know. See Math.Geometry.Grid for an example of how to use the package. Suggestions for improvement are welcome. From alfredo.dinapoli at gmail.com Thu Sep 6 12:37:14 2012 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Thu, 6 Sep 2012 10:37:14 +0000 Subject: [Haskell-cafe] ANNOUNCE: grid-1.1 In-Reply-To: References: Message-ID: It seems cool, looking forward to play with it! On 6 September 2012 09:42, Amy de Buitl?ir wrote: > I'm happy to announce a new package called grid: > > http://hackage.haskell.org/package/grid > https://github.com/mhwombat/grid/wiki (wiki) > > Grid provides tools for working with regular arrangements of tiles, such as > might be used in a board game or self-organising map (SOM). Grid currently > supports triangular, square, and hexagonal tiles, with various 2D and > toroidal > layouts. If you need a tile shape or layout that isn't currently provided, > please let me know. See Math.Geometry.Grid for an example of how to use the > package. Suggestions for improvement are welcome. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at paulvisschers.net Thu Sep 6 13:28:13 2012 From: mail at paulvisschers.net (Paul Visschers) Date: Thu, 6 Sep 2012 13:28:13 +0200 Subject: [Haskell-cafe] ANNOUNCE: grid-1.1 In-Reply-To: References: Message-ID: Looks nice. Does it scale well to millions of elements, and can it handle 3D? On Thu, Sep 6, 2012 at 12:37 PM, Alfredo Di Napoli < alfredo.dinapoli at gmail.com> wrote: > It seems cool, looking forward to play with it! > > > On 6 September 2012 09:42, Amy de Buitl?ir wrote: > >> I'm happy to announce a new package called grid: >> >> http://hackage.haskell.org/package/grid >> https://github.com/mhwombat/grid/wiki (wiki) >> >> Grid provides tools for working with regular arrangements of tiles, such >> as >> might be used in a board game or self-organising map (SOM). Grid currently >> supports triangular, square, and hexagonal tiles, with various 2D and >> toroidal >> layouts. If you need a tile shape or layout that isn't currently provided, >> please let me know. See Math.Geometry.Grid for an example of how to use >> the >> package. Suggestions for improvement are welcome. >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From amy at nualeargais.ie Thu Sep 6 14:04:09 2012 From: amy at nualeargais.ie (Amy de =?utf-8?b?QnVpdGzDqWly?=) Date: Thu, 6 Sep 2012 12:04:09 +0000 (UTC) Subject: [Haskell-cafe] ANNOUNCE: grid-1.1 References: Message-ID: Paul Visschers paulvisschers.net> writes: > Looks nice. Does it scale well to millions of elements, and can it handle 3D? The current implementation wouldn't scale well to millions of elements, but it shouldn't take much tweaking to support that. Currently, when a grid is constructed, the list of all possible indices is constructed as well, so that calls to the "indices" function are fast. To support large numbers of tiles, I would instead generate all possible indices only when the "indices" function is called. Then the indices function would be too slow to be usable for more than, say, 50,000 tiles. But perhaps you don't need that function. At present, the only 3D support I have is for square tiles on the surface of the torus. I could add more tile shapes on the surface of the torus or other 3D shapes. I could also add support for 3D "tiles" (e.g., cubes, pyramids) in a 3D volume, if that's what you need. Let me know what your needs are and I'll try to incorporate it. From byorgey at seas.upenn.edu Thu Sep 6 16:40:52 2012 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Thu, 6 Sep 2012 10:40:52 -0400 Subject: [Haskell-cafe] ANNOUNCE: grid-1.1 In-Reply-To: References: Message-ID: <20120906144051.GA15500@seas.upenn.edu> On Thu, Sep 06, 2012 at 09:42:19AM +0000, Amy de Buitl?ir wrote: > I'm happy to announce a new package called grid: > > http://hackage.haskell.org/package/grid > https://github.com/mhwombat/grid/wiki (wiki) Looks neat! By the way, the URLs within the Haddock documentation are formatted improperly (because Haddock interprets the forward slashes as italic markers). You should place the URLs within angle brackets like and Haddock will turn them into real clickable links. -Brent From krismicinski at gmail.com Thu Sep 6 18:05:21 2012 From: krismicinski at gmail.com (Kristopher Micinski) Date: Thu, 6 Sep 2012 12:05:21 -0400 Subject: [Haskell-cafe] ANNOUNCE: grid-1.1 In-Reply-To: References: Message-ID: On Thu, Sep 6, 2012 at 8:04 AM, Amy de Buitl?ir wrote: > Paul Visschers paulvisschers.net> writes: > >> Looks nice. Does it scale well to millions of elements, and can it handle 3D? > > The current implementation wouldn't scale well to millions of elements, but it > shouldn't take much tweaking to support that. Currently, when a grid is > constructed, the list of all possible indices is constructed as well, so that > calls to the "indices" function are fast. To support large numbers of tiles, I > would instead generate all possible indices only when the "indices" function is > called. Then the indices function would be too slow to be usable for more than, > say, 50,000 tiles. But perhaps you don't need that function. > It seems like you should be able to stick this behind some abstraction so that you can support multiple implementations for grids (i.e., currently storing indices as you mention, but could support other implementations with different trade offs ...)? kris From amy at nualeargais.ie Thu Sep 6 18:36:24 2012 From: amy at nualeargais.ie (Amy de =?utf-8?b?QnVpdGzDqWly?=) Date: Thu, 6 Sep 2012 16:36:24 +0000 (UTC) Subject: [Haskell-cafe] ANNOUNCE: grid-1.1 References: Message-ID: > It seems like you should be able to stick this behind some abstraction > so that you can support multiple implementations for grids (i.e., > currently storing indices as you mention, but could support other > implementations with different trade offs ...)? > > kris Yes, there's a Grid typeclass which anyone can extend. The minimal complete definition is: indices, distance, and size. There are default implementations of the other functions, but you can also develop your own. So as you suggest, it would be easy for me to add other grid implementations that would live side-by-side with the current implementations, but would have different trade-offs. From amy at nualeargais.ie Thu Sep 6 18:38:00 2012 From: amy at nualeargais.ie (Amy de =?utf-8?b?QnVpdGzDqWly?=) Date: Thu, 6 Sep 2012 16:38:00 +0000 (UTC) Subject: [Haskell-cafe] ANNOUNCE: grid-1.1 References: <20120906144051.GA15500@seas.upenn.edu> Message-ID: Brent Yorgey seas.upenn.edu> writes: > Looks neat! By the way, the URLs within the Haddock documentation are > formatted improperly... Cheers! I'll fix that. From bo at ct.de Thu Sep 6 18:46:14 2012 From: bo at ct.de (=?ISO-8859-15?Q?Harald_B=F6geholz?=) Date: Thu, 06 Sep 2012 18:46:14 +0200 Subject: [Haskell-cafe] performance issues with popCount Message-ID: <5048D356.4090609@ct.de> Dear Haskell Cafe, I am struggling with the performance of the popCount function from Data.Bits. To be more precise: I downloaded the Haskell Platform 2012.2.0.0 from http://hackage.haskell.org/platform/ (64 bit, Mac OS X). In this version I found the popCount function to be broken. If I look in the online documentation at http://hackage.haskell.org/packages/archive/base/4.5.1.0/doc/html/src/Data-Bits.html#popCount it is already fixed, but included with my Haskell Platform was the broken version. Anyway, I tried this version popCount :: Integer -> Int popCount = go 0 where go c 0 = c go c w = go (c+1) (w .&. (w - 1)) and profiling showed that my program spent 80 % of its time counting bits. So I thought I'm clever and implement a table-based version like this: popCount' :: Integer -> Int popCount' = go 0 where go c 0 = c go c w = go (c+1) (w .&. (w - 1)) popCountN = 10 popCountMask :: Integer popCountMask = shift 1 popCountN - 1 popCountTable :: Array Integer Int popCountTable = listArray (0, popCountMask) $ map popCount' [0 .. popCountMask] popCount :: Integer -> Int popCount 0 = 0 popCount x = popCountTable ! (x .&. popCountMask) + popCount (x `shiftR` popCountN) turns out this is even slower ... now my program spends 90 % of its time counting bits :-(. Any hints? Thanks -- Harald B?geholz (PGP key available from servers) Redaktion c't Tel.: +49 511 5352-300 Fax: +49 511 5352-417 http://www.ct.de/ int f[9814],b,c=9814,g,i;long a=1e4,d,e,h; main(){for(;b=c,c-=14;i=printf("%04d",e+d/a),e=d%a) while(g=--b*2)d=h*b+a*(i?f[b]:a/5),h=d/--g,f[b]=d%g;} (Arndt/Haenel) Affe Apfel Vergaser /* Heise Zeitschriften Verlag GmbH & Co. KG * Karl-Wiechert-Allee 10 * 30625 Hannover * Registergericht: Amtsgericht Hannover HRA 26709 * Pers?nlich haftende Gesellschafterin: Heise Zeitschriften Verlag * Gesch?ftsf?hrung GmbH * Registergericht: Amtsgericht Hannover, HRB 60405 * Gesch?ftsf?hrer: Ansgar Heise, Dr. Alfons Schr?der */ From thomas.dubuisson at gmail.com Thu Sep 6 19:45:22 2012 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Thu, 6 Sep 2012 10:45:22 -0700 Subject: [Haskell-cafe] performance issues with popCount In-Reply-To: <5048D356.4090609@ct.de> References: <5048D356.4090609@ct.de> Message-ID: What _should_ be happening is we should be calling GMP's popcount function when using integer-gmp. As for your code I worry about it: * being too lazy, so add some bang patterns or seq * using boxed arrays, so use unboxed * indexing arrays by Integer comparison even when those are small integers - just index by Int. * will never terminate with negative values. Sure it's a solution but calling 'error' is more appropriate. But really I hope you spend the time fixing base, not making a one-off solution that will still be slow. Cheers, Thomas On Thu, Sep 6, 2012 at 9:46 AM, Harald B?geholz wrote: > Dear Haskell Cafe, > > > I am struggling with the performance of the popCount function from > Data.Bits. > > To be more precise: I downloaded the Haskell Platform 2012.2.0.0 from > http://hackage.haskell.org/platform/ (64 bit, Mac OS X). In this version > I found the popCount function to be broken. If I look in the online > documentation at > http://hackage.haskell.org/packages/archive/base/4.5.1.0/doc/html/src/Data-Bits.html#popCount > it is already fixed, but included with my Haskell Platform was the > broken version. > > Anyway, I tried this version > > popCount :: Integer -> Int > popCount = go 0 > where > go c 0 = c > go c w = go (c+1) (w .&. (w - 1)) > > and profiling showed that my program spent 80 % of its time counting bits. > > So I thought I'm clever and implement a table-based version like this: > > popCount' :: Integer -> Int > popCount' = go 0 > where > go c 0 = c > go c w = go (c+1) (w .&. (w - 1)) > > popCountN = 10 > > popCountMask :: Integer > popCountMask = shift 1 popCountN - 1 > > popCountTable :: Array Integer Int > popCountTable = listArray (0, popCountMask) $ map popCount' [0 .. > popCountMask] > > popCount :: Integer -> Int > popCount 0 = 0 > popCount x = popCountTable ! (x .&. popCountMask) + popCount (x `shiftR` > popCountN) > > > turns out this is even slower ... now my program spends 90 % of its time > counting bits :-(. > > > Any hints? > > > Thanks > -- > Harald B?geholz (PGP key available from servers) > Redaktion c't Tel.: +49 511 5352-300 Fax: +49 511 5352-417 > http://www.ct.de/ > > int f[9814],b,c=9814,g,i;long a=1e4,d,e,h; > main(){for(;b=c,c-=14;i=printf("%04d",e+d/a),e=d%a) > while(g=--b*2)d=h*b+a*(i?f[b]:a/5),h=d/--g,f[b]=d%g;} > (Arndt/Haenel) > > Affe Apfel Vergaser > > /* Heise Zeitschriften Verlag GmbH & Co. KG * Karl-Wiechert-Allee 10 * > 30625 Hannover * Registergericht: Amtsgericht Hannover HRA 26709 * > Pers?nlich haftende Gesellschafterin: Heise Zeitschriften Verlag * > Gesch?ftsf?hrung GmbH * Registergericht: Amtsgericht Hannover, HRB > 60405 * Gesch?ftsf?hrer: Ansgar Heise, Dr. Alfons Schr?der */ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From johan.tibell at gmail.com Thu Sep 6 21:07:28 2012 From: johan.tibell at gmail.com (Johan Tibell) Date: Thu, 6 Sep 2012 12:07:28 -0700 Subject: [Haskell-cafe] performance issues with popCount In-Reply-To: <5048D356.4090609@ct.de> References: <5048D356.4090609@ct.de> Message-ID: Hi Harald, On Thu, Sep 6, 2012 at 9:46 AM, Harald B?geholz wrote: > Anyway, I tried this version > > popCount :: Integer -> Int > popCount = go 0 > where > go c 0 = c > go c w = go (c+1) (w .&. (w - 1)) > > and profiling showed that my program spent 80 % of its time counting bits. This is very much a placeholder version. I didn't spend any time optimizing the Integer implementation (the implementations for fixed sized type are quite optimal however). > So I thought I'm clever and implement a table-based version like this: > > popCount' :: Integer -> Int > popCount' = go 0 > where > go c 0 = c > go c w = go (c+1) (w .&. (w - 1)) > > popCountN = 10 > > popCountMask :: Integer > popCountMask = shift 1 popCountN - 1 > > popCountTable :: Array Integer Int > popCountTable = listArray (0, popCountMask) $ map popCount' [0 .. > popCountMask] > > popCount :: Integer -> Int > popCount 0 = 0 > popCount x = popCountTable ! (x .&. popCountMask) + popCount (x `shiftR` > popCountN) Have a look at the popCount implementation for e.g. Int, which are written in C and called through the FFI: https://github.com/ghc/packages-ghc-prim/blob/master/cbits/popcnt.c Perhaps you could create a binding to the GMP mpz_popcount function, as Integer is implemented using GMP already? It would make a nice patch to the Data.Bits module. Note that you'd still need a fallback for those that use integer-simple instead of integer-gmp. If you don't want to do that you can take this function: uint8 popcnt8(uint8 x) { return popcount_tab[(unsigned char)x]; } and call it repeatedly (via the FFI) for each byte in your Integer. (Use the popcount_tab I linked to above.) -- Johan From david.feuer at gmail.com Fri Sep 7 01:35:43 2012 From: david.feuer at gmail.com (David Feuer) Date: Thu, 6 Sep 2012 19:35:43 -0400 Subject: [Haskell-cafe] Haskell with all the safeties off In-Reply-To: References: Message-ID: I have no plans to do such a thing anytime soon, but is there a way to tell GHC to allow nasal demons to fly if the program forces bottom? This mode of operation would seem to be a useful optimization when compiling a program produced by Coq or similar, enabling various transformations that can turn bottom into non-bottom, eliminating runtime checks in incomplete patterns, etc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ezyang at MIT.EDU Fri Sep 7 08:00:01 2012 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Fri, 07 Sep 2012 02:00:01 -0400 Subject: [Haskell-cafe] Haskell with all the safeties off In-Reply-To: References: Message-ID: <1346997477-sup-2170@javelin> Haskell already does this, to some extent, in the design of imprecise exceptions. But note that bottom *does* have well defined behavior, so these "optimizations" are not very desirable. Edward Excerpts from David Feuer's message of Thu Sep 06 19:35:43 -0400 2012: > I have no plans to do such a thing anytime soon, but is there a way to tell > GHC to allow nasal demons to fly if the program forces bottom? This mode of > operation would seem to be a useful optimization when compiling a program > produced by Coq or similar, enabling various transformations that can turn > bottom into non-bottom, eliminating runtime checks in incomplete patterns, > etc. From niklas.broberg at gmail.com Fri Sep 7 11:57:18 2012 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Fri, 7 Sep 2012 11:57:18 +0200 Subject: [Haskell-cafe] ANNOUNCE: haskell-src-exts 1.13.5 Message-ID: Fellow Haskelleers, I'm pleased to announce the release of haskell-src-exts-1.13.5! * On hackage: http://hackage.haskell.org/package/haskell-src-exts * Via cabal: cabal install haskell-src-exts * Darcs repo: http://code.haskell.org/haskell-src-exts There are two primary reasons for this release: 1) to add the requested support for UHC's 'js' FFI calling convention (in 1.13.4), and 2) to export a stand-alone token stream lexer (in 1.13.5). NOTE: If after reading the above, you think "wow, a token stream lexer, I'll use that for some kind of refactoring tool", then you're most likely wrong. Please contact me in that case and I'll tell you why. :-) A probably unnecessary warning: This release may fail to parse some files that were previously possible to parse, if they included RULES pragmas using 'forall' as a varid. I really doubt any such exist, and they would not have been accepted by GHC if they did, so I sincerely doubt that anyone will be effected by this. Changelog: 1.13.4 --> 1.13.5 =============== * Expose Language.Haskell.Exts.Lexer, which implements a standalone token stream lexer. The module is re-exported both by Language.Haskell.Exts and by Language.Haskell.Exts.Annotated. 1.13.3 --> 1.13.4 =============== * Fix bug where operators starting with # written in parentheses would not be parsed when UnboxedTuples is turned on. Now works. * Allow 'family' and 'forall' as (non-type) varid's. This adds one more shift/reduce conflict to the parser, and its resolution means that '{-# RULES "name" forall = ... #-}' is not allowed. * Complete the set of FFI calling conventions from the Haskell 2010 report (even if no compiler implements them). Also include the 'js' calling convention, supported by UHC. Cheers, /Niklas -------------- next part -------------- An HTML attachment was scrubbed... URL: From nicolas at incubaid.com Fri Sep 7 13:54:55 2012 From: nicolas at incubaid.com (Nicolas Trangez) Date: Fri, 07 Sep 2012 13:54:55 +0200 Subject: [Haskell-cafe] performance issues with popCount In-Reply-To: References: <5048D356.4090609@ct.de> Message-ID: <1347018895.1895.94.camel@tau.nicolast.be> On Thu, 2012-09-06 at 12:07 -0700, Johan Tibell wrote: > Have a look at the popCount implementation for e.g. Int, which are > written in C and called through the FFI: > > https://github.com/ghc/packages-ghc-prim/blob/master/cbits/popcnt.c Out of interest: isn't this compiled into the popCnt# primop (and popcnt instruction on SSE4.2)? I recently noticed Data.IntSet also contains a fairly basic "bitcount" implementation [1]. Is this kept as-is for a reason, instead of using popCount from Data.Bits? Nicolas [1] https://github.com/ghc/packages-containers/blob/master/Data/IntSet/Base.hs#L1459 From david.waern at gmail.com Fri Sep 7 15:19:36 2012 From: david.waern at gmail.com (David Waern) Date: Fri, 7 Sep 2012 15:19:36 +0200 Subject: [Haskell-cafe] ANNOUCE: Haddock 2.10.0 and 2.11.0 Message-ID: -------------------------------------------- -- Haddock 2.10.0 and 2.11.0 -------------------------------------------- Two new versions of Haddock have been uploaded to Hackage: version 2.10.0 which comes with GHC 7.4.2 and 2.11.0 which comes with the new GHC 7.6.1! -------------------------------------------- -- Changes in version 2.12.0 -------------------------------------------- * Labeled URLs (e.g ) * Improved memory usage (new dependency: deepseq) -------------------------------------------- -- Changes in version 2.11.0 -------------------------------------------- * Show deprecation messages for identifiers * List identifiers declared on the same line (with a common type) separately * Don't crash on unicode strings in doc comments * Fix reporting of modules safe haskell mode * Fix a case where we were generating invalid xhtml * Improved --qual option (no crashes, proper error messages) * A new --qual option "aliased" which qualifies identifers by the module alias used in the source code * The Haddock API restores GHC's static flags after invocation * Access to unexported identifiers through the Haddock API again -------------------------------------------- -- Links -------------------------------------------- Homepage: http://www.haskell.org/haddock Hackage page: http://hackage.haskell.org/package/haddock-2.12.0 Bugtracker and wiki: http://trac.haskell.org/haddock Mailing list: haddock at projects.haskell.org Code repository: http://darcs.haskell.org/haddock.git -------------------------------------------- -- Contributors -------------------------------------------- The following people contributed patches to this release: Paolo Capriotti Simon Hengel Ian Lynagh Simon Peyton Jones Iavor S. Diatchki David Terei Henning Thielemann David Waern -------------------------------------------- -- Get Involved -------------------------------------------- We would be very happy to get more contributors. To get involved, start by grabbing the code: http://darcs.haskell.org/haddock.git Then take a look at the bug and feature tracker for things to work on: http://trac.haskell.org/haddock From alfredo.dinapoli at gmail.com Fri Sep 7 15:30:11 2012 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Fri, 7 Sep 2012 13:30:11 +0000 Subject: [Haskell-cafe] ANNOUCE: Haddock 2.10.0 and 2.11.0 In-Reply-To: References: Message-ID: Great news! On 7 September 2012 13:19, David Waern wrote: > -------------------------------------------- > -- Haddock 2.10.0 and 2.11.0 > -------------------------------------------- > > Two new versions of Haddock have been uploaded to Hackage: version > 2.10.0 which comes with GHC 7.4.2 and 2.11.0 which comes with the new > GHC 7.6.1! > > -------------------------------------------- > -- Changes in version 2.12.0 > -------------------------------------------- > > * Labeled URLs (e.g ) > > * Improved memory usage (new dependency: deepseq) > > -------------------------------------------- > -- Changes in version 2.11.0 > -------------------------------------------- > > * Show deprecation messages for identifiers > > * List identifiers declared on the same line (with a common type) > separately > > * Don't crash on unicode strings in doc comments > > * Fix reporting of modules safe haskell mode > > * Fix a case where we were generating invalid xhtml > > * Improved --qual option (no crashes, proper error messages) > > * A new --qual option "aliased" which qualifies identifers by the module > alias > used in the source code > > * The Haddock API restores GHC's static flags after invocation > > * Access to unexported identifiers through the Haddock API again > > -------------------------------------------- > -- Links > -------------------------------------------- > > Homepage: > http://www.haskell.org/haddock > > Hackage page: > http://hackage.haskell.org/package/haddock-2.12.0 > > Bugtracker and wiki: > http://trac.haskell.org/haddock > > Mailing list: > haddock at projects.haskell.org > > Code repository: > http://darcs.haskell.org/haddock.git > > -------------------------------------------- > -- Contributors > -------------------------------------------- > > The following people contributed patches to this release: > > Paolo Capriotti > Simon Hengel > Ian Lynagh > Simon Peyton Jones > Iavor S. Diatchki > David Terei > Henning Thielemann > David Waern > > -------------------------------------------- > -- Get Involved > -------------------------------------------- > > We would be very happy to get more contributors. To get involved, start by > grabbing the code: > > http://darcs.haskell.org/haddock.git > > Then take a look at the bug and feature tracker for things to work on: > > http://trac.haskell.org/haddock > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From semen at trygub.com Fri Sep 7 17:04:52 2012 From: semen at trygub.com (Semen Trygubenko) Date: Fri, 7 Sep 2012 16:04:52 +0100 Subject: [Haskell-cafe] parsing ghc type errors Message-ID: <20120907150452.GX5959@trygub.com> Dear Haskell-cafe, When dealing with ghc type errors I often see messages like Couldn't match expected type `ghc-prim:GHC.Types.IO{tc 32I} MyTypeNameHere{tc r1d8}' with actual type `ghc-prim:GHC.Types.IO{tc 32I} MyOtherTypeNameHere{tc r1d8}' Could you please help me understand the meaning of the entities in {} and why are they useful, or point to a source of information about them? Messages where familiar types are referenced are easy to read, but occasionally I get messages of the sort with actual type `[( b0{tv t3p} [tau] :: ghc-prim:GHC.Prim.*{(w) tc 34d} )]' How do I go about reading the type [( b0{tv t3p} [tau] :: ghc-prim:GHC.Prim.*{(w) tc 34d} )] ? E.g., where the names 'b0' and '[tau]' come from? What does '(w)' in '{(w) tc 34d}' mean? Thank you, Semen -- ????? ?????????? -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: From david.feuer at gmail.com Fri Sep 7 18:06:00 2012 From: david.feuer at gmail.com (David Feuer) Date: Fri, 7 Sep 2012 12:06:00 -0400 Subject: [Haskell-cafe] Haskell with all the safeties off In-Reply-To: <1346997477-sup-2170@javelin> References: <1346997477-sup-2170@javelin> Message-ID: On Sep 7, 2012 2:00 AM, "Edward Z. Yang" @ mit.edu > wrote: > > Haskell already does this, to some extent, in the design of imprecise > exceptions. But note that bottom *does* have well defined behavior, so > these "optimizations" are not very desirable. They're not *usually* desirable, but when the code has been proven not to fall into bottom, there doesn't seem to be much point in ensuring that things will work right if it does. This sort of thing only really makes sense when using Haskell as a compiler target. > Edward > > Excerpts from David Feuer's message of Thu Sep 06 19:35:43 -0400 2012: > > I have no plans to do such a thing anytime soon, but is there a way to tell > > GHC to allow nasal demons to fly if the program forces bottom? This mode of > > operation would seem to be a useful optimization when compiling a program > > produced by Coq or similar, enabling various transformations that can turn > > bottom into non-bottom, eliminating runtime checks in incomplete patterns, > > etc. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ezyang at MIT.EDU Fri Sep 7 18:56:19 2012 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Fri, 07 Sep 2012 09:56:19 -0700 Subject: [Haskell-cafe] Haskell with all the safeties off In-Reply-To: References: <1346997477-sup-2170@javelin> Message-ID: <1347036576-sup-5669@javelin> Excerpts from David Feuer's message of Fri Sep 07 12:06:00 -0400 2012: > They're not *usually* desirable, but when the code has been proven not to > fall into bottom, there doesn't seem to be much point in ensuring that > things will work right if it does. This sort of thing only really makes > sense when using Haskell as a compiler target. OK, so it sounds like what you're more looking for is a way of giving extra information to GHC's strictness analyzer, so that it is more willing to unbox/skip making thunks even when the analyzer itself isn't able to figure it out. But it seems to me that in any such case, there might be a way to add seq's which have equivalent effect. Edward From johan.tibell at gmail.com Sat Sep 8 00:55:43 2012 From: johan.tibell at gmail.com (Johan Tibell) Date: Fri, 7 Sep 2012 15:55:43 -0700 Subject: [Haskell-cafe] performance issues with popCount In-Reply-To: <1347018895.1895.94.camel@tau.nicolast.be> References: <5048D356.4090609@ct.de> <1347018895.1895.94.camel@tau.nicolast.be> Message-ID: On Fri, Sep 7, 2012 at 4:54 AM, Nicolas Trangez wrote: > On Thu, 2012-09-06 at 12:07 -0700, Johan Tibell wrote: >> Have a look at the popCount implementation for e.g. Int, which are >> written in C and called through the FFI: >> >> https://github.com/ghc/packages-ghc-prim/blob/master/cbits/popcnt.c > > Out of interest: isn't this compiled into the popCnt# primop (and popcnt > instruction on SSE4.2)? It's the other way around the popCnt# primop is compiled into either calls to these C functions or into the popcnt instruction, if -msse4.2 is given. > I recently noticed Data.IntSet also contains a fairly basic "bitcount" > implementation [1]. Is this kept as-is for a reason, instead of using > popCount from Data.Bits? I don't think so, except that we want to support the last 3 released versions of GHC so we need to have a fallback if Data.Bits.popCount isn't defined. -- Johan From ivan.miljenovic at gmail.com Sat Sep 8 01:19:08 2012 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Sat, 8 Sep 2012 09:19:08 +1000 Subject: [Haskell-cafe] ANNOUCE: Haddock 2.10.0 and 2.11.0 In-Reply-To: References: Message-ID: On 7 September 2012 23:19, David Waern wrote: > -------------------------------------------- > -- Haddock 2.10.0 and 2.11.0 > -------------------------------------------- > > Two new versions of Haddock have been uploaded to Hackage: version > 2.10.0 which comes with GHC 7.4.2 and 2.11.0 which comes with the new > GHC 7.6.1! > > -------------------------------------------- > -- Changes in version 2.12.0 > -------------------------------------------- So either your changelog has the wrong versions, or else you listed the wrong versions above? ;-) (Or are you just teasing us with the features we'll have with Haddock when GHC 7.8 comes out?) More seriously, it seems there's an error building even 2.12.0 with GHC 7.6; is that correct? http://hackage.haskell.org/packages/archive/haddock/2.12.0/logs/failure/ghc-7.6 > > * Labeled URLs (e.g ) > > * Improved memory usage (new dependency: deepseq) > > -------------------------------------------- > -- Changes in version 2.11.0 > -------------------------------------------- > > * Show deprecation messages for identifiers > > * List identifiers declared on the same line (with a common type) separately > > * Don't crash on unicode strings in doc comments > > * Fix reporting of modules safe haskell mode > > * Fix a case where we were generating invalid xhtml > > * Improved --qual option (no crashes, proper error messages) > > * A new --qual option "aliased" which qualifies identifers by the module alias > used in the source code > > * The Haddock API restores GHC's static flags after invocation > > * Access to unexported identifiers through the Haddock API again > > -------------------------------------------- > -- Links > -------------------------------------------- > > Homepage: > http://www.haskell.org/haddock > > Hackage page: > http://hackage.haskell.org/package/haddock-2.12.0 > > Bugtracker and wiki: > http://trac.haskell.org/haddock > > Mailing list: > haddock at projects.haskell.org > > Code repository: > http://darcs.haskell.org/haddock.git > > -------------------------------------------- > -- Contributors > -------------------------------------------- > > The following people contributed patches to this release: > > Paolo Capriotti > Simon Hengel > Ian Lynagh > Simon Peyton Jones > Iavor S. Diatchki > David Terei > Henning Thielemann > David Waern > > -------------------------------------------- > -- Get Involved > -------------------------------------------- > > We would be very happy to get more contributors. To get involved, start by > grabbing the code: > > http://darcs.haskell.org/haddock.git > > Then take a look at the bug and feature tracker for things to work on: > > http://trac.haskell.org/haddock > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From alex at stangl.us Sat Sep 8 08:55:39 2012 From: alex at stangl.us (Alex Stangl) Date: Sat, 8 Sep 2012 01:55:39 -0500 Subject: [Haskell-cafe] List indexer Message-ID: <20120908065539.GA81973@scout.stangl.us> Hi, I have written a small "wrapper" to speed random-access to a list. The usage scenario I have in mind is a "stream" computation yielding an infinite list, and I want to randomly access elements w/o having to traverse the entire list from the beginning for each access. I suspected something similar must already exist, but nothing I looked at seemed to do the trick. IntMap seems to want a finite input list. Ditto for the various array types, except possibly dynamic array. Attached is the list indexer I came up with, and a small test program (I swap the commented-out lines to switch btw. list & list index tests). I am interested to hear any feedback on this -- whether it duplicates something that already exists, or whether there's a better approach, and comments on the code, etc. Also if somebody can suggest a better name (so as not to overlay the word index too much.) I'll publish it on hackage (or at least github) if people think it's useful. It sped up the program I initally wrote it for enormously. Thanks, Alex -------------- next part -------------- A non-text attachment was scrubbed... Name: ListIndex.hs Type: text/x-haskell Size: 2045 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ListIndexTest.hs Type: text/x-haskell Size: 852 bytes Desc: not available URL: From ierton at gmail.com Sat Sep 8 09:04:34 2012 From: ierton at gmail.com (Sergey Mironov) Date: Sat, 8 Sep 2012 11:04:34 +0400 Subject: [Haskell-cafe] package categories Message-ID: Hello list. Do we have a guideline for selecting correct category for a package being developed? I'd like to choose between Web.MyLib and Network.MyLib. Or probably just MyLib if I feel ambitious? Sergey. From sol at typeful.net Sat Sep 8 09:47:13 2012 From: sol at typeful.net (Simon Hengel) Date: Sat, 8 Sep 2012 09:47:13 +0200 Subject: [Haskell-cafe] ANNOUCE: Haddock 2.10.0 and 2.11.0 In-Reply-To: References: Message-ID: <20120908074713.GA2679@x200> On Sat, Sep 08, 2012 at 09:19:08AM +1000, Ivan Lazar Miljenovic wrote: > More seriously, it seems there's an error building even 2.12.0 with > GHC 7.6; is that correct? A functional version of Haddock 2.12.0 comes with GHC 7.6.1. This build error only affects you, if you want to use the Haddock API. But yes, if you want to use the Haddock API, you are currently stuck. Cheers, Simon From Ramana.Kumar at cl.cam.ac.uk Sat Sep 8 10:20:29 2012 From: Ramana.Kumar at cl.cam.ac.uk (Ramana Kumar) Date: Sat, 8 Sep 2012 09:20:29 +0100 Subject: [Haskell-cafe] Haskell with all the safeties off In-Reply-To: <1347036576-sup-5669@javelin> References: <1346997477-sup-2170@javelin> <1347036576-sup-5669@javelin> Message-ID: On Fri, Sep 7, 2012 at 5:56 PM, Edward Z. Yang wrote: > Excerpts from David Feuer's message of Fri Sep 07 12:06:00 -0400 2012: > > They're not *usually* desirable, but when the code has been proven not to > > fall into bottom, there doesn't seem to be much point in ensuring that > > things will work right if it does. This sort of thing only really makes > > sense when using Haskell as a compiler target. > > OK, so it sounds like what you're more looking for is a way of giving > extra information to GHC's strictness analyzer, so that it is more > willing to unbox/skip making thunks even when the analyzer itself isn't > able to figure it out. But it seems to me that in any such case, there > might be a way to add seq's which have equivalent effect. > But in the case that you've independently proven the code correct, it would be much more convenient to just tell GHC to "trust me" with a flag rather than having to go analyse and edit the code to put in the required seqs (thereby breaking the proof too...) > > Edward > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From patai_gergely at fastmail.fm Sat Sep 8 10:39:36 2012 From: patai_gergely at fastmail.fm (Patai Gergely) Date: Sat, 08 Sep 2012 10:39:36 +0200 Subject: [Haskell-cafe] ANN: LambdaCube 3D (purely functional rendering engine) is back in business Message-ID: <1347093576.23943.140661125187213.56F2AFD8@webmail.messagingengine.com> Hello all, We recently rebooted the LambdaCube project, which aims to provide a purely functional interface for GPU programming. The details and the background are described in our new blog [1], while the code can be found on GitHub [2]. Cheers, Gergely [1] http://lambdacube3d.wordpress.com/ [2] https://github.com/csabahruska/lc-dsl -- http://www.fastmail.fm - The professional email service From nicolas at incubaid.com Sat Sep 8 12:28:21 2012 From: nicolas at incubaid.com (Nicolas Trangez) Date: Sat, 08 Sep 2012 12:28:21 +0200 Subject: [Haskell-cafe] performance issues with popCount In-Reply-To: References: <5048D356.4090609@ct.de> <1347018895.1895.94.camel@tau.nicolast.be> Message-ID: <1347100101.1895.111.camel@tau.nicolast.be> On Fri, 2012-09-07 at 15:55 -0700, Johan Tibell wrote: > On Fri, Sep 7, 2012 at 4:54 AM, Nicolas Trangez wrote: > > On Thu, 2012-09-06 at 12:07 -0700, Johan Tibell wrote: > >> Have a look at the popCount implementation for e.g. Int, which are > >> written in C and called through the FFI: > >> > >> https://github.com/ghc/packages-ghc-prim/blob/master/cbits/popcnt.c > > > > Out of interest: isn't this compiled into the popCnt# primop (and popcnt > > instruction on SSE4.2)? > > It's the other way around the popCnt# primop is compiled into either > calls to these C functions or into the popcnt instruction, if -msse4.2 > is given. Yes, indeed. I was referring to Data.Bits.popCount, but looking back this was indeed completely non-obvious. My bad. > > I recently noticed Data.IntSet also contains a fairly basic "bitcount" > > implementation [1]. Is this kept as-is for a reason, instead of using > > popCount from Data.Bits? > > I don't think so, except that we want to support the last 3 released > versions of GHC so we need to have a fallback if Data.Bits.popCount > isn't defined. I might look into creating a (CPP-based) patch then. Nicolas From alfredo.dinapoli at gmail.com Sat Sep 8 14:23:57 2012 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Sat, 8 Sep 2012 14:23:57 +0200 Subject: [Haskell-cafe] ANN: LambdaCube 3D (purely functional rendering engine) is back in business In-Reply-To: <1347093576.23943.140661125187213.56F2AFD8@webmail.messagingengine.com> References: <1347093576.23943.140661125187213.56F2AFD8@webmail.messagingengine.com> Message-ID: <20120908122356.GA27878@gmail.com> Good luck for this new beginning! A. On Sat, Sep 08, 2012 at 10:39:36AM +0200, Patai Gergely wrote: > Hello all, > > We recently rebooted the LambdaCube project, which aims to provide a > purely functional interface for GPU programming. The details and the > background are described in our new blog [1], while the code can be > found on GitHub [2]. > > Cheers, > > Gergely > > [1] http://lambdacube3d.wordpress.com/ > [2] https://github.com/csabahruska/lc-dsl > > -- > http://www.fastmail.fm - The professional email service > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From radical at google.com Sat Sep 8 20:54:20 2012 From: radical at google.com (Alvaro Gutierrez) Date: Sat, 8 Sep 2012 14:54:20 -0400 Subject: [Haskell-cafe] ANN: LambdaCube 3D (purely functional rendering engine) is back in business In-Reply-To: <1347093576.23943.140661125187213.56F2AFD8@webmail.messagingengine.com> References: <1347093576.23943.140661125187213.56F2AFD8@webmail.messagingengine.com> Message-ID: On Sat, Sep 8, 2012 at 4:39 AM, Patai Gergely wrote: > Hello all, > > We recently rebooted the LambdaCube project, which aims to provide a > purely functional interface for GPU programming. The details and the > background are described in our new blog [1], while the code can be > found on GitHub [2]. This is awesome. The Quake3 level viewer in particular looks great. From hutch-lists at recursive.ca Sat Sep 8 21:08:06 2012 From: hutch-lists at recursive.ca (Bob Hutchison) Date: Sat, 8 Sep 2012 15:08:06 -0400 Subject: [Haskell-cafe] JavaScript (SpiderMonkey, V8, etc) embedded in GHC? Message-ID: <954564B0-C953-49E0-B9A9-FD8CBC9C3A66@recursive.ca> 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 From sedrikov at gmail.com Sat Sep 8 21:10:34 2012 From: sedrikov at gmail.com (AUGER =?UTF-8?B?Q8OpZHJpYw==?=) Date: Sat, 8 Sep 2012 21:10:34 +0200 Subject: [Haskell-cafe] Haskell with all the safeties off In-Reply-To: References: <1346997477-sup-2170@javelin> <1347036576-sup-5669@javelin> Message-ID: <20120908211034.083c3ae0@Dakkon.home> Le Sat, 8 Sep 2012 09:20:29 +0100, Ramana Kumar a ?crit : > On Fri, Sep 7, 2012 at 5:56 PM, Edward Z. Yang wrote: > > > Excerpts from David Feuer's message of Fri Sep 07 12:06:00 -0400 > > 2012: > > > They're not *usually* desirable, but when the code has been > > > proven not to fall into bottom, there doesn't seem to be much > > > point in ensuring that things will work right if it does. This > > > sort of thing only really makes sense when using Haskell as a > > > compiler target. > > > > OK, so it sounds like what you're more looking for is a way of > > giving extra information to GHC's strictness analyzer, so that it > > is more willing to unbox/skip making thunks even when the analyzer > > itself isn't able to figure it out. But it seems to me that in any > > such case, there might be a way to add seq's which have equivalent > > effect. > > > > But in the case that you've independently proven the code correct, it > would be much more convenient to just tell GHC to "trust me" with a > flag rather than having to go analyse and edit the code to put in the > required seqs (thereby breaking the proof too...) For Coq, I think that you can do something like: Definition seq {A B : Type} (a : A) (b : B) := b. Then you do your code the Haskell way. As seq is mainly the identity, it won't bother you for proofs (and won't break inductive definition using Fixpoint). And as I am pretty sure the extraction doesn't inline functions, you then just have to do something like: Extraction Constant seq "seq". (* I do not recall very well the syntay here, but it is documented *) Then your extracted code will place seq where you requested them. I am recompiling Coq, yet, so I cannot test it. This way, it won't break the proof (but you have to place more faith in the extraction system). > > > > > > Edward > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From ierton at gmail.com Sat Sep 8 23:44:35 2012 From: ierton at gmail.com (Sergey Mironov) Date: Sun, 9 Sep 2012 01:44:35 +0400 Subject: [Haskell-cafe] ANNOUNCE vkhs-0.0.3 Message-ID: I'm happy to announce a new package called VKHS: http://hackage.haskell.org/package/VKHS https://github.com/ierton/vkhs VKHS provides access to Vkontakte [1] (popular Russian social network) API methods. Library can be used to login into the network as a standalone application (OAuth implicit flow as they call it). Interaction with user is not required. For now, vkhs offers limited error detection and no captcha support. Here is an example code: import Web.VKHS.Login import Web.VKHS.Api main = do let client_id = "111111" -- application id, register first let user_of_interest = "222222" let e = env client_id "user at example.com" "password" [Photos,Audio,Groups] (Right at) <- login e (Right ans) <- api e at "users.get" [ ("uids",user_of_interest) , ("fields","first_name,last_name,nickname,screen_name") , ("name_case","nom") ] putStrLn ans Internally, library uses small curl-based HTTP automata and tagsoup for jumping over relocations and submitting various 'Yes I agree' forms. Sergey. [1] - http://vk.com From byorgey at seas.upenn.edu Sun Sep 9 04:24:58 2012 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat, 8 Sep 2012 22:24:58 -0400 Subject: [Haskell-cafe] package categories In-Reply-To: References: Message-ID: <20120909022458.GA12873@seas.upenn.edu> On Sat, Sep 08, 2012 at 11:04:34AM +0400, Sergey Mironov wrote: > Hello list. Do we have a guideline for selecting correct category for > a package being developed? I'd like to choose between Web.MyLib and > Network.MyLib. Or probably just MyLib if I feel ambitious? > Sergey. MyLib is discouraged. I'm sure either Web.MyLib or Network.MyLib would be fine. I don't know of any guidelines. -Brent From fox at ucw.cz Sun Sep 9 10:46:58 2012 From: fox at ucw.cz (Milan Straka) Date: Sun, 9 Sep 2012 10:46:58 +0200 Subject: [Haskell-cafe] Destructive updates to plain ADTs Message-ID: <20120909084658.GA25913@auryn.cz> Hi all, is there any way to perform a destructive update on a plain ADT? Imagine I have a simple data Tree a = Nil | Node a (Tree a) (Tree a) I would like to be able to modify right subtree of an existing tree. I can do that for example when using IORefs by changing the datatype to data Tree a = Nil | Node a (IORef (Tree a)) (IORef (Tree a)) and use unsafePerformIO + writeIORef. But the IORefs cause additional complexity when working with the data type. At the moment I am interested in any GHC solution, be it non-portable or version specific. I would like just to run some benchmarks and see the results. Cheers, Milan From johan.tibell at gmail.com Sun Sep 9 10:58:22 2012 From: johan.tibell at gmail.com (Johan Tibell) Date: Sun, 9 Sep 2012 01:58:22 -0700 Subject: [Haskell-cafe] Destructive updates to plain ADTs In-Reply-To: <20120909084658.GA25913@auryn.cz> References: <20120909084658.GA25913@auryn.cz> Message-ID: On Sun, Sep 9, 2012 at 1:46 AM, Milan Straka wrote: > Hi all, > > is there any way to perform a destructive update on a plain ADT? > Imagine I have a simple > data Tree a = Nil | Node a (Tree a) (Tree a) > I would like to be able to modify right subtree of an existing tree. > > I can do that for example when using IORefs by changing the datatype to > data Tree a = Nil | Node a (IORef (Tree a)) (IORef (Tree a)) > and use unsafePerformIO + writeIORef. But the IORefs cause additional > complexity when working with the data type. > > > At the moment I am interested in any GHC solution, be it non-portable or > version specific. I would like just to run some benchmarks and see the > results. > > Cheers, > Milan You can do it if you refer to the children using Array#s. That's what I do in unordered-containers to implement a more efficient fromList. For arbitrary field types I don't think there's a way (although it would be useful when birthing persistent data structures). -- Johan From miguelimo38 at yandex.ru Sun Sep 9 11:19:10 2012 From: miguelimo38 at yandex.ru (MigMit) Date: Sun, 9 Sep 2012 13:19:10 +0400 Subject: [Haskell-cafe] Destructive updates to plain ADTs In-Reply-To: <20120909084658.GA25913@auryn.cz> References: <20120909084658.GA25913@auryn.cz> Message-ID: <7F5FD47E-CAF2-4911-B47E-946292CF2D66@yandex.ru> Why modify it instead of creating the new one and let the previous tree get garbage collected? On Sep 9, 2012, at 12:46 PM, Milan Straka wrote: > Hi all, > > is there any way to perform a destructive update on a plain ADT? > Imagine I have a simple > data Tree a = Nil | Node a (Tree a) (Tree a) > I would like to be able to modify right subtree of an existing tree. > > I can do that for example when using IORefs by changing the datatype to > data Tree a = Nil | Node a (IORef (Tree a)) (IORef (Tree a)) > and use unsafePerformIO + writeIORef. But the IORefs cause additional > complexity when working with the data type. > > > At the moment I am interested in any GHC solution, be it non-portable or > version specific. I would like just to run some benchmarks and see the > results. > > Cheers, > Milan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From johan.tibell at gmail.com Sun Sep 9 11:24:47 2012 From: johan.tibell at gmail.com (Johan Tibell) Date: Sun, 9 Sep 2012 02:24:47 -0700 Subject: [Haskell-cafe] Destructive updates to plain ADTs In-Reply-To: <7F5FD47E-CAF2-4911-B47E-946292CF2D66@yandex.ru> References: <20120909084658.GA25913@auryn.cz> <7F5FD47E-CAF2-4911-B47E-946292CF2D66@yandex.ru> Message-ID: On Sun, Sep 9, 2012 at 2:19 AM, MigMit wrote: > Why modify it instead of creating the new one and let the previous tree get garbage collected? You can avoid a bunch of copying and allocation by modifying the nodes in-place. See http://blog.johantibell.com/2012/03/improvements-to-hashmap-and-hashset.html for some numbers. -- Johan From fox at ucw.cz Sun Sep 9 12:03:25 2012 From: fox at ucw.cz (Milan Straka) Date: Sun, 9 Sep 2012 12:03:25 +0200 Subject: [Haskell-cafe] Destructive updates to plain ADTs In-Reply-To: References: <20120909084658.GA25913@auryn.cz> Message-ID: <20120909100325.GA26467@auryn.cz> > > is there any way to perform a destructive update on a plain ADT? > > Imagine I have a simple > > data Tree a = Nil | Node a (Tree a) (Tree a) > > I would like to be able to modify right subtree of an existing tree. > > > > I can do that for example when using IORefs by changing the datatype to > > data Tree a = Nil | Node a (IORef (Tree a)) (IORef (Tree a)) > > and use unsafePerformIO + writeIORef. But the IORefs cause additional > > complexity when working with the data type. > > > > > > At the moment I am interested in any GHC solution, be it non-portable or > > version specific. I would like just to run some benchmarks and see the > > results. > > > > Cheers, > > Milan > > You can do it if you refer to the children using Array#s. That's what > I do in unordered-containers to implement a more efficient fromList. But the Array# adds another level of indirection, which seem wasteful if it has 2 elements. Also creating and cloning array is calling method in runtime, which is another source of (minor) slowdown. > For arbitrary field types I don't think there's a way (although it > would be useful when birthing persistent data structures). That is my reason for asking this. I was hoping for some Addr# trick or something like that. If I understand the GHC runtime correctly, rewriting a pointer in an ADT should not break any garbage collecting and similar. Cheers, Milan From ganesh at earth.li Sun Sep 9 15:31:44 2012 From: ganesh at earth.li (Ganesh Sittampalam) Date: Sun, 09 Sep 2012 14:31:44 +0100 Subject: [Haskell-cafe] Destructive updates to plain ADTs In-Reply-To: <20120909100325.GA26467@auryn.cz> References: <20120909084658.GA25913@auryn.cz> <20120909100325.GA26467@auryn.cz> Message-ID: <504C9A40.2090802@earth.li> On 09/09/2012 11:03, Milan Straka wrote: > I was hoping for some Addr# trick or something like that. If > I understand the GHC runtime correctly, rewriting a pointer in an ADT > should not break any garbage collecting and similar. Don't you need to worry about having something in the old generation suddenly pointing to something in a younger generation? Ganesh From david.waern at gmail.com Sun Sep 9 22:36:47 2012 From: david.waern at gmail.com (David Waern) Date: Sun, 9 Sep 2012 22:36:47 +0200 Subject: [Haskell-cafe] ANNOUCE: Haddock 2.10.0 and 2.11.0 In-Reply-To: References: Message-ID: 2012/9/8 Ivan Lazar Miljenovic : > On 7 September 2012 23:19, David Waern wrote: >> -------------------------------------------- >> -- Haddock 2.10.0 and 2.11.0 >> -------------------------------------------- >> >> Two new versions of Haddock have been uploaded to Hackage: version >> 2.10.0 which comes with GHC 7.4.2 and 2.11.0 which comes with the new >> GHC 7.6.1! >> >> -------------------------------------------- >> -- Changes in version 2.12.0 >> -------------------------------------------- > > So either your changelog has the wrong versions, or else you listed > the wrong versions above? ;-) Oops, sorry. I listed the wrong versions above! David From anthony_clayden at clear.net.nz Sun Sep 9 23:52:15 2012 From: anthony_clayden at clear.net.nz (AntC) Date: Sun, 9 Sep 2012 21:52:15 +0000 (UTC) Subject: [Haskell-cafe] Destructive updates to plain ADTs References: <20120909084658.GA25913@auryn.cz> Message-ID: Milan Straka ucw.cz> writes: > > is there any way to perform a destructive update on a plain ADT? Hi Milan, perhaps this is a dumb question, but given that you're using a lazy functional language: why do you want to do destructive updates at all? Perhaps you'd be better off using an imperative/object-oriented language? If you're trying to create a static data structure, perhaps the credit card transform is the approach to use? > ... I would like just to run some benchmarks and see the results. Running benchmarks for destructive updates in Haskell seems a waste of time(?) AntC From garious at gmail.com Mon Sep 10 00:24:01 2012 From: garious at gmail.com (Greg Fitzgerald) Date: Sun, 9 Sep 2012 15:24:01 -0700 Subject: [Haskell-cafe] JavaScript (SpiderMonkey, V8, etc) embedded in GHC? In-Reply-To: <954564B0-C953-49E0-B9A9-FD8CBC9C3A66@recursive.ca> References: <954564B0-C953-49E0-B9A9-FD8CBC9C3A66@recursive.ca> Message-ID: 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 wrote: > 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 at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Hannes_E at gmx.de Mon Sep 10 12:08:31 2012 From: Hannes_E at gmx.de (Johannes Erber) Date: Mon, 10 Sep 2012 11:08:31 +0100 Subject: [Haskell-cafe] ANNOUNCE: grid-1.1 In-Reply-To: References: Message-ID: <504DBC1F.1020205@gmx.de> Hi Amy, thank you for your nice package. While I used it I wrote a function that calculates all edges between all (neighboured) tiles in a grid. I though it could of interest for somebody else: http://hpaste.org/74520 Tested for rectangular and triangular grids. Still have the feeling it could be done much simpler!? Best, Johannes On 06/09/12 10:42, Amy de Buitl?ir wrote: > I'm happy to announce a new package called grid: > > http://hackage.haskell.org/package/grid > https://github.com/mhwombat/grid/wiki (wiki) > > Grid provides tools for working with regular arrangements of tiles, such as > might be used in a board game or self-organising map (SOM). Grid currently > supports triangular, square, and hexagonal tiles, with various 2D and toroidal > layouts. If you need a tile shape or layout that isn't currently provided, > please let me know. See Math.Geometry.Grid for an example of how to use the > package. Suggestions for improvement are welcome. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From hutch-lists at recursive.ca Mon Sep 10 13:06:29 2012 From: hutch-lists at recursive.ca (Bob Hutchison) Date: Mon, 10 Sep 2012 07:06:29 -0400 Subject: [Haskell-cafe] JavaScript (SpiderMonkey, V8, etc) embedded in GHC? In-Reply-To: References: <954564B0-C953-49E0-B9A9-FD8CBC9C3A66@recursive.ca> Message-ID: <280401E7-4DFA-4F06-9082-59750FF3AD94@recursive.ca> Thanks Greg, interesting thought. It would work the other way around, but it'd be easy enough to set up a node server to run the javascript. There's no IO allowed or any other blocking operations so I can make this all automatic. Still, that's another moving part I'd just as soon not have. Strange there's no JavaScript embedding in GHC, or there doesn't seem to be. Cheers, Bob On 2012-09-09, at 6:24 PM, Greg Fitzgerald wrote: > 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 wrote: > 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 at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From simons at cryp.to Mon Sep 10 16:05:21 2012 From: simons at cryp.to (Peter Simons) Date: Mon, 10 Sep 2012 16:05:21 +0200 Subject: [Haskell-cafe] extensible-exceptions no longer a part of GHC 7.6.1? Message-ID: <87oblevuqm.fsf@write-only.cryp.to> Hi, 'extensible-exceptions' used to be a part of GHC, but it appears that the package has been dropped from 7.6.1. Yet, the release notes on haskell.org don't say anything about this subject (other than TODO). Was that change intentional? Take care, Peter From paolo at well-typed.com Mon Sep 10 16:11:06 2012 From: paolo at well-typed.com (Paolo Capriotti) Date: Mon, 10 Sep 2012 15:11:06 +0100 Subject: [Haskell-cafe] extensible-exceptions no longer a part of GHC 7.6.1? In-Reply-To: <87oblevuqm.fsf@write-only.cryp.to> References: <87oblevuqm.fsf@write-only.cryp.to> Message-ID: On Mon, Sep 10, 2012 at 3:05 PM, Peter Simons wrote: > Hi, > > 'extensible-exceptions' used to be a part of GHC, but it appears that > the package has been dropped from 7.6.1. Yet, the release notes on > haskell.org don't say anything about this subject (other than TODO). > > Was that change intentional? The release notes on the website (and on the released tarballs) are an old version, that ended up in the final released revision of GHC by mistake. We are in the process of fixing this, at least for the copy on the website. Sorry about the confusion. Paolo From corentin.dupont at gmail.com Mon Sep 10 23:15:18 2012 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Mon, 10 Sep 2012 23:15:18 +0200 Subject: [Haskell-cafe] type variable in class instance Message-ID: Hello everybody! I'm soliciting once again your help! It's been several days I'm blocked by this problem: *{-# LANGUAGE DeriveDataTypeable #-} import Data.Typeable class (Typeable e) => Event e data Player = Player Int deriving (Typeable) data Message m = Message String deriving (Typeable) instance Event Player instance (Typeable m) => Event (Message m) viewEvent :: (Event e) => e -> IO () viewEvent event = do case cast event of Just (Player a) -> putStrLn $ show a Nothing -> return () case cast event of Just (Message s) -> putStrLn $ show s Nothing -> return () * gives me a: * Ambiguous type variable `t0' in the constraint: (Typeable t0) arising from a use of `cast' Probable fix: add a type signature that fixes these type variable(s) In the expression: cast event In the expression: case cast event of { Just (Message s) -> putStrLn $ show s Nothing -> return () }* This is because *Message* has a type variable, while *Player* has not... How to get this to work? I tried everything, existential types, scoped type variables etc. without success... Thanks!! Corentin -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephen.tetley at gmail.com Mon Sep 10 23:33:32 2012 From: stephen.tetley at gmail.com (Stephen Tetley) Date: Mon, 10 Sep 2012 22:33:32 +0100 Subject: [Haskell-cafe] type variable in class instance In-Reply-To: References: Message-ID: Whilst dynamic typing isn't idiomatic for Haskell, it seems like you've decided you want it. So why not use Data.Dynamic rather than roll you're own dynamic typing with Typeable? From corentin.dupont at gmail.com Tue Sep 11 00:06:15 2012 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Tue, 11 Sep 2012 00:06:15 +0200 Subject: [Haskell-cafe] type variable in class instance In-Reply-To: References: Message-ID: Hi Stephen, I wasn't aware of Data.Dynamic. I tried: *viewEvent :: Dynamic -> IO () viewEvent event = do case fromDynamic event of Nothing -> return () Just (Message s) -> putStrLn $ show s* But still got the same error (Ambiguous type variable `t0' in the constraint: (Typeable t0) arising from a use of `fromDynamic')... Best, Corentin On Mon, Sep 10, 2012 at 11:33 PM, Stephen Tetley wrote: > Whilst dynamic typing isn't idiomatic for Haskell, it seems like > you've decided you want it. So why not use Data.Dynamic rather than > roll you're own dynamic typing with Typeable? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryani.spam at gmail.com Tue Sep 11 01:03:36 2012 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon, 10 Sep 2012 16:03:36 -0700 Subject: [Haskell-cafe] type variable in class instance In-Reply-To: References: Message-ID: From ryani.spam at gmail.com Tue Sep 11 01:12:25 2012 From: ryani.spam at gmail.com (Ryan Ingram) Date: Mon, 10 Sep 2012 16:12:25 -0700 Subject: [Haskell-cafe] type variable in class instance In-Reply-To: References: Message-ID: By the way, if you *really* want to do it your way, you can inspect the typeOf the event directly and look for your "Message" type (using typeRepTyCon from Data.Typeable), then unsafeCoerce into Message () to extract the String. import Unsafe.Coerce import Data.Typeable tyConMessage :: TyCon tyConMessage = typeRepTyCon $ typeOf ( undefined :: Message () ) getMessageContents :: Event e => e -> Maybe String getMessageContents e | typeRepTyCon (typeOf e) == tyConMessage = Just $ case (unsafeCoerce e :: Message ()) of Message s -> s | otherwise = Nothing But I strongly recommend *not* doing it this way :) -- ryan On Mon, Sep 10, 2012 at 4:03 PM, Ryan Ingram wrote: > From the point of view of the language, Message () and Message Int and > Message Player are all completely distinct types and may have different > behavior--there's no way for it to "know" that they all have the same > representation that only contains a String. > > The derived Typeable instance for "Message m" is really a derived instance > of "Typeable1 Message" along with the generic instance "(Typeable1 f, > Typeable a) => Typeable (m a)" in Data.Typeable. > > So you need to specify the type of message you want, or drop the type > parameter from Message. > > A simpler answer, though, would just be to put the functions in the > typeclass. > > class Event e where > viewEvent :: e -> IO () > > instance Event Player where > viewEvent (Player a) = putStrLn $ show a > instance Event (Message m) where > viewEvent (Message s) = putStrLn s > > In this case, the instance makes it clear that the type parameter is > irrelevant and puts no constraints on it. And the type of viewEvent is > exactly the same as you were asking for: Event e => e -> IO (). > > -- ryan > > On Mon, Sep 10, 2012 at 3:06 PM, Corentin Dupont < > corentin.dupont at gmail.com> wrote: > >> Hi Stephen, >> I wasn't aware of Data.Dynamic. >> I tried: >> >> *viewEvent :: Dynamic -> IO () >> viewEvent event = do >> case fromDynamic event of >> Nothing -> return () >> >> Just (Message s) -> putStrLn $ show s >> * >> >> But still got the same error (Ambiguous type variable `t0' in the >> constraint: (Typeable t0) arising from a use of `fromDynamic')... >> >> Best, >> Corentin >> >> >> >> On Mon, Sep 10, 2012 at 11:33 PM, Stephen Tetley < >> stephen.tetley at gmail.com> wrote: >> >>> Whilst dynamic typing isn't idiomatic for Haskell, it seems like >>> you've decided you want it. So why not use Data.Dynamic rather than >>> roll you're own dynamic typing with Typeable? >>> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kazu at iij.ad.jp Tue Sep 11 05:27:29 2012 From: kazu at iij.ad.jp (Kazu Yamamoto (=?iso-2022-jp?B?GyRCOzNLXE9CSScbKEI=?=)) Date: Tue, 11 Sep 2012 12:27:29 +0900 (JST) Subject: [Haskell-cafe] The Architecture of the Mighttpd High-Speed Web Server Message-ID: <20120911.122729.721200261189191966.kazu@iij.ad.jp> Hello from Copenhagen, In last may, I wrote an article about Mighttpd in Japanese because a PR staff of IIJ asked me to do so. Since this article got popular in Japan, the PR staff decided to translate it into English. The English version is now open to the public: http://www.iij.ad.jp/en/company/development/tech/mighttpd/ # Mighttpd is based on Yesod's Warp but I did touch it to make the # article simple. I guess that we can use this article to explain why Haskell is suitable for network programming to other programming language communities. FYI, the original Japanese article can be found: http://www.iij.ad.jp/company/development/tech/activities/mighttpd/ Regards, --Kazu From oleg at okmij.org Tue Sep 11 08:53:32 2012 From: oleg at okmij.org (oleg at okmij.org) Date: 11 Sep 2012 06:53:32 -0000 Subject: [Haskell-cafe] type variable in class instance Message-ID: <20120911065332.1997.qmail@www1.g3.pair.com> Corentin Dupon wrote about essentially the read-show problem: > class (Typeable e) => Event e > > data Player = Player Int deriving (Typeable) > data Message m = Message String deriving (Typeable) > > instance Event Player > > instance (Typeable m) => Event (Message m) > > viewEvent :: (Event e) => e -> IO () > viewEvent event = do > case cast event of > Just (Player a) -> putStrLn $ show a > Nothing -> return () > case cast event of > Just (Message s) -> putStrLn $ show s > Nothing -> return () Indeed the overloaded function cast needs to know the target type -- the type to cast to. In case of Player, the pattern (Player a) uniquely determines the type of the desired value: Player. This is not so for Message: the pattern (Message s) may correspond to the type Message (), Message Int, etc. To avoid the problem, just specify the desired type explicitly > case cast event of > Just (Message s::Message ()) -> putStrLn $ show s > Nothing -> return () (ScopedTypeVariables extension is needed). The exact type of the message doesn't matter, so I chose Message (). BTW, if the set of events is closed, GADTs seem a better fit > data Player > data Message s > > data Event e where > Player :: Int -> Event Player > Message :: String -> Event (Message s) > > viewEvent :: Event e -> IO () > viewEvent (Player a) = putStrLn $ show a > viewEvent (Message s) = putStrLn $ show s From komadori at gekkou.co.uk Tue Sep 11 09:47:55 2012 From: komadori at gekkou.co.uk (Robin KAY) Date: Tue, 11 Sep 2012 08:47:55 +0100 Subject: [Haskell-cafe] ANNOUNCE: hsqml-0.1.1 (and hsqml-morris-0.1.0) Message-ID: <504EECAB.9040405@gekkou.co.uk> Dear All, I would like to announce a new package called 'hsqml' [1]. HsQML provides a Haskell binding to the Qt Quick framework. It allows you to write graphical applications where the front-end is written in Qt Quick's QML language (incorporating JavaScript) and the back-end is written in Haskell. The two layers are coupled together via a facility to define custom JavaScript objects through which QML code can call into Haskell. HsQML requires an installation of Qt 4.7 (including QtDeclarative) or later on your path. It has been tested with GHC 7.4 on both Linux and Windows. There is also a simple example program available using HsQML on Hackage called 'hsqml-morris'. It implements a human v computer game of Nine Men's Morris with game logic and AI written in Haskell and the presentation layer in QML. The library is currently limited by a lack of support for Qt signals, so calls can only be made from JavaScript to Haskell and not the other way. I plan to add support for these in a future release. Migration over to Qt 5.x is also likely once it's released. [1] http://hackage.haskell.org/package/hsqml-0.1.1 [2] http://hackage.haskell.org/package/hsqml-morris-0.1.0 Regards, -- Robin KAY From fox at ucw.cz Tue Sep 11 09:49:25 2012 From: fox at ucw.cz (Milan Straka) Date: Tue, 11 Sep 2012 09:49:25 +0200 Subject: [Haskell-cafe] Destructive updates to plain ADTs In-Reply-To: References: <20120909084658.GA25913@auryn.cz> Message-ID: <20120911074925.GA1485@auryn.cz> Hi, > > is there any way to perform a destructive update on a plain ADT? > > Hi Milan, perhaps this is a dumb question, but given that you're using a lazy > functional language: why do you want to do destructive updates at all? > > Perhaps you'd be better off using an imperative/object-oriented language? I am one of the maintainers of the containers package, so I definitely want to stick to Haskell :) The reason for me wanting to do destructive updates is speed -- if I could perform destructive updates during the construction of persistent structure (e.g., inside Data.Map.fromList), the performance would improve. > > ... I would like just to run some benchmarks and see the results. > > Running benchmarks for destructive updates in Haskell seems a waste of time(?) Johan successfully improved unordered-containers by using destructive updates during construction, but he is using Array# where destructive updates are possible. I was wondering if I could do similar thing in containers... Cheers, Milan From martijn at oblomov.com Tue Sep 11 13:51:08 2012 From: martijn at oblomov.com (Martijn Schrage) Date: Tue, 11 Sep 2012 13:51:08 +0200 Subject: [Haskell-cafe] type variable in class instance In-Reply-To: <20120911065332.1997.qmail@www1.g3.pair.com> References: <20120911065332.1997.qmail@www1.g3.pair.com> Message-ID: <504F25AC.2000603@oblomov.com> On 11-09-12 08:53, oleg at okmij.org wrote: > Corentin Dupon wrote about essentially the read-show problem: >> class (Typeable e) => Event e >> >> data Player = Player Int deriving (Typeable) >> data Message m = Message String deriving (Typeable) >> >> instance Event Player >> >> instance (Typeable m) => Event (Message m) >> >> viewEvent :: (Event e) => e -> IO () >> viewEvent event = do >> case cast event of >> Just (Player a) -> putStrLn $ show a >> Nothing -> return () >> case cast event of >> Just (Message s) -> putStrLn $ show s >> Nothing -> return () > Indeed the overloaded function cast needs to know the target type -- > the type to cast to. In case of Player, the pattern > (Player a) uniquely determines the type of the desired value: Player. > This is not so for Message: the pattern (Message s) may correspond to > the type Message (), Message Int, etc. > > To avoid the problem, just specify the desired type explicitly I had the same idea, but it doesn't work. Fixing m to () causes the cast to fail for any other type, so viewEvent (Message "yes" :: Message ()) will work, but viewEvent (Message "no" :: Message Char) won't. Putting viewEvent in the Event class though, like Ryan suggested, seems to be an elegant solution that stays close to the original source. Cheers, Martijn >> case cast event of >> Just (Message s::Message ()) -> putStrLn $ show s >> Nothing -> return () > (ScopedTypeVariables extension is needed). The exact type of the > message doesn't matter, so I chose Message (). > > BTW, if the set of events is closed, GADTs seem a better fit > >> data Player >> data Message s >> >> data Event e where >> Player :: Int -> Event Player >> Message :: String -> Event (Message s) >> >> viewEvent :: Event e -> IO () >> viewEvent (Player a) = putStrLn $ show a >> viewEvent (Message s) = putStrLn $ show s > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From corentin.dupont at gmail.com Tue Sep 11 15:39:08 2012 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Tue, 11 Sep 2012 15:39:08 +0200 Subject: [Haskell-cafe] type variable in class instance In-Reply-To: <504F25AC.2000603@oblomov.com> References: <20120911065332.1997.qmail@www1.g3.pair.com> <504F25AC.2000603@oblomov.com> Message-ID: Thanks Martijn, Oleg and Ryan for your kind replies! @Ryan and Martijn: I considered putting the viewEvent in the typeclass, but I figured out that would break the separation of concerns. Indeed this typeclass "Event" belongs to the inner engine, while the display is done in another component (not even the same library) using a specific technology (for instance HTML). So it doesn't feel right to mix the logic of the event engine with the display... @Oleg: Yes the set of events is closed and I would be much happier with a GADT! But no matter how hard I tried I couldn't manage. Here is the full problem: *{-# LANGUAGE ExistentialQuantification, TypeFamilies, DeriveDataTypeable #-} import Data.Typeable -- | Define the events and their related data class (Eq e, Typeable e, Show e) => Event e where data EventData e -- | Groups of events data PlayerEvent = Arrive | Leave deriving (Typeable, Show, Eq) -- | events types data Player = Player PlayerEvent deriving (Typeable, Show, Eq) data Message m = Message String deriving (Typeable, Show, Eq) -- | event instances instance Event Player where data EventData Player = PlayerData {playerData :: Int} instance (Typeable m) => Event (Message m) where data EventData (Message m) = MessageData {messageData :: m} -- | structure to store an event data EventHandler = forall e . (Event e) => EH {eventNumber :: Int, event :: e, handler :: (EventData e) -> IO ()} deriving Typeable -- store a new event with its handler in the list addEvent :: (Event e) => e -> (EventData e -> IO ()) -> [EventHandler] -> [EventHandler] addEvent event handler ehs = undefined -- trigger all the corresponding events in the list, passing the **data to the handlers triggerEvent :: (Event e) => e -> (EventData e) -> [EventHandler] -> IO () triggerEvent event edata ehs = undefined --Examples: msg :: Message Int msg = Message "give me a number" myList = addEvent msg (\(MessageData n) -> putStrLn $ "Your number is: " ++ show n) [] trigger = triggerEvent msg (MessageData 1) **myList --Yelds "Your number is: 1"* Has you can see this allows me to associate an arbitrary data type to each event with the type family "EventData". Furthermore some events like "Message" let the user choose the data type using the type parameter. This way I have nice signatures for the functions "addEvent" and "triggerEvent". The right types for the handlers and the data passed is enforced at compilation time. But I couldn't find any way to convert this into a GATD and get rid of the "Event" class...... Thanks, Corentin On Tue, Sep 11, 2012 at 1:51 PM, Martijn Schrage wrote: > On 11-09-12 08:53, oleg at okmij.org wrote: > > Corentin Dupon wrote about essentially the read-show problem: > > class (Typeable e) => Event e > > data Player = Player Int deriving (Typeable) > data Message m = Message String deriving (Typeable) > > instance Event Player > > instance (Typeable m) => Event (Message m) > > viewEvent :: (Event e) => e -> IO () > viewEvent event = do > case cast event of > Just (Player a) -> putStrLn $ show a > Nothing -> return () > case cast event of > Just (Message s) -> putStrLn $ show s > Nothing -> return () > > Indeed the overloaded function cast needs to know the target type -- > the type to cast to. In case of Player, the pattern > (Player a) uniquely determines the type of the desired value: Player. > This is not so for Message: the pattern (Message s) may correspond to > the type Message (), Message Int, etc. > > To avoid the problem, just specify the desired type explicitly > > I had the same idea, but it doesn't work. Fixing m to () causes the cast > to fail for any other type, so viewEvent (Message "yes" :: Message ())will work, but viewEvent > (Message "no" :: Message Char) > won't. > > Putting viewEvent in the Event class though, like Ryan suggested, seems to > be an elegant solution that stays close to the original source. > > Cheers, > Martijn > > case cast event of > Just (Message s::Message ()) -> putStrLn $ show s > Nothing -> return () > > (ScopedTypeVariables extension is needed). The exact type of the > message doesn't matter, so I chose Message (). > > BTW, if the set of events is closed, GADTs seem a better fit > > > data Player > data Message s > > data Event e where > Player :: Int -> Event Player > Message :: String -> Event (Message s) > > viewEvent :: Event e -> IO () > viewEvent (Player a) = putStrLn $ show a > viewEvent (Message s) = putStrLn $ show s > > _______________________________________________ > Haskell-Cafe mailing listHaskell-Cafe at haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From leather at cs.uu.nl Tue Sep 11 16:10:55 2012 From: leather at cs.uu.nl (Sean Leather) Date: Tue, 11 Sep 2012 16:10:55 +0200 Subject: [Haskell-cafe] type variable in class instance In-Reply-To: References: <20120911065332.1997.qmail@www1.g3.pair.com> <504F25AC.2000603@oblomov.com> Message-ID: On Tue, Sep 11, 2012 at 3:39 PM, Corentin Dupontwrote: > @Oleg: Yes the set of events is closed and I would be much happier with a > GADT! But no matter how hard I tried I couldn't manage. > Here is the full problem: > > *{-# LANGUAGE ExistentialQuantification, TypeFamilies, DeriveDataTypeable > #-} > > import Data.Typeable > > -- | Define the events and their related data > class (Eq e, Typeable e, Show e) => Event e where > data EventData e > > -- | Groups of events > data PlayerEvent = Arrive | Leave deriving (Typeable, Show, Eq) > > -- | events types > data Player = Player PlayerEvent deriving (Typeable, Show, Eq) > data Message m = Message String deriving (Typeable, Show, Eq) > > -- | event instances > instance Event Player where data > EventData Player = PlayerData {playerData :: Int} > instance (Typeable m) => Event (Message m) where data EventData (Message > m) = MessageData {messageData :: m} > > -- | structure to store an event > data EventHandler = forall e . (Event e) => > EH {eventNumber :: Int, > event :: e, > handler :: (EventData e) -> IO ()} deriving Typeable > > -- store a new event with its handler in the list > addEvent :: (Event e) => e -> (EventData e -> IO ()) -> [EventHandler] -> > [EventHandler] > addEvent event handler ehs = undefined > > -- trigger all the corresponding events in the list, passing the **data > to the handlers > triggerEvent :: (Event e) => e -> (EventData e) -> [EventHandler] -> IO () > triggerEvent event edata ehs = undefined > > --Examples: > msg :: Message Int > msg = Message "give me a number" > myList = addEvent msg (\(MessageData n) -> putStrLn $ "Your number is: " > ++ show n) [] > trigger = triggerEvent msg (MessageData 1) **myList --Yelds "Your number > is: 1"* > > Has you can see this allows me to associate an arbitrary data type to each > event with the type family "EventData". Furthermore some events like > "Message" let the user choose the data type using the type parameter. This > way I have nice signatures for the functions "addEvent" and "triggerEvent". > The right types for the handlers and the data passed is enforced at > compilation time. > But I couldn't find any way to convert this into a GATD and get rid of the > "Event" class...... > Would this work? data Player = Arrive | Leave data Message m = Message String data Data a where PlayerData :: Int -> Data Player MessageData :: m -> Data (Message m) data Handler where Handler :: Int -> e -> (Data e -> IO ()) -> Handler addEvent :: e -> (Data e -> IO ()) -> [Handler] -> [Handler] addEvent = undefined triggerEvent :: e -> Data e -> [Handler] -> IO () triggerEvent = undefined Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: From corentin.dupont at gmail.com Tue Sep 11 17:06:30 2012 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Tue, 11 Sep 2012 17:06:30 +0200 Subject: [Haskell-cafe] type variable in class instance In-Reply-To: References: <20120911065332.1997.qmail@www1.g3.pair.com> <504F25AC.2000603@oblomov.com> Message-ID: Yes. That's fantastic! This GADT is the missing piece of my puzzle. I transformed a bit your solution, polluting it with some classes instances and fleshing the functions: *data Player = Arrive | Leave deriving (Show, Typeable, Eq) data Message m = Message String deriving (Show, Typeable, Eq) data Data a where PlayerData :: Int -> Data Player MessageData :: m -> Data (Message m) data Handler where Handler :: (Typeable e) => e -> (Data e -> IO ()) -> Handler instance forall e. (Typeable e) => Typeable (Data e) where typeOf _ = mkTyConApp (mkTyCon( ("Expression.EventData (" ++ (show $ typeOf (undefined::e))) ++ ")" )) [] addEvent :: (Typeable e) => e -> (Data e -> IO ()) -> [Handler] -> [Handler] addEvent e h hs = (Handler e h) : hs triggerEvent :: (Eq e, Typeable e) => e -> Data e -> [Handler] -> IO () triggerEvent e d hs = do let filtered = filter (\(Handler e1 _) -> e1 === e) hs mapM_ f filtered where f (Handler _ h) = case cast h of Just castedH -> do castedH d Nothing -> return () viewEvent :: (Typeable e) => e -> IO() viewEvent event = do case cast event of Just (a :: Player) -> putStrLn $ "Player" ++ show a Nothing -> return () case cast event of (Just (Message s)) -> putStrLn $ "Player" ++ s Nothing -> return ()* Unfortunately, I still cannot pattern match on the events to view them (*viewEvent won't compile)*... Best, Corentin On Tue, Sep 11, 2012 at 4:10 PM, Sean Leather wrote: > On Tue, Sep 11, 2012 at 3:39 PM, Corentin Dupontwrote: > > @Oleg: Yes the set of events is closed and I would be much happier with a >> GADT! But no matter how hard I tried I couldn't manage. >> Here is the full problem: >> >> *{-# LANGUAGE ExistentialQuantification, TypeFamilies, >> DeriveDataTypeable #-} >> >> import Data.Typeable >> >> -- | Define the events and their related data >> class (Eq e, Typeable e, Show e) => Event e where >> data EventData e >> >> -- | Groups of events >> data PlayerEvent = Arrive | Leave deriving (Typeable, Show, Eq) >> >> -- | events types >> data Player = Player PlayerEvent deriving (Typeable, Show, Eq) >> data Message m = Message String deriving (Typeable, Show, Eq) >> >> -- | event instances >> instance Event Player where data >> EventData Player = PlayerData {playerData :: Int} >> instance (Typeable m) => Event (Message m) where data EventData >> (Message m) = MessageData {messageData :: m} >> >> -- | structure to store an event >> data EventHandler = forall e . (Event e) => >> EH {eventNumber :: Int, >> event :: e, >> handler :: (EventData e) -> IO ()} deriving Typeable >> >> -- store a new event with its handler in the list >> addEvent :: (Event e) => e -> (EventData e -> IO ()) -> [EventHandler] -> >> [EventHandler] >> addEvent event handler ehs = undefined >> >> -- trigger all the corresponding events in the list, passing the **data >> to the handlers >> triggerEvent :: (Event e) => e -> (EventData e) -> [EventHandler] -> IO () >> triggerEvent event edata ehs = undefined >> >> --Examples: >> msg :: Message Int >> msg = Message "give me a number" >> myList = addEvent msg (\(MessageData n) -> putStrLn $ "Your number is: " >> ++ show n) [] >> trigger = triggerEvent msg (MessageData 1) **myList --Yelds "Your number >> is: 1"* >> >> Has you can see this allows me to associate an arbitrary data type to >> each event with the type family "EventData". Furthermore some events like >> "Message" let the user choose the data type using the type parameter. This >> way I have nice signatures for the functions "addEvent" and "triggerEvent". >> The right types for the handlers and the data passed is enforced at >> compilation time. >> But I couldn't find any way to convert this into a GATD and get rid of >> the "Event" class...... >> > > Would this work? > > data Player = Arrive | Leave > data Message m = Message String > > data Data a where > PlayerData :: Int -> Data Player > MessageData :: m -> Data (Message m) > > data Handler where > Handler :: Int -> e -> (Data e -> IO ()) -> Handler > > addEvent :: e -> (Data e -> IO ()) -> [Handler] -> [Handler] > addEvent = undefined > > triggerEvent :: e -> Data e -> [Handler] -> IO () > triggerEvent = undefined > > Regards, > Sean > -------------- next part -------------- An HTML attachment was scrubbed... URL: From corentin.dupont at gmail.com Tue Sep 11 18:16:27 2012 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Tue, 11 Sep 2012 18:16:27 +0200 Subject: [Haskell-cafe] type variable in class instance In-Reply-To: References: <20120911065332.1997.qmail@www1.g3.pair.com> <504F25AC.2000603@oblomov.com> Message-ID: I finally come up with this version, which allows to do pattern matching against the events. I'm sure it could be cleaned a bit, but it think the idea is there. I would like to thank again everybody on this list, that's very friendly and helpful! Corentin *{-# LANGUAGE ExistentialQuantification, TypeFamilies, DeriveDataTypeable, GADTs, ScopedTypeVariables, StandaloneDeriving #-} import Data.Typeable data Player = Arrive | Leave deriving (Show, Typeable, Eq) data Message m = Message String deriving (Show, Typeable, Eq) data Event a where PlayerEvent :: Player -> Event Player MessageEvent :: Message m -> Event (Message m) data Data a where PlayerData :: Int -> Data (Event Player) MessageData :: m -> Data (Event (Message m)) data Handler where Handler :: (Typeable e) => Event e -> (Data (Event e) -> IO ()) -> Handler deriving instance Eq (Event a) deriving instance Typeable1 Data deriving instance Typeable1 Event addEvent :: (Typeable e) => Event e -> (Data (Event e) -> IO ()) -> [Handler] -> [Handler] addEvent e h hs = (Handler e h) : hs triggerEvent :: (Eq e, Typeable e) => Event e -> (Data (Event e)) -> [Handler] -> IO () triggerEvent e d hs = do let filtered = filter (\(Handler e1 _) -> e1 === e) hs mapM_ f filtered where f (Handler _ h) = case cast h of Just castedH -> do castedH d Nothing -> return () viewEvent :: (Typeable e) => (Event e) -> IO() viewEvent (PlayerEvent p) = putStrLn $ "Player " ++ show p viewEvent m@(MessageEvent s) = putStrLn $ "Message " ++ show s ++ " of type " ++ (show $ typeOf m) -- | an equality that tests also the types. (===) :: (Typeable a, Typeable b, Eq b) => a -> b -> Bool (===) x y = cast x == Just y --TEST testPlayer = addEvent (PlayerEvent Arrive) (\(PlayerData d) -> putStrLn $ show d) [] msg :: Message Int msg = Message "give me a number" myList = addEvent (MessageEvent msg) (\(MessageData n) -> putStrLn $ "Your number is: " ++ show n) [] trigger = triggerEvent (MessageEvent msg) (MessageData 1) myList --Yelds "Your number is: 1"* On Tue, Sep 11, 2012 at 5:06 PM, Corentin Dupont wrote: > Yes. > That's fantastic! This GADT is the missing piece of my puzzle. I > transformed a bit your solution, polluting it with some classes instances > and fleshing the functions: > > *data Player = Arrive | Leave deriving (Show, Typeable, Eq) > data Message m = Message String deriving (Show, Typeable, Eq) > > > data Data a where > PlayerData :: Int -> Data Player > MessageData :: m -> Data (Message m) > > data Handler where > Handler :: (Typeable e) => e -> (Data e -> IO ()) -> Handler > > instance forall e. (Typeable e) => Typeable (Data e) where > typeOf _ = mkTyConApp (mkTyCon( ("Expression.EventData (" ++ (show $ > typeOf (undefined::e))) ++ ")" )) [] > > addEvent :: (Typeable e) => e -> (Data e -> IO ()) -> [Handler] -> > [Handler] > addEvent e h hs = (Handler e h) : hs > > triggerEvent :: (Eq e, Typeable e) => e -> Data e -> [Handler] -> IO () > triggerEvent e d hs = do > let filtered = filter (\(Handler e1 _) -> e1 === e) hs > mapM_ f filtered where > f (Handler _ h) = case cast h of > Just castedH -> do > castedH d > Nothing -> return () > > viewEvent :: (Typeable e) => e -> IO() > > viewEvent event = do > case cast event of > Just (a :: Player) -> putStrLn $ "Player" ++ show a > > Nothing -> return () > case cast event of > (Just (Message s)) -> putStrLn $ "Player" ++ s > Nothing -> return ()* > > > Unfortunately, I still cannot pattern match on the events to view them (*viewEvent > won't compile)*... > > Best, > Corentin > > > > On Tue, Sep 11, 2012 at 4:10 PM, Sean Leather wrote: > >> On Tue, Sep 11, 2012 at 3:39 PM, Corentin Dupontwrote: >> >> @Oleg: Yes the set of events is closed and I would be much happier with a >>> GADT! But no matter how hard I tried I couldn't manage. >>> Here is the full problem: >>> >>> *{-# LANGUAGE ExistentialQuantification, TypeFamilies, >>> DeriveDataTypeable #-} >>> >>> import Data.Typeable >>> >>> -- | Define the events and their related data >>> class (Eq e, Typeable e, Show e) => Event e where >>> data EventData e >>> >>> -- | Groups of events >>> data PlayerEvent = Arrive | Leave deriving (Typeable, Show, Eq) >>> >>> -- | events types >>> data Player = Player PlayerEvent deriving (Typeable, Show, Eq) >>> data Message m = Message String deriving (Typeable, Show, Eq) >>> >>> -- | event instances >>> instance Event Player where data >>> EventData Player = PlayerData {playerData :: Int} >>> instance (Typeable m) => Event (Message m) where data EventData >>> (Message m) = MessageData {messageData :: m} >>> >>> -- | structure to store an event >>> data EventHandler = forall e . (Event e) => >>> EH {eventNumber :: Int, >>> event :: e, >>> handler :: (EventData e) -> IO ()} deriving Typeable >>> >>> -- store a new event with its handler in the list >>> addEvent :: (Event e) => e -> (EventData e -> IO ()) -> [EventHandler] >>> -> [EventHandler] >>> addEvent event handler ehs = undefined >>> >>> -- trigger all the corresponding events in the list, passing the **data >>> to the handlers >>> triggerEvent :: (Event e) => e -> (EventData e) -> [EventHandler] -> IO >>> () >>> triggerEvent event edata ehs = undefined >>> >>> --Examples: >>> msg :: Message Int >>> msg = Message "give me a number" >>> myList = addEvent msg (\(MessageData n) -> putStrLn $ "Your number is: " >>> ++ show n) [] >>> trigger = triggerEvent msg (MessageData 1) **myList --Yelds "Your >>> number is: 1"* >>> >>> Has you can see this allows me to associate an arbitrary data type to >>> each event with the type family "EventData". Furthermore some events like >>> "Message" let the user choose the data type using the type parameter. This >>> way I have nice signatures for the functions "addEvent" and "triggerEvent". >>> The right types for the handlers and the data passed is enforced at >>> compilation time. >>> But I couldn't find any way to convert this into a GATD and get rid of >>> the "Event" class...... >>> >> >> Would this work? >> >> data Player = Arrive | Leave >> data Message m = Message String >> >> data Data a where >> PlayerData :: Int -> Data Player >> MessageData :: m -> Data (Message m) >> >> data Handler where >> Handler :: Int -> e -> (Data e -> IO ()) -> Handler >> >> addEvent :: e -> (Data e -> IO ()) -> [Handler] -> [Handler] >> addEvent = undefined >> >> triggerEvent :: e -> Data e -> [Handler] -> IO () >> triggerEvent = undefined >> >> Regards, >> Sean >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ericvmelo at gmail.com Tue Sep 11 18:36:52 2012 From: ericvmelo at gmail.com (Eric Velten de Melo) Date: Tue, 11 Sep 2012 13:36:52 -0300 Subject: [Haskell-cafe] Either Monad and Laziness Message-ID: Hello, I am currently trying to rewrite the Graphics.Pgm library from hackage to parse the PGM to a lazy array. The current implementation parses it straight to UArray, which is strict. The behaviour I want to achieve is like this: I want the program when compiled to read from a file, parsing the PGM and at the same time apply transformations to the entries as they are read and write them back to another PGM file. The problem is that even using a lazy array structure, because the parser returns an Either structure it is only possible to know if the parser was successful or not after the whole file is read, therefore requiring it to read the entire file before applying the transformations, ruining the property of laziness. Is there some way to keep this from happening? Should I even want to make it like this? Not really a real life situation, but imagine I want to read a reaaaaally large PGM file which does not fit into RAM memory and I don't want to be forced to have the whole array in the memory at once. One alternative I thought was parsing only the PGM header and then read the rest of the input without using Parsec and the Either Monad. In the event the data is corrupted, though, I would not know how to recover from it. Any thoughts? Hopefully I'm not saying anything really stupid. Eric From evohunz at gmail.com Tue Sep 11 18:43:41 2012 From: evohunz at gmail.com (Thiago Negri) Date: Tue, 11 Sep 2012 13:43:41 -0300 Subject: [Haskell-cafe] Pattern matching: multi constructors to same branch Message-ID: Is it possible to capture more than one constructor in a single pattern matching? I mean, is it possible to generalize the following pattern matching of A and B to a single branch? g f C = [f C] g f v@(A _ n) = f v : g n g f v@(B _ n) = f v : g n For example: g f C = [f C] g f v@(A|B _ n) = f v : g n Or: g f v = case v of C -> [f C] A|B -> f v : g (n v) Thanks. From dave at zednenem.com Tue Sep 11 18:46:57 2012 From: dave at zednenem.com (David Menendez) Date: Tue, 11 Sep 2012 12:46:57 -0400 Subject: [Haskell-cafe] type variable in class instance In-Reply-To: References: <20120911065332.1997.qmail@www1.g3.pair.com> <504F25AC.2000603@oblomov.com> Message-ID: I'm not sure I understand On Tue, Sep 11, 2012 at 11:06 AM, Corentin Dupont wrote: > Yes. > That's fantastic! This GADT is the missing piece of my puzzle. I transformed > a bit your solution, polluting it with some classes instances and fleshing > the functions: > > data Player = Arrive | Leave deriving (Show, Typeable, Eq) > data Message m = Message String deriving (Show, Typeable, Eq) > > > data Data a where > PlayerData :: Int -> Data Player > MessageData :: m -> Data (Message m) > > data Handler where > Handler :: (Typeable e) => e -> (Data e -> IO ()) -> Handler > > instance forall e. (Typeable e) => Typeable (Data e) where > typeOf _ = mkTyConApp (mkTyCon( ("Expression.EventData (" ++ (show $ > typeOf (undefined::e))) ++ ")" )) [] > > addEvent :: (Typeable e) => e -> (Data e -> IO ()) -> [Handler] -> [Handler] > addEvent e h hs = (Handler e h) : hs > > triggerEvent :: (Eq e, Typeable e) => e -> Data e -> [Handler] -> IO () > triggerEvent e d hs = do > let filtered = filter (\(Handler e1 _) -> e1 === e) hs > mapM_ f filtered where > f (Handler _ h) = case cast h of > Just castedH -> do > castedH d > Nothing -> return () > > viewEvent :: (Typeable e) => e -> IO() > > viewEvent event = do > case cast event of > Just (a :: Player) -> putStrLn $ "Player" ++ show a > > Nothing -> return () > case cast event of > (Just (Message s)) -> putStrLn $ "Player" ++ s > Nothing -> return () > > > Unfortunately, I still cannot pattern match on the events to view them > (viewEvent won't compile)... Mixing GADTs and Typeable seems like a bad idea. If you really don't want to put viewEvent in the Event typeclass, but the class of events is closed, you could use a GADT to witness the event type. class Event e where eventType :: EventType e ... data EventType e where PlayerEvent :: EventType Player MessageEvent :: EventType (Message m) viewEvent :: Event e => e -> IO () viewEvent = viewEvent' eventType viewEvent' :: EventType e -> e -> IO () viewEvent' PlayerEvent e = ... viewEvent' MessageEvent (Message s) = ... -- Dave Menendez From corentin.dupont at gmail.com Tue Sep 11 19:03:46 2012 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Tue, 11 Sep 2012 19:03:46 +0200 Subject: [Haskell-cafe] type variable in class instance In-Reply-To: References: <20120911065332.1997.qmail@www1.g3.pair.com> <504F25AC.2000603@oblomov.com> Message-ID: Hi David, that may be also a way to go. I've also looked into this way (view patterns), unfortunately it seems that I will be obliged to maintain 2 parallel structures: for each Event instance, I will have to add a ViewEvent element as well carrying the same information: instance Event Time where eventType = TimeEvent data EventType e where PlayerEvent :: EventType Player MessageEvent :: EventType (Message m) TimeEvent :: EventType Time That's why I like the all-GADT solution... Corentin On Tue, Sep 11, 2012 at 6:46 PM, David Menendez wrote: > I'm not sure I understand > > > On Tue, Sep 11, 2012 at 11:06 AM, Corentin Dupont > wrote: > > Yes. > > That's fantastic! This GADT is the missing piece of my puzzle. I > transformed > > a bit your solution, polluting it with some classes instances and > fleshing > > the functions: > > > > data Player = Arrive | Leave deriving (Show, Typeable, Eq) > > data Message m = Message String deriving (Show, Typeable, Eq) > > > > > > data Data a where > > PlayerData :: Int -> Data Player > > MessageData :: m -> Data (Message m) > > > > data Handler where > > Handler :: (Typeable e) => e -> (Data e -> IO ()) -> Handler > > > > instance forall e. (Typeable e) => Typeable (Data e) where > > typeOf _ = mkTyConApp (mkTyCon( ("Expression.EventData (" ++ (show $ > > typeOf (undefined::e))) ++ ")" )) [] > > > > addEvent :: (Typeable e) => e -> (Data e -> IO ()) -> [Handler] -> > [Handler] > > addEvent e h hs = (Handler e h) : hs > > > > triggerEvent :: (Eq e, Typeable e) => e -> Data e -> [Handler] -> IO () > > triggerEvent e d hs = do > > let filtered = filter (\(Handler e1 _) -> e1 === e) hs > > mapM_ f filtered where > > f (Handler _ h) = case cast h of > > Just castedH -> do > > castedH d > > Nothing -> return () > > > > viewEvent :: (Typeable e) => e -> IO() > > > > viewEvent event = do > > case cast event of > > Just (a :: Player) -> putStrLn $ "Player" ++ show a > > > > Nothing -> return () > > case cast event of > > (Just (Message s)) -> putStrLn $ "Player" ++ s > > Nothing -> return () > > > > > > Unfortunately, I still cannot pattern match on the events to view them > > (viewEvent won't compile)... > > Mixing GADTs and Typeable seems like a bad idea. If you really don't > want to put viewEvent in the Event typeclass, but the class of events > is closed, you could use a GADT to witness the event type. > > class Event e where > eventType :: EventType e > ... > > data EventType e where > PlayerEvent :: EventType Player > MessageEvent :: EventType (Message m) > > viewEvent :: Event e => e -> IO () > viewEvent = viewEvent' eventType > > viewEvent' :: EventType e -> e -> IO () > viewEvent' PlayerEvent e = ... > viewEvent' MessageEvent (Message s) = ... > > -- > Dave Menendez > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From leather at cs.uu.nl Tue Sep 11 20:09:26 2012 From: leather at cs.uu.nl (Sean Leather) Date: Tue, 11 Sep 2012 20:09:26 +0200 Subject: [Haskell-cafe] type variable in class instance In-Reply-To: References: <20120911065332.1997.qmail@www1.g3.pair.com> <504F25AC.2000603@oblomov.com> Message-ID: On Tue, Sep 11, 2012 at 6:46 PM, David Menendez wrote: > Mixing GADTs and Typeable seems like a bad idea. If you really don't > want to put viewEvent in the Event typeclass, but the class of events > is closed, you could use a GADT to witness the event type. On Tue, Sep 11, 2012 at 7:03 PM, Corentin Dupont wrote: > unfortunately it seems that I will be obliged to maintain 2 parallel > structures: > for each Event instance, I will have to add a ViewEvent element as well > carrying the same information: That's why I like the all-GADT solution... Inspired by David's suggestion, here's another version without Typeable. In Corentin's version, the switching back and forth between explicit and forgetful typing bothered me. This version never forgets types. Also, viewEvent is really an instance of Show, as I would expect. I don't see the extra maintenance burden mentioned by Corentin. {-# LANGUAGE TypeFamilies, GADTs #-} data Player = Arrive | Leave deriving Show newtype Message t = Message String deriving (Eq, Show) data Type :: * -> * where Int :: Type (Message Int) String :: Type (Message String) Player :: Type Player data TEq :: * -> * -> * where Refl :: TEq a a teq :: Type a -> Type b -> Maybe (TEq a b) teq Int Int = Just Refl teq String String = Just Refl teq Player Player = Just Refl teq _ _ = Nothing type family Data t :: * type instance Data (Message t) = t type instance Data Player = Int data Event t = Event (Type t) t data Handler where Handler :: Event t -> (Data t -> IO ()) -> Handler runHandler :: Eq t => Event t -> Data t -> Handler -> IO () runHandler (Event t e) d (Handler (Event u e') f) = case teq t u of Just Refl | e == e' -> f d _ -> return () runHandlers :: Eq t => Event t -> Data t -> [Handler] -> IO () runHandlers e d hs = mapM_ (runHandler e d) hs -- Replacement for viewEvent instance Show (Event t) where show (Event ty e) = case ty of Int -> show e ++ " of type Int" String -> show e ++ " of type String" Player -> "Player " ++ show e messageEvent :: Type (Message t) -> String -> Event (Message t) messageEvent t s = Event t (Message s) playerEvent :: Player -> Event Player playerEvent = Event Player -- Tests event1 = messageEvent Int "give me a number" -- No type signature necessary! handler1 = Handler event1 (\n -> putStrLn $ "Your number is: " ++ show n) test1 = runHandlers event1 1 [handler1] -- Yields "Your number is: 1" Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: From qdunkan at gmail.com Tue Sep 11 20:48:43 2012 From: qdunkan at gmail.com (Evan Laforge) Date: Tue, 11 Sep 2012 11:48:43 -0700 Subject: [Haskell-cafe] Either Monad and Laziness In-Reply-To: References: Message-ID: On Tue, Sep 11, 2012 at 9:36 AM, Eric Velten de Melo wrote: > Any thoughts? Hopefully I'm not saying anything really stupid. You can intersperse decoding errors in the output, e.g. output is [Either Error DecodedChunk]. Then all the processors have to deal with it, but if you just want to pass the error through then just 'map . fmap' instead of 'map'. This means processors can also inject their own errors or logs into the output, which may be very useful. Or you could use runtime exceptions, i.e. the decoder is lazy but can call error. This is bad for reliability but if you know you always want to crash on a bad parse it keeps the return value simple. From corentin.dupont at gmail.com Tue Sep 11 21:18:57 2012 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Tue, 11 Sep 2012 21:18:57 +0200 Subject: [Haskell-cafe] type variable in class instance In-Reply-To: References: <20120911065332.1997.qmail@www1.g3.pair.com> <504F25AC.2000603@oblomov.com> Message-ID: That's very interesting. One problem is, if the set of event is closed, the set of possible data types is not (the user can choose any data type for a Message callback for example). I think this can be solved using a class instead of a GADT for "Type". One can also use a type witness? On Tue, Sep 11, 2012 at 8:09 PM, Sean Leather wrote: > On Tue, Sep 11, 2012 at 6:46 PM, David Menendez wrote: > > Mixing GADTs and Typeable seems like a bad idea. If you really don't >> want to put viewEvent in the Event typeclass, but the class of events >> is closed, you could use a GADT to witness the event type. > > > On Tue, Sep 11, 2012 at 7:03 PM, Corentin Dupont wrote: > >> unfortunately it seems that I will be obliged to maintain 2 parallel >> structures: >> for each Event instance, I will have to add a ViewEvent element as well >> carrying the same information: > > That's why I like the all-GADT solution... > > > Inspired by David's suggestion, here's another version without Typeable. > In Corentin's version, the switching back and forth between explicit and > forgetful typing bothered me. This version never forgets types. Also, > viewEvent is really an instance of Show, as I would expect. I don't see the > extra maintenance burden mentioned by Corentin. > > {-# LANGUAGE TypeFamilies, GADTs #-} > > data Player = Arrive | Leave deriving Show > newtype Message t = Message String deriving (Eq, Show) > > data Type :: * -> * where > Int :: Type (Message Int) > String :: Type (Message String) > Player :: Type Player > > data TEq :: * -> * -> * where > Refl :: TEq a a > > teq :: Type a -> Type b -> Maybe (TEq a b) > teq Int Int = Just Refl > teq String String = Just Refl > teq Player Player = Just Refl > teq _ _ = Nothing > > type family Data t :: * > type instance Data (Message t) = t > type instance Data Player = Int > > data Event t = Event (Type t) t > > data Handler where > Handler :: Event t -> (Data t -> IO ()) -> Handler > > runHandler :: Eq t => Event t -> Data t -> Handler -> IO () > runHandler (Event t e) d (Handler (Event u e') f) = > case teq t u of > Just Refl | e == e' -> f d > _ -> return () > > runHandlers :: Eq t => Event t -> Data t -> [Handler] -> IO () > runHandlers e d hs = mapM_ (runHandler e d) hs > > -- Replacement for viewEvent > instance Show (Event t) where > show (Event ty e) = > case ty of > Int -> show e ++ " of type Int" > String -> show e ++ " of type String" > Player -> "Player " ++ show e > > messageEvent :: Type (Message t) -> String -> Event (Message t) > messageEvent t s = Event t (Message s) > > playerEvent :: Player -> Event Player > playerEvent = Event Player > > -- Tests > > event1 = messageEvent Int "give me a number" -- No type signature > necessary! > handler1 = Handler event1 (\n -> putStrLn $ "Your number is: " ++ show n) > test1 = runHandlers event1 1 [handler1] -- Yields "Your number is: 1" > > Regards, > Sean > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timothyhobbs at seznam.cz Tue Sep 11 21:51:53 2012 From: timothyhobbs at seznam.cz (timothyhobbs at seznam.cz) Date: Tue, 11 Sep 2012 21:51:53 +0200 (CEST) Subject: [Haskell-cafe] Either Monad and Laziness References: Message-ID: <1Kx.1kb30.5mK{{TqhDZF.1GJvPP@seznam.cz> Use a tuple: (Result,Maybe Error) rather than an Either.? Do everything lazily, and in the case of an error, undo the result. ---------- P?vodn? zpr?va ---------- Od: Eric Velten de Melo Datum: 11. 9. 2012 P?edm?t: [Haskell-cafe] Either Monad and Laziness "Hello, I am currently trying to rewrite the Graphics.Pgm library from hackage to parse the PGM to a lazy array. The current implementation parses it straight to UArray, which is strict. The behaviour I want to achieve is like this: I want the program when compiled to read from a file, parsing the PGM and at the same time apply transformations to the entries as they are read and write them back to another PGM file. The problem is that even using a lazy array structure, because the parser returns an Either structure it is only possible to know if the parser was successful or not after the whole file is read, therefore requiring it to read the entire file before applying the transformations, ruining the property of laziness. Is there some way to keep this from happening? Should I even want to make it like this? Not really a real life situation, but imagine I want to read a reaaaaally large PGM file which does not fit into RAM memory and I don't want to be forced to have the whole array in the memory at once. One alternative I thought was parsing only the PGM header and then read the rest of the input without using Parsec and the Either Monad. In the event the data is corrupted, though, I would not know how to recover from it. Any thoughts? Hopefully I'm not saying anything really stupid. Eric _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe at haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe (http://www.haskell.org/mailman/listinfo/haskell-cafe)" -------------- next part -------------- An HTML attachment was scrubbed... URL: From leather at cs.uu.nl Tue Sep 11 22:18:30 2012 From: leather at cs.uu.nl (Sean Leather) Date: Tue, 11 Sep 2012 22:18:30 +0200 Subject: [Haskell-cafe] type variable in class instance In-Reply-To: References: <20120911065332.1997.qmail@www1.g3.pair.com> <504F25AC.2000603@oblomov.com> Message-ID: On Tue, Sep 11, 2012 at 9:18 PM, Corentin Dupont wrote: > That's very interesting. > One problem is, if the set of event is closed, the set of possible data > types is not (the user can choose any data type for a Message callback for > example). I think this can be solved using a class instead of a GADT for > "Type". One can also use a type witness? > Just a "bit" more complicated... {-# LANGUAGE TypeFamilies, GADTs #-} import Data.Typeable import Unsafe.Coerce data Player = Arrive | Leave deriving Show newtype Message t = Message String deriving (Eq, Show) data Type :: * -> * where MessageT :: Typeable t => Proxy t -> Type (Message t) PlayerT :: Type Player data Proxy t typeOfProxy :: Typeable t => Proxy t -> TypeRep typeOfProxy x = typeOf (unproxy x) where unproxy :: Proxy t -> t unproxy = undefined data TEq :: * -> * -> * where Refl :: TEq a a teq :: Type a -> Type b -> Maybe (TEq a b) teq (MessageT p) (MessageT q) | typeOfProxy p == typeOfProxy q = Just (unsafeCoerce Refl) teq PlayerT PlayerT = Just Refl teq _ _ = Nothing type family Data t :: * type instance Data (Message t) = t type instance Data Player = Int data Event t = Event (Type t) t data Handler where Handler :: Event t -> (Data t -> IO ()) -> Handler runHandler :: Eq t => Event t -> Data t -> Handler -> IO () runHandler (Event t e) d (Handler (Event u e') f) = case teq t u of Just Refl | e == e' -> f d _ -> return () runHandlers :: Eq t => Event t -> Data t -> [Handler] -> IO () runHandlers e d hs = mapM_ (runHandler e d) hs -- Replacement for viewEvent instance Show (Event t) where show (Event ty e) = case ty of MessageT t -> show e ++ " of type " ++ show (typeOfProxy t) PlayerT -> "Player " ++ show e messageEvent :: Typeable t => Proxy t -> String -> Event (Message t) messageEvent t s = Event (MessageT t) (Message s) playerEvent :: Player -> Event Player playerEvent = Event PlayerT -- Tests int :: Proxy Int int = undefined event1 = messageEvent int "give me a number" -- No type signature necessary! handler1 = Handler event1 (\n -> putStrLn $ "Your number is: " ++ show n) test1 = runHandlers event1 1 [handler1] -- Yields "Your number is: 1" The Proxy type is not absolutely necessary, because you can use the type directly. But I think the Proxy makes it clear that no (non-bottom) terms of the type are expected. Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: From mgsloan at gmail.com Wed Sep 12 01:04:48 2012 From: mgsloan at gmail.com (Michael Sloan) Date: Tue, 11 Sep 2012 16:04:48 -0700 Subject: [Haskell-cafe] Pattern matching: multi constructors to same branch In-Reply-To: References: Message-ID: I've seen this asked before, and I think some languages support it (ML maybe?). One way to do this is with view patterns: g f C = [f C] g f (getVN -> (v, n)) = f v : g f n getVN v@(A _ n) = (v, n) getVN v@(B _ n) = (v, n) (I changed the recursive call to g - figured you meant passing along f) If you need to still have match clauses after that, for falling through when it's not something that getVN matches, then have it yield a Maybe, and match on Just. -Michael On Tue, Sep 11, 2012 at 9:43 AM, Thiago Negri wrote: > Is it possible to capture more than one constructor in a single > pattern matching? > I mean, is it possible to generalize the following pattern matching of > A and B to a single branch? > > g f C = [f C] > g f v@(A _ n) = f v : g n > g f v@(B _ n) = f v : g n > > For example: > > g f C = [f C] > g f v@(A|B _ n) = f v : g n > > Or: > > g f v = > case v of > C -> [f C] > A|B -> f v : g (n v) > > > Thanks. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From oleg at okmij.org Wed Sep 12 07:44:55 2012 From: oleg at okmij.org (oleg at okmij.org) Date: 12 Sep 2012 05:44:55 -0000 Subject: [Haskell-cafe] type variable in class instance In-Reply-To: Message-ID: <20120912054455.79615.qmail@www1.g3.pair.com> Let me see if I understand. You have events of different sorts: events about players, events about timeouts, events about various messages. Associated with each sort of event is a (potentially open) set of data types: messages can carry payload of various types. A handler specifies behavior of a system upon the reception of an event. A game entity (player, monster, etc) is a collection of behaviors. The typing problem is building the heterogeneous collection of behaviors and routing an event to the appropriate handler. Is this right? There seem to be two main implementations, with explicit types and latent (dynamic) types. The explicit-type representation is essentially HList (a Type-indexed Record, TIR, to be precise). Let's start with the latent-type representation. Now I understand your problem better, I think your original approach was the right one. GADT was a distraction, sorry. Hopefully you find the code below better reflects your intentions. {-# LANGUAGE ExistentialQuantification, DeriveDataTypeable #-} {-# LANGUAGE StandaloneDeriving #-} import Data.Typeable -- Events sorts data Player = Player PlayerN PlayerStatus deriving (Eq, Show, Typeable) type PlayerN = Int data PlayerStatus = Enetering | Leaving deriving (Eq, Show) newtype Message m = Message m deriving (Eq, Show) deriving instance Typeable1 Message newtype Time = Time Int deriving (Eq, Show, Typeable) data SomeEvent = forall e. Typeable e => SomeEvent e deriving (Typeable) -- They are all events class Typeable e => Event e where -- the Event predicate what_event :: SomeEvent -> Maybe e what_event (SomeEvent e) = cast e instance Event Player instance Event Time instance Typeable m => Event (Message m) instance Event SomeEvent where what_event = Just -- A handler is a reaction on an event -- Given an event, a handler may decline to handle it type Handler e = e -> Maybe (IO ()) inj_handler :: Event e => Handler e -> Handler SomeEvent inj_handler h se | Just e <- what_event se = h e inj_handler _ _ = Nothing type Handlers = [Handler SomeEvent] trigger :: Event e => e -> Handlers -> IO () trigger e [] = fail "Not handled" trigger e (h:rest) | Just rh <- h (SomeEvent e) = rh | otherwise = trigger e rest -- Sample behaviors -- viewing behavior (although viewing is better with Show since all -- particular events implement it anyway) view_player :: Handler Player view_player (Player x s) = Just . putStrLn . unwords $ ["Player", show x, show s] -- View a particular message view_msg_str :: Handler (Message String) view_msg_str (Message s) = Just . putStrLn . unwords $ ["Message", s] -- View any message view_msg_any :: Handler SomeEvent view_msg_any (SomeEvent e) | (tc1,[tr]) <- splitTyConApp (typeOf e), (tc2,_) <- splitTyConApp (typeOf (undefined::Message ())), tc1 == tc2 = Just . putStrLn . unwords $ ["Some message of the type", show tr] view_msg_any _ = Nothing viewers = [inj_handler view_player, inj_handler view_msg_str, view_msg_any] test1 = trigger (Player 1 Leaving) viewers -- Player 1 Leaving test2 = trigger (Message "str1") viewers -- Message str1 test3 = trigger (Message (2::Int)) viewers -- Some message of the type Int From oleg at okmij.org Wed Sep 12 08:03:30 2012 From: oleg at okmij.org (oleg at okmij.org) Date: 12 Sep 2012 06:03:30 -0000 Subject: [Haskell-cafe] Either Monad and Laziness Message-ID: <20120912060330.83793.qmail@www1.g3.pair.com> > I am currently trying to rewrite the Graphics.Pgm library from hackage > to parse the PGM to a lazy array. Laziness and IO really do not mix. > The problem is that even using a lazy array structure, because the > parser returns an Either structure it is only possible to know if the > parser was successful or not after the whole file is read, That is one of the problems. Unexpected memory blowups could be another problem. The drawbacks of lazy IO are well documented by now. > The behaviour I want to achieve is like this: I want the program when > compiled to read from a file, parsing the PGM and at the same time > apply transformations to the entries as they are read and write them > back to another PGM file. Such problems are the main motivation for iteratees, conduits, pipes, etc. Every such library contains procedures for doing exactly what you want. Please check Hackage. John Lato's iteratee library, for example, has procedure for handling sound (AIFF) files -- which may be very big. IterateeM has the TIFF decoder -- which is incremental and strict. TIFF is much harder to parse than PGM. From ierton at gmail.com Wed Sep 12 10:24:06 2012 From: ierton at gmail.com (Sergey Mironov) Date: Wed, 12 Sep 2012 12:24:06 +0400 Subject: [Haskell-cafe] IO vs MonadIO Message-ID: Hi. Just a brief question. System.IO functions are defined in IO monad and have signatures like Foo -> IO Bar. Would it be better to have all of them defined as (MonadIO m) => Foo -> m Bar? What are the problems that would arise? Sergey From ivan.miljenovic at gmail.com Wed Sep 12 11:55:50 2012 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Wed, 12 Sep 2012 19:55:50 +1000 Subject: [Haskell-cafe] IO vs MonadIO In-Reply-To: References: Message-ID: On 12 September 2012 18:24, Sergey Mironov wrote: > Hi. Just a brief question. System.IO functions are defined in IO monad > and have signatures like Foo -> IO Bar. > Would it be better to have all of them defined as (MonadIO m) => Foo > -> m Bar? What are the problems that would arise? That would require MonadIO being defined in base, and might make some existing code fail due to lack of type signatures (though I suppose you could specify a default). -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From ivan.miljenovic at gmail.com Wed Sep 12 11:56:40 2012 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Wed, 12 Sep 2012 19:56:40 +1000 Subject: [Haskell-cafe] IO vs MonadIO In-Reply-To: References: Message-ID: On 12 September 2012 19:55, Ivan Lazar Miljenovic wrote: > On 12 September 2012 18:24, Sergey Mironov wrote: >> Hi. Just a brief question. System.IO functions are defined in IO monad >> and have signatures like Foo -> IO Bar. >> Would it be better to have all of them defined as (MonadIO m) => Foo >> -> m Bar? What are the problems that would arise? > > That would require MonadIO being defined in base, and might make some > existing code fail due to lack of type signatures (though I suppose > you could specify a default). Oh, and you'd still need to define them all somewhere to work _for_ IO so you can then have the liftIO variants anyway. > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic at gmail.com > http://IvanMiljenovic.wordpress.com -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From corentin.dupont at gmail.com Wed Sep 12 12:55:20 2012 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Wed, 12 Sep 2012 12:55:20 +0200 Subject: [Haskell-cafe] type variable in class instance In-Reply-To: <20120912054455.79615.qmail@www1.g3.pair.com> References: <20120912054455.79615.qmail@www1.g3.pair.com> Message-ID: If I understand, the SomeEvent event acts as a proxy to hide the diversity of the events? That's interesting. This way I don't have to use an heterogeneous list and a lot of casting... On Wed, Sep 12, 2012 at 7:44 AM, wrote: > > Let me see if I understand. You have events of different sorts: events > about players, events about timeouts, events about various > messages. Associated with each sort of event is a (potentially open) > set of data types: messages can carry payload of various types. A > handler specifies behavior of a system upon the reception of an > event. A game entity (player, monster, etc) is a collection of > behaviors. The typing problem is building the heterogeneous collection > of behaviors and routing an event to the appropriate handler. Is this > right? > > There seem to be two main implementations, with explicit types and latent > (dynamic) types. The explicit-type representation is essentially HList > (a Type-indexed Record, TIR, to be precise). Let's start with the > latent-type representation. Now I understand your problem better, I > think your original approach was the right one. GADT was a > distraction, sorry. Hopefully you find the code below better reflects > your intentions. > > {-# LANGUAGE ExistentialQuantification, DeriveDataTypeable #-} > {-# LANGUAGE StandaloneDeriving #-} > > import Data.Typeable > > -- Events sorts > > data Player = Player PlayerN PlayerStatus > deriving (Eq, Show, Typeable) > > type PlayerN = Int > data PlayerStatus = Enetering | Leaving > deriving (Eq, Show) > > newtype Message m = Message m > deriving (Eq, Show) > > deriving instance Typeable1 Message > > newtype Time = Time Int > deriving (Eq, Show, Typeable) > > data SomeEvent = forall e. Typeable e => SomeEvent e > deriving (Typeable) > > -- They are all events > > class Typeable e => Event e where -- the Event > predicate > what_event :: SomeEvent -> Maybe e > what_event (SomeEvent e) = cast e > > > instance Event Player > instance Event Time > instance Typeable m => Event (Message m) > > instance Event SomeEvent where > what_event = Just > > -- A handler is a reaction on an event > -- Given an event, a handler may decline to handle it > type Handler e = e -> Maybe (IO ()) > > inj_handler :: Event e => Handler e -> Handler SomeEvent > inj_handler h se | Just e <- what_event se = h e > inj_handler _ _ = Nothing > > > type Handlers = [Handler SomeEvent] > > trigger :: Event e => e -> Handlers -> IO () > trigger e [] = fail "Not handled" > trigger e (h:rest) > | Just rh <- h (SomeEvent e) = rh > | otherwise = trigger e rest > > -- Sample behaviors > > -- viewing behavior (although viewing is better with Show since all > -- particular events implement it anyway) > > view_player :: Handler Player > view_player (Player x s) = Just . putStrLn . unwords $ > ["Player", show x, show s] > > -- View a particular message > view_msg_str :: Handler (Message String) > view_msg_str (Message s) = Just . putStrLn . unwords $ > ["Message", s] > > -- View any message > view_msg_any :: Handler SomeEvent > view_msg_any (SomeEvent e) > | (tc1,[tr]) <- splitTyConApp (typeOf e), > (tc2,_) <- splitTyConApp (typeOf (undefined::Message ())), > tc1 == tc2 = > Just . putStrLn . unwords $ ["Some message of the type", show tr] > view_msg_any _ = Nothing > > viewers = [inj_handler view_player, inj_handler view_msg_str, view_msg_any] > > > test1 = trigger (Player 1 Leaving) viewers > -- Player 1 Leaving > > test2 = trigger (Message "str1") viewers > -- Message str1 > > test3 = trigger (Message (2::Int)) viewers > -- Some message of the type Int > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alfredo.dinapoli at gmail.com Wed Sep 12 15:03:49 2012 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Wed, 12 Sep 2012 13:03:49 +0000 Subject: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell Message-ID: Hi everyone, in case you have missed it, I've released a Vim plugin called Cumino: http://adinapoli.github.com/cumino/ It does one simple thing: It allows communication between Vim and tmux, in particular to a ghci session. With Cumino you can fire-up Vim, load a ghci session and interact with it with only few keystrokes. The plugin also supports visual selection: you can select for example a function (even with all its signature!) and you can send it to ghci. The visual selection supports imports, custom types and typeclasses. It's a simple idea but so damn useful, imho. This release also adds the possibility to prettify the code using the excellent stylish-haskell: select a snippet, simply indent in the usual way ( = ) and voil?, now your code is indented! Feedback are highly appreciated, as well as contributions. There are still some issues with some terminals (for example urxvt does not work right now) but the plugin has been tested against gnome-terminal, xterm and mlterm. I'll post in reddit too for completeness! Bye! Alfredo -------------- next part -------------- An HTML attachment was scrubbed... URL: From matvey.aksenov at gmail.com Wed Sep 12 15:18:23 2012 From: matvey.aksenov at gmail.com (Matvey Aksenov) Date: Wed, 12 Sep 2012 17:18:23 +0400 Subject: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell In-Reply-To: References: Message-ID: <50508B9F.8030005@gmail.com> Are urxvt-related issues documented somewhere? On 09/12/2012 05:03 PM, Alfredo Di Napoli wrote: > There are still some issues with some terminals (for example urxvt > does not work right now) From tifonzafel at gmail.com Wed Sep 12 16:40:11 2012 From: tifonzafel at gmail.com (felipe zapata) Date: Wed, 12 Sep 2012 16:40:11 +0200 Subject: [Haskell-cafe] guards in applicative style Message-ID: Hi Haskellers, Suppose I have two list and I want to calculate the cartesian product between the two of them, constrained to a predicate. In List comprehension notation is just result = [ (x, y) | x <- list1, y <-list2, somePredicate x y ] or in monadic notation result = do x <- list1 y <- list2 guard (somePredicate x y) return $ (x,y) Then I was wondering if we can do something similar using an applicative style result = (,) <$> list1 <*> list2 (somePredicate ???) The question is then, there is a way for defining a guard in applicative Style? Thanks in advance, Felipe Zapata. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ericvmelo at gmail.com Wed Sep 12 16:46:00 2012 From: ericvmelo at gmail.com (Eric Velten de Melo) Date: Wed, 12 Sep 2012 11:46:00 -0300 Subject: [Haskell-cafe] Either Monad and Laziness In-Reply-To: <20120912060330.83793.qmail@www1.g3.pair.com> References: <20120912060330.83793.qmail@www1.g3.pair.com> Message-ID: Thanks for all the tips! The iteratees seem worth checking out. I'll see what I can do and will report back if I come up with something. Eric On 12 September 2012 03:03, wrote: > >> I am currently trying to rewrite the Graphics.Pgm library from hackage >> to parse the PGM to a lazy array. > > Laziness and IO really do not mix. > >> The problem is that even using a lazy array structure, because the >> parser returns an Either structure it is only possible to know if the >> parser was successful or not after the whole file is read, > > That is one of the problems. Unexpected memory blowups could be > another problem. The drawbacks of lazy IO are well documented by now. > >> The behaviour I want to achieve is like this: I want the program when >> compiled to read from a file, parsing the PGM and at the same time >> apply transformations to the entries as they are read and write them >> back to another PGM file. > > Such problems are the main motivation for iteratees, conduits, pipes, > etc. Every such library contains procedures for doing exactly what you > want. Please check Hackage. John Lato's iteratee library, for example, > has procedure for handling sound (AIFF) files -- which may be very > big. IterateeM has the TIFF decoder -- which is incremental and > strict. TIFF is much harder to parse than PGM. > > From lbolla at gmail.com Wed Sep 12 16:52:03 2012 From: lbolla at gmail.com (Lorenzo Bolla) Date: Wed, 12 Sep 2012 15:52:03 +0100 Subject: [Haskell-cafe] guards in applicative style In-Reply-To: References: Message-ID: I'm no expert at all, but I would say "no". "guard" type is: guard :: MonadPlus m => Bool -> m () and "MonadPlus" is a monad "plus" (ehm...) mzero and mplus (http://en.wikibooks.org/wiki/Haskell/MonadPlus). On the other hand Applicative is "less" than a monad (http://www.haskell.org/haskellwiki/Applicative_functor), therefore "guard" as is cannot be defined. But, in your specific example, with lists, you can always use "filter": filter (uncurry somePredicate) ((,) <$> list1 <*> list2 (somePredicate ???)) hth, L. On Wed, Sep 12, 2012 at 3:40 PM, felipe zapata wrote: > > Hi Haskellers, > > Suppose I have two list and I want to calculate > the cartesian product between the two of them, > constrained to a predicate. > In List comprehension notation is just > > result = [ (x, y) | x <- list1, y <-list2, somePredicate x y ] > > or in monadic notation > > result = do > x <- list1 > y <- list2 > guard (somePredicate x y) > return $ (x,y) > > Then I was wondering if we can do something similar using an applicative style > > result = (,) <$> list1 <*> list2 (somePredicate ???) > > The question is then, > there is a way for defining a guard in applicative Style? > > Thanks in advance, > > Felipe Zapata. > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ericvmelo at gmail.com Wed Sep 12 17:04:31 2012 From: ericvmelo at gmail.com (Eric Velten de Melo) Date: Wed, 12 Sep 2012 12:04:31 -0300 Subject: [Haskell-cafe] Either Monad and Laziness In-Reply-To: References: <20120912060330.83793.qmail@www1.g3.pair.com> Message-ID: On 12 September 2012 11:46, Eric Velten de Melo wrote: > Thanks for all the tips! The iteratees seem worth checking out. I'll > see what I can do and will report back if I come up with something. > > Eric > > On 12 September 2012 03:03, wrote: >> >>> I am currently trying to rewrite the Graphics.Pgm library from hackage >>> to parse the PGM to a lazy array. >> >> Laziness and IO really do not mix. >> >>> The problem is that even using a lazy array structure, because the >>> parser returns an Either structure it is only possible to know if the >>> parser was successful or not after the whole file is read, >> >> That is one of the problems. Unexpected memory blowups could be >> another problem. The drawbacks of lazy IO are well documented by now. >> >>> The behaviour I want to achieve is like this: I want the program when >>> compiled to read from a file, parsing the PGM and at the same time >>> apply transformations to the entries as they are read and write them >>> back to another PGM file. >> >> Such problems are the main motivation for iteratees, conduits, pipes, >> etc. Every such library contains procedures for doing exactly what you >> want. Please check Hackage. John Lato's iteratee library, for example, >> has procedure for handling sound (AIFF) files -- which may be very >> big. IterateeM has the TIFF decoder -- which is incremental and >> strict. TIFF is much harder to parse than PGM. >> It would be really awesome, though, if it were possible to use a parser written in Parsec with this, in the spirit of avoiding code rewriting and enhancing expressivity and abstraction. From roma at ro-che.info Wed Sep 12 17:06:22 2012 From: roma at ro-che.info (Roman Cheplyaka) Date: Wed, 12 Sep 2012 17:06:22 +0200 Subject: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell In-Reply-To: References: Message-ID: So, suppose that I'm in a terminal vim session, and I want to start ghci (in the current terminal). What do I do? cc starts a new terminal, which is not what I want. On Wed, Sep 12, 2012 at 3:03 PM, Alfredo Di Napoli < alfredo.dinapoli at gmail.com> wrote: > Hi everyone, > > in case you have missed it, I've released a Vim plugin called Cumino: > > http://adinapoli.github.com/cumino/ > > It does one simple thing: It allows communication between Vim and tmux, in > particular to a ghci session. With Cumino you can fire-up Vim, > load a ghci session and interact with it with only few keystrokes. The > plugin also supports visual selection: you can select for example a > function (even with all its signature!) > and you can send it to ghci. The visual selection supports imports, custom > types and typeclasses. > > It's a simple idea but so damn useful, imho. > > This release also adds the possibility to prettify the code using the > excellent stylish-haskell: select a snippet, simply indent in the usual way > ( = ) and voil?, now > your code is indented! > > Feedback are highly appreciated, as well as contributions. > There are still some issues with some terminals (for example urxvt does > not work right now) but the plugin has been tested against gnome-terminal, > xterm and mlterm. > > I'll post in reddit too for completeness! > > Bye! > Alfredo > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alfredo.dinapoli at gmail.com Wed Sep 12 17:25:52 2012 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Wed, 12 Sep 2012 17:25:52 +0200 Subject: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell In-Reply-To: <50508B9F.8030005@gmail.com> References: <50508B9F.8030005@gmail.com> Message-ID: <302E04D5-7A10-4F5F-8294-47C80AC0FF11@gmail.com> Hi, I'm not in front of the pc now, but afair the problem was related to opening a new urxvt window FROM a running urxvt. More details soon :) Sent from my iPad On 12/set/2012, at 15:18, Matvey Aksenov wrote: > Are urxvt-related issues documented somewhere? > > On 09/12/2012 05:03 PM, Alfredo Di Napoli wrote: >> There are still some issues with some terminals (for example urxvt does not work right now) From alfredo.dinapoli at gmail.com Wed Sep 12 17:28:00 2012 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Wed, 12 Sep 2012 17:28:00 +0200 Subject: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell In-Reply-To: References: Message-ID: Could you please tell me what your desired behaviour would be? In praticular, do you want a ghci session in another tab or in a tmux pane perhaps? Otherwise I can't see any viable way to let vim and ghci cooperate inside the SAME window. Bye, Alfredo Sent from my iPad On 12/set/2012, at 17:05, Roman Cheplyaka wrote: > So, suppose that I'm in a terminal vim session, and I want to start ghci (in the current terminal). What do I do? > > cc starts a new terminal, which is not what I want. > > On Wed, Sep 12, 2012 at 3:03 PM, Alfredo Di Napoli wrote: > Hi everyone, > > in case you have missed it, I've released a Vim plugin called Cumino: > > http://adinapoli.github.com/cumino/ > > It does one simple thing: It allows communication between Vim and tmux, in particular to a ghci session. With Cumino you can fire-up Vim, > load a ghci session and interact with it with only few keystrokes. The plugin also supports visual selection: you can select for example a function (even with all its signature!) > and you can send it to ghci. The visual selection supports imports, custom types and typeclasses. > > It's a simple idea but so damn useful, imho. > > This release also adds the possibility to prettify the code using the excellent stylish-haskell: select a snippet, simply indent in the usual way ( = ) and voil?, now > your code is indented! > > Feedback are highly appreciated, as well as contributions. > There are still some issues with some terminals (for example urxvt does not work right now) but the plugin has been tested against gnome-terminal, xterm and mlterm. > > I'll post in reddit too for completeness! > > Bye! > Alfredo > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From f at mazzo.li Wed Sep 12 17:37:03 2012 From: f at mazzo.li (Francesco Mazzoli) Date: Wed, 12 Sep 2012 16:37:03 +0100 Subject: [Haskell-cafe] Either Monad and Laziness In-Reply-To: References: <20120912060330.83793.qmail@www1.g3.pair.com> Message-ID: <87vcfjxnfk.wl%f@mazzo.li> At Wed, 12 Sep 2012 12:04:31 -0300, Eric Velten de Melo wrote: > It would be really awesome, though, if it were possible to use a > parser written in Parsec with this, in the spirit of avoiding code > rewriting and enhancing expressivity and abstraction. There is and , which turn attoparsec parsers into enumerators/conduits, and , which is a compatibility layer between attoaparsec and parsec. Good luck :). -- Francesco * Often in error, never in doubt From member at linkedin.com Wed Sep 12 17:42:31 2012 From: member at linkedin.com (Sakari Joinen via LinkedIn) Date: Wed, 12 Sep 2012 15:42:31 +0000 (UTC) Subject: [Haskell-cafe] Invitation to connect on LinkedIn Message-ID: <1663877330.956242.1347464551072.JavaMail.app@ela4-app2319.prod> LinkedIn ------------ Sakari Joinen requested to add you as a connection on LinkedIn: ------------------------------------------ Steve, I'd like to add you to my professional network on LinkedIn. - Sakari Accept invitation from Sakari Joinen http://www.linkedin.com/e/uc6lxc-h70llpqy-2x/XvIdBwmueHfd6vFMPXXdLaqreCbl5oOSpPTFPU/blk/I425561150_15/0UcDpKqiRzolZKqiRybmRSrCBvrmRLoORIrmkZt5YCpnlOt3RApnhMpmdzgmhxrSNBszYRclYMdj4NdzkRczh9bThqd3kOp5tMbP0TdjgMd3wNdzwLrCBxbOYWrSlI/eml-comm_invm-b-in_ac-inv28/?hs=false&tok=0SXF1g5wqeHlo1 View profile of Sakari Joinen http://www.linkedin.com/e/uc6lxc-h70llpqy-2x/rso/203924390/GIO8/name/2590796_I425561150_15/?hs=false&tok=31wLM7O9ueHlo1 ------------------------------------------ You are receiving Invitation emails. This email was intended for Steve Severance. Learn why this is included: http://www.linkedin.com/e/uc6lxc-h70llpqy-2x/plh/http%3A%2F%2Fhelp%2Elinkedin%2Ecom%2Fapp%2Fanswers%2Fdetail%2Fa_id%2F4788/-GXI/?hs=false&tok=38T1PPvOmeHlo1 (c) 2012, LinkedIn Corporation. 2029 Stierlin Ct, Mountain View, CA 94043, USA. -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Wed Sep 12 18:59:23 2012 From: allbery.b at gmail.com (Brandon Allbery) Date: Wed, 12 Sep 2012 12:59:23 -0400 Subject: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell In-Reply-To: <302E04D5-7A10-4F5F-8294-47C80AC0FF11@gmail.com> References: <50508B9F.8030005@gmail.com> <302E04D5-7A10-4F5F-8294-47C80AC0FF11@gmail.com> Message-ID: On Wed, Sep 12, 2012 at 11:25 AM, Alfredo Di Napoli < alfredo.dinapoli at gmail.com> wrote: > I'm not in front of the pc now, but afair the problem was related to > opening a new urxvt window FROM a running urxvt. > More details soon :) > urxvt defaults to using a client-server model for all terminals, IIRC (we have a warning about it in the xmonad documentation as well since it messes up ManageHooks). There's possibly some option to disable this and force an independent terminal. -- brandon s allbery allbery.b at gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms -------------- next part -------------- An HTML attachment was scrubbed... URL: From alfredo.dinapoli at gmail.com Wed Sep 12 19:36:42 2012 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Wed, 12 Sep 2012 19:36:42 +0200 Subject: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell In-Reply-To: References: <50508B9F.8030005@gmail.com> <302E04D5-7A10-4F5F-8294-47C80AC0FF11@gmail.com> Message-ID: <20120912173640.GB14062@gmail.com> If such a possibility exists, I would be happy to fix the urxvt support :) Bear in mind, though, that the Cumino terminal is only needed for the Ghci session, so you can use your favourite terminal to run Vim :) A. > urxvt defaults to using a client-server model for all terminals, IIRC (we > have a warning about it in the xmonad documentation as well since it messes > up ManageHooks). There's possibly some option to disable this and force an > independent terminal. > > -- > brandon s allbery allbery.b at gmail.com > wandering unix systems administrator (available) (412) 475-9364 vm/sms From kdamodar2000 at gmail.com Wed Sep 12 20:21:08 2012 From: kdamodar2000 at gmail.com (damodar kulkarni) Date: Wed, 12 Sep 2012 23:51:08 +0530 Subject: [Haskell-cafe] Invitation to connect on LinkedIn In-Reply-To: <1663877330.956242.1347464551072.JavaMail.app@ela4-app2319.prod> References: <1663877330.956242.1347464551072.JavaMail.app@ela4-app2319.prod> Message-ID: Hi, Correct me if I am wrong, but by looking at the way the message is created, I think, LinkedIn is acting a kind of spammer these days. Shall we lodge protest against it as a community? As an aside, can we not automatically delete all messages to haskell mailing-lists whose "from" field contains "LinkedIn" (and the likes of it) in it? -Damodar On Wed, Sep 12, 2012 at 9:12 PM, Sakari Joinen via LinkedIn < member at linkedin.com> wrote: > > [image: LinkedIn Logo] > > > > Steve, > > Sakari Joinen wants to connect with you on LinkedIn. > > Sakari Joinen > Senior QA Engineer at Rocketpack View Profile ? > > Accept > > > > You are receiving Invitation emails. Unsubscribe. > > > This email was intended for Steve Severance (Principal at Alpha Heavy > Industries). Learn why we included this. > ? 2012, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, > USA > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From krismicinski at gmail.com Wed Sep 12 20:34:48 2012 From: krismicinski at gmail.com (Kristopher Micinski) Date: Wed, 12 Sep 2012 14:34:48 -0400 Subject: [Haskell-cafe] Invitation to connect on LinkedIn In-Reply-To: References: <1663877330.956242.1347464551072.JavaMail.app@ela4-app2319.prod> Message-ID: I believe these are the effect of linkedin harvesting your email contacts, and then a blanket "invite all" link that you can click. Whether it's linkedin who's spamming, or the person who forgot to uncheck certain mailing lists, that's more of a moral debate.. kris On Wed, Sep 12, 2012 at 2:21 PM, damodar kulkarni wrote: > Hi, > Correct me if I am wrong, but by looking at the way the message is > created, I think, LinkedIn is acting a kind of spammer these days. Shall we > lodge protest against it as a community? > As an aside, can we not automatically delete all messages to haskell > mailing-lists whose "from" field contains "LinkedIn" (and the likes of it) > in it? > > -Damodar > > On Wed, Sep 12, 2012 at 9:12 PM, Sakari Joinen via LinkedIn < > member at linkedin.com> wrote: > >> >> [image: LinkedIn Logo] >> >> >> >> Steve, >> >> Sakari Joinen wants to connect with you on LinkedIn. >> >> Sakari Joinen >> Senior QA Engineer at Rocketpack View Profile ? >> >> Accept >> >> >> >> You are receiving Invitation emails. Unsubscribe. >> >> >> This email was intended for Steve Severance (Principal at Alpha Heavy >> Industries). Learn why we included this. >> ? 2012, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, >> USA >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alfredo.dinapoli at gmail.com Wed Sep 12 20:48:05 2012 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Wed, 12 Sep 2012 20:48:05 +0200 Subject: [Haskell-cafe] Help a young graduate haskeller to land its dream job In-Reply-To: References: Message-ID: <20120912184802.GC14062@gmail.com> Hi everyone, If this mail sound strange to you, you are free to ignore it. My name is Alfredo Di Napoli and I'm a 24-year-old programmer from Rome, Italy. I've graduated in May and I'm currently working as an intern for a company involved in the defence field. In my spare time, though, I study functional programming, especially Haskell. FP is my true passion and I'm another dreamer trying to land the job he loves. In a nutshell I'm looking for every possibility to do Haskell/functional programming in Europe/North Europe. I'm throwing this stone into this pond because life has endless possibilities, who knows? :) A disclaimer, though: I'm not an expert Haskeller, but I'm very passionate about technology and I love learning (I've obviously already read LYAH and RWH). You can find more information about me (including my CV if interested) here: www.alfredodinapoli.com Oh! One last thing! I would be very grateful to everyone willing to spent two minutes of his time giving me any kind of suggestion about the FP job world or how to prepare/improve myself for the foreseeable future. Thanks again, and sorry for the OT/spammish plug. Humbly, Alfredo Di Napoli From allbery.b at gmail.com Wed Sep 12 20:49:20 2012 From: allbery.b at gmail.com (Brandon Allbery) Date: Wed, 12 Sep 2012 14:49:20 -0400 Subject: [Haskell-cafe] Invitation to connect on LinkedIn In-Reply-To: References: <1663877330.956242.1347464551072.JavaMail.app@ela4-app2319.prod> Message-ID: On Wed, Sep 12, 2012 at 2:21 PM, damodar kulkarni wrote: > Correct me if I am wrong, but by looking at the way the message is > created, I think, LinkedIn is acting a kind of spammer these days. Shall we > lodge protest against it as a community? > What happens is that anyone who joins is pushed to run their contact list through them "to look for connections", then LinkedIn sends an invitation to any address not already noted as a member. So it's spammy but in an especially slimy user-initiated way. -- brandon s allbery allbery.b at gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms -------------- next part -------------- An HTML attachment was scrubbed... URL: From stayvoid at gmail.com Wed Sep 12 20:53:39 2012 From: stayvoid at gmail.com (Stayvoid) Date: Wed, 12 Sep 2012 22:53:39 +0400 Subject: [Haskell-cafe] [Hackage] Bug report and proposal Message-ID: Hello, I found a bug: "source" points to the wrong page. [1] I know that bugs should be reported via Github. But I don't have an account and don't want to create one. There might be others who don't want to use Github. Why rely on external bug tracker? I assume that it has been chosen because of its features, but it doesn't have the most important one (i.e. anonymous posting). What's better: to have more features or to have less bugs? Is it possible to move away from Github? What about a separate mailing list for bugs? I'm sorry if this sounds to harsh; I'm not good at writing. I don't want to attack or blame anyone. I'm also sorry if this message is not appropriate, but I haven't found a better place. [1] http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:seq Cheers From allbery.b at gmail.com Wed Sep 12 21:05:39 2012 From: allbery.b at gmail.com (Brandon Allbery) Date: Wed, 12 Sep 2012 15:05:39 -0400 Subject: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell In-Reply-To: <20120912173640.GB14062@gmail.com> References: <50508B9F.8030005@gmail.com> <302E04D5-7A10-4F5F-8294-47C80AC0FF11@gmail.com> <20120912173640.GB14062@gmail.com> Message-ID: On Wed, Sep 12, 2012 at 1:36 PM, Alfredo Di Napoli < alfredo.dinapoli at gmail.com> wrote: > If such a possibility exists, > I would be happy to fix the urxvt support :) > Actually I went back through it and it should only be an issue if urxvtc is used; urxvt "should" always be standalone. Unless they went and made it too smart for its own good, in which case there might be some option to make it behave the old way. See http://www.haskell.org/haskellwiki/Xmonad/General_xmonad.hs_config_tips#Terminal_emulator_factoriesfor details. (I am assuming the problem is urxvt recognizes itself and uses the terminal factory to rub off a new window in the same process, which can't be given separate configuration information and can't be communicated with via xterm-style raw pty mode etc.) -- brandon s allbery allbery.b at gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms -------------- next part -------------- An HTML attachment was scrubbed... URL: From ekirpichov at gmail.com Wed Sep 12 21:13:11 2012 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Wed, 12 Sep 2012 12:13:11 -0700 Subject: [Haskell-cafe] Help a young graduate haskeller to land its dream job In-Reply-To: <20120912184802.GC14062@gmail.com> References: <20120912184802.GC14062@gmail.com> Message-ID: Hi Alfredo, You might look at the various bigdata companies. I was surprised by how many of them are using Scala or Clojure - it's definitely over 50%. Looks like FP is really gaining traction in this area. On Wed, Sep 12, 2012 at 11:48 AM, Alfredo Di Napoli wrote: > Hi everyone, > > If this mail sound strange to you, you are free to ignore it. > > My name is Alfredo Di Napoli and I'm a 24-year-old programmer from > Rome, Italy. I've graduated in May and I'm currently working as an intern > for a company involved in the defence field. > > In my spare time, though, I study functional programming, especially > Haskell. FP is my true passion and I'm another dreamer trying to land the > job he loves. > > In a nutshell I'm looking for every possibility to do Haskell/functional > programming in Europe/North Europe. I'm throwing this stone into this pond > because life has endless possibilities, who knows? :) > > A disclaimer, though: I'm not an expert Haskeller, but I'm very passionate > about technology and I love learning (I've obviously already read LYAH and > RWH). You can find more information about me (including my CV if interested) > here: > > www.alfredodinapoli.com > > Oh! One last thing! I would be very grateful to everyone willing to spent > two minutes of his time giving me any kind of suggestion about the FP job > world or how to prepare/improve myself for the foreseeable future. > > Thanks again, > and sorry for the OT/spammish plug. > > Humbly, > Alfredo Di Napoli > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Eugene Kirpichov http://www.linkedin.com/in/eugenekirpichov We're hiring! http://tinyurl.com/mirantis-openstack-engineer From byorgey at seas.upenn.edu Wed Sep 12 21:27:31 2012 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Wed, 12 Sep 2012 21:27:31 +0200 Subject: [Haskell-cafe] guards in applicative style In-Reply-To: References: Message-ID: <20120912192731.GA12999@seas.upenn.edu> Lorenzo is correct, but actually for the wrong reason. =) The *type* of guard is a historical accident, and the fact that it requires MonadPlus doesn't really tell us anything. Let's take a look at its implementation: guard :: (MonadPlus m) => Bool -> m () guard True = return () guard False = mzero 'return' is not specific to Monad; we could just as well use 'pure'. 'mzero' is a method of 'MonadPlus' but there is no reason we can't use 'empty' from the 'Alternative' class. So we could define guardA :: Alternative f => Bool -> f () guardA True = pure () guardA False = empty (As another example, consider the function 'sequence :: Monad m => [m a] -> m [a]'. Actually this function does not need Monad at all, it only needs Applicative.) However, guardA is not as useful as guard, and it is not possible to do the equivalent of the example shown using a list comprehension with a guard. The reason is that whereas monadic computations can make use of intermediate computed values to decide what to do next, Applicative computations cannot. So there is no way to generate values for x and y and then pass them to 'guardA' to do the filtering. guardA can only be used to conditionally abort an Applicative computation using information *external* to the Applicative computation; it cannot express a condition on the intermediate values computed by the Applicative computation itself. -Brent On Wed, Sep 12, 2012 at 03:52:03PM +0100, Lorenzo Bolla wrote: > I'm no expert at all, but I would say "no". > "guard" type is: > guard :: MonadPlus m => Bool -> m () > > and "MonadPlus" is a monad "plus" (ehm...) mzero and mplus > (http://en.wikibooks.org/wiki/Haskell/MonadPlus). > On the other hand Applicative is "less" than a monad > (http://www.haskell.org/haskellwiki/Applicative_functor), therefore > "guard" as is cannot be defined. > > But, in your specific example, with lists, you can always use "filter": > filter (uncurry somePredicate) ((,) <$> list1 <*> list2 (somePredicate ???)) > > hth, > L. > > > On Wed, Sep 12, 2012 at 3:40 PM, felipe zapata wrote: > > > > Hi Haskellers, > > > > Suppose I have two list and I want to calculate > > the cartesian product between the two of them, > > constrained to a predicate. > > In List comprehension notation is just > > > > result = [ (x, y) | x <- list1, y <-list2, somePredicate x y ] > > > > or in monadic notation > > > > result = do > > x <- list1 > > y <- list2 > > guard (somePredicate x y) > > return $ (x,y) > > > > Then I was wondering if we can do something similar using an applicative style > > > > result = (,) <$> list1 <*> list2 (somePredicate ???) > > > > The question is then, > > there is a way for defining a guard in applicative Style? > > > > Thanks in advance, > > > > Felipe Zapata. > > > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From sseverance at alphaheavy.com Wed Sep 12 21:31:30 2012 From: sseverance at alphaheavy.com (Steve Severance) Date: Wed, 12 Sep 2012 12:31:30 -0700 Subject: [Haskell-cafe] Invitation to connect on LinkedIn In-Reply-To: References: <1663877330.956242.1347464551072.JavaMail.app@ela4-app2319.prod> Message-ID: My heart skipped a beat when I saw myself on here. Then I saw I was the target. For the record I am morally opposed to inbox harvesting, although LinkedIn keeps "recommending" that I do just that. Steve On Wed, Sep 12, 2012 at 11:49 AM, Brandon Allbery wrote: > On Wed, Sep 12, 2012 at 2:21 PM, damodar kulkarni wrote: > >> Correct me if I am wrong, but by looking at the way the message is >> created, I think, LinkedIn is acting a kind of spammer these days. Shall we >> lodge protest against it as a community? >> > > What happens is that anyone who joins is pushed to run their contact list > through them "to look for connections", then LinkedIn sends an invitation > to any address not already noted as a member. So it's spammy but in an > especially slimy user-initiated way. > > -- > brandon s allbery allbery.b at gmail.com > wandering unix systems administrator (available) (412) 475-9364 vm/sms > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roma at ro-che.info Wed Sep 12 23:43:23 2012 From: roma at ro-che.info (Roman Cheplyaka) Date: Wed, 12 Sep 2012 23:43:23 +0200 Subject: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell In-Reply-To: <76952E9E-EB66-4A80-8B9B-6652CC86BD38@gmail.com> References: <76952E9E-EB66-4A80-8B9B-6652CC86BD38@gmail.com> Message-ID: Ah, okay. I was just confused by the fact that it uses tmux, and thought that I was misusing it. Yes, I also usually keep ghci in a separate window (and I am an xmonad user, too). I just thought that this offers a different experience and wanted to try it out. Anyway, thanks for clarifying. On Wed, Sep 12, 2012 at 5:24 PM, Alfredo Di Napoli < alfredo.dinapoli at gmail.com> wrote: > Hi Roman, > > Cumino was thought to operate in another terminal. Personally, but this is > only a personal taste, having to switch between terminal tabs or tmux panes > is not the fastest workflow. Being an Xmonad user, i can easily swap > between terminals (read ghci and vim) simply with mod + j or mod + k. > So the answer to your answer is: You can't, Cumino will always start in > another terminal window. Is the same behaviour of Slime, though. > > Sent from my iPad > > On 12/set/2012, at 17:06, Roman Cheplyaka wrote: > > So, suppose that I'm in a terminal vim session, and I want to start ghci > (in the current terminal). What do I do? > > cc starts a new terminal, which is not what I want. > > On Wed, Sep 12, 2012 at 3:03 PM, Alfredo Di Napoli < > alfredo.dinapoli at gmail.com> wrote: > >> Hi everyone, >> >> in case you have missed it, I've released a Vim plugin called Cumino: >> >> http://adinapoli.github.com/cumino/ >> >> It does one simple thing: It allows communication between Vim and tmux, >> in particular to a ghci session. With Cumino you can fire-up Vim, >> load a ghci session and interact with it with only few keystrokes. The >> plugin also supports visual selection: you can select for example a >> function (even with all its signature!) >> and you can send it to ghci. The visual selection supports imports, >> custom types and typeclasses. >> >> It's a simple idea but so damn useful, imho. >> >> This release also adds the possibility to prettify the code using the >> excellent stylish-haskell: select a snippet, simply indent in the usual way >> ( = ) and voil?, now >> your code is indented! >> >> Feedback are highly appreciated, as well as contributions. >> There are still some issues with some terminals (for example urxvt does >> not work right now) but the plugin has been tested against gnome-terminal, >> xterm and mlterm. >> >> I'll post in reddit too for completeness! >> >> Bye! >> Alfredo >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivan.miljenovic at gmail.com Thu Sep 13 01:40:24 2012 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Thu, 13 Sep 2012 09:40:24 +1000 Subject: [Haskell-cafe] [Hackage] Bug report and proposal In-Reply-To: References: Message-ID: On 13 September 2012 04:53, Stayvoid wrote: > Hello, > > I found a bug: "source" points to the wrong page. [1] > > I know that bugs should be reported via Github. But I don't have an > account and don't want to create one. There might be others who don't > want to use Github. Why rely on external bug tracker? I assume that it > has been chosen because of its features, but it doesn't have the most > important one (i.e. anonymous posting). What's better: to have more > features or to have less bugs? > > Is it possible to move away from Github? > What about a separate mailing list for bugs? Whilst in general I agree with you, people have complained previously about needing to subscribe to libraries at haskell.org for bug reports for boot libraries, or for needing to get a Trac login, etc. If, however, _no_ login is required, then the system is open to spamming :s > > I'm sorry if this sounds to harsh; I'm not good at writing. I don't > want to attack or blame anyone. I'm also sorry if this message is not > appropriate, but I haven't found a better place. > > [1] http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:seq > > Cheers > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From es at ertes.de Thu Sep 13 02:03:49 2012 From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=) Date: Thu, 13 Sep 2012 02:03:49 +0200 Subject: [Haskell-cafe] guards in applicative style References: <20120912192731.GA12999@seas.upenn.edu> Message-ID: <20120913020349.454c4019@tritium.streitmacht.eu> Brent Yorgey wrote: > However, guardA is not as useful as guard, and it is not possible to > do the equivalent of the example shown using a list comprehension with > a guard. The reason is that whereas monadic computations can make use > of intermediate computed values to decide what to do next, Applicative > computations cannot. So there is no way to generate values for x and > y and then pass them to 'guardA' to do the filtering. guardA can only > be used to conditionally abort an Applicative computation using > information *external* to the Applicative computation; it cannot > express a condition on the intermediate values computed by the > Applicative computation itself. To continue this story, from most applicative functors you can construct a category, which is interesting for non-monads. Let's examine the SparseStream functor, which is not a monad: data SparseStream a = SparseStream { headS :: Maybe a, tailS :: SparseStream a } This is an applicative functor, instance Applicative SparseStream where pure x = let str = SparseStream (Just x) str in str SparseStream f fs <*> SparseStream x xs = SparseStream (f <*> x) (fs <*> xs) but with a little extension it becomes a category, the wire category: newtype Wire a b = Wire (a -> (Maybe b, Wire a b)) This is like SparseStream, but for each head/tail pair it wants an argument. Given a Category instance you can now actually make use of guardA without resorting to monadic combinators: guardA p . myStream This is conceptually how Netwire's applicative FRP works and how events are implemented. Greets, Ertugrul -- Not to be or to be and (not to be or to be and (not to be or to be and (not to be or to be and ... that is the list monad. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: not available URL: From i at maskray.tk Thu Sep 13 04:42:26 2012 From: i at maskray.tk (Ray) Date: Thu, 13 Sep 2012 10:42:26 +0800 Subject: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell In-Reply-To: References: Message-ID: <20120913024226.GA1724@lap.tuna.tsinghua.edu.cn> On Wed, Sep 12, 2012 at 01:03:49PM +0000, Alfredo Di Napoli wrote: > Hi everyone, > > in case you have missed it, I've released a Vim plugin called Cumino: > > http://adinapoli.github.com/cumino/ > > It does one simple thing: It allows communication between Vim and tmux, in > particular to a ghci session. With Cumino you can fire-up Vim, > load a ghci session and interact with it with only few keystrokes. The plugin > also supports visual selection: you can select for example a function (even > with all its signature!) > and you can send it to ghci. The visual selection supports imports, custom > types and typeclasses. > > It's a simple idea but so damn useful, imho. > > This release also adds the possibility to prettify the code using the excellent > stylish-haskell: select a snippet, simply indent in the usual way ( = ) and > voil?, now > your code is indented! > > Feedback are highly appreciated, as well as contributions. > There are still some issues with some terminals (for example urxvt does not > work right now) but the plugin has been tested against gnome-terminal, xterm > and mlterm. > > I'll post in reddit too for completeness! Nice bridge between vim and tmux! Would you mind add supporting for `urxvtc'? urxvtc's -e option is followed by a list of options instead of a string. urxvtc -e sh -c 'echo a' xterm -e echo a From alfredo.dinapoli at gmail.com Thu Sep 13 08:14:56 2012 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Thu, 13 Sep 2012 06:14:56 +0000 Subject: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell In-Reply-To: References: <76952E9E-EB66-4A80-8B9B-6652CC86BD38@gmail.com> Message-ID: You're welcome :) Using Cumino your workflow should be faster and leaner. I encourage to try it out and let me have feedback! Cheers, A. On 12 September 2012 21:43, Roman Cheplyaka wrote: > Ah, okay. I was just confused by the fact that it uses tmux, and thought > that I was misusing it. > > Yes, I also usually keep ghci in a separate window (and I am an xmonad > user, too). I just thought that this offers a different experience and > wanted to try it out. > > Anyway, thanks for clarifying. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alfredo.dinapoli at gmail.com Thu Sep 13 08:22:43 2012 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Thu, 13 Sep 2012 06:22:43 +0000 Subject: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell In-Reply-To: <20120913024226.GA1724@lap.tuna.tsinghua.edu.cn> References: <20120913024226.GA1724@lap.tuna.tsinghua.edu.cn> Message-ID: > > Nice bridge between vim and tmux! Thanks! > Would you mind add supporting for `urxvtc'? > urxvtc's -e option is followed by a list of options instead of a string. > > urxvtc -e sh -c 'echo a' > xterm -e echo a > I would like to, and in fact I've already tried, but urxvt is trickier than other shells. Using the command you gave me does not create a new window, tested both on XMonad and Gnome. This is the error you can see using the option "-hold", this way: urxvt --hold -e "echo a" This opens a new window with the error: *urxvt: Unable to exec child. * Any idea? -------------- next part -------------- An HTML attachment was scrubbed... URL: From mystic.satvik at gmail.com Thu Sep 13 11:18:24 2012 From: mystic.satvik at gmail.com (satvik chauhan) Date: Thu, 13 Sep 2012 14:48:24 +0530 Subject: [Haskell-cafe] How Type inference work in presence of Functional Dependencies Message-ID: Consider the code below : {-# LANGUAGE MultiParamTypeClasses,FlexibleInstances,FunctionalDependencies,UndecidableInstances,FlexibleContexts #-} class Foo a c | a -> c instance Foo Int Float f :: (Foo Int a) => Int -> a f = undefined Now when I see the inferred type of f in ghci > :t f > f :: Int -> Float Now If I add the following code g :: Int -> Float g = undefined h :: (Foo Int a) => Int -> a h = g I get the error Could not deduce (a ~ Float) I am not able to understand what has happened here ? The restriction "Foo Int a" should have restricted the type of h to "Int -> Float" as shown in the inferred type of f. - Satvik -------------- next part -------------- An HTML attachment was scrubbed... URL: From hesselink at gmail.com Thu Sep 13 11:47:12 2012 From: hesselink at gmail.com (Erik Hesselink) Date: Thu, 13 Sep 2012 11:47:12 +0200 Subject: [Haskell-cafe] How Type inference work in presence of Functional Dependencies In-Reply-To: References: Message-ID: I don't know if this is a bug or not, but the translation to type families works: class Foo a where type FooT a :: * instance Foo Int where type FooT Int = Float f :: Int -> FooT Int f = undefined g :: Int -> Float g = undefined h :: Int -> FooT Int h = g You don't even need the class contexts. Erik On Thu, Sep 13, 2012 at 11:18 AM, satvik chauhan wrote: > Consider the code below : > > {-# LANGUAGE > MultiParamTypeClasses,FlexibleInstances,FunctionalDependencies,UndecidableInstances,FlexibleContexts > #-} > class Foo a c | a -> c > instance Foo Int Float > f :: (Foo Int a) => Int -> a > f = undefined > > Now when I see the inferred type of f in ghci > >> :t f > >> f :: Int -> Float > > Now If I add the following code > > g :: Int -> Float > g = undefined > > h :: (Foo Int a) => Int -> a > h = g > > > I get the error > > Could not deduce (a ~ Float) > > > I am not able to understand what has happened here ? The restriction "Foo > Int a" should have restricted the type of h to "Int -> Float" as shown in > the inferred type of f. > > > - Satvik > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dan.doel at gmail.com Thu Sep 13 16:44:17 2012 From: dan.doel at gmail.com (Dan Doel) Date: Thu, 13 Sep 2012 10:44:17 -0400 Subject: [Haskell-cafe] Fwd: How Type inference work in presence of Functional Dependencies In-Reply-To: References: Message-ID: Copying the mailing list, because I forgot. On Thu, Sep 13, 2012 at 5:18 AM, satvik chauhan wrote: > Consider the code below : > > {-# LANGUAGE > MultiParamTypeClasses,FlexibleInstances,FunctionalDependencies,UndecidableInstances,FlexibleContexts > #-} > class Foo a c | a -> c > instance Foo Int Float > f :: (Foo Int a) => Int -> a > f = undefined > > Now when I see the inferred type of f in ghci > >> :t f > >> f :: Int -> Float > > Now If I add the following code > > g :: Int -> Float > g = undefined > > h :: (Foo Int a) => Int -> a > h = g > > > I get the error > > Could not deduce (a ~ Float) > > > I am not able to understand what has happened here ? The restriction "Foo > Int a" should have restricted the type of h to "Int -> Float" as shown in > the inferred type of f. The answer, I believe, is that the difference between the fundep implementation and type families is local constraint information. Fundeps do no local propagation. So in your first definition, you've locally provided 'Int -> a', which is acceptable to GHC. Then it figures out externally to the function that '(Foo Int a) => Int -> a' is actually Int -> Float. In the second definition, you're trying to give 'Int -> Float', but GHC only knows locally that you need to provide 'Int -> a' with a constraint 'Foo Int a' which it _won't_ use to determine that a ~ Float. This is not inherent to fundeps. One could make a version of fundeps that has the local constraint rules (easily so by translating to the new type families stuff). But, the difference is also the reason that overlapping instances are supported for fundeps and not type families. But I won't get into that right now. -- Dan From allbery.b at gmail.com Thu Sep 13 17:20:51 2012 From: allbery.b at gmail.com (Brandon Allbery) Date: Thu, 13 Sep 2012 11:20:51 -0400 Subject: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell In-Reply-To: References: <20120913024226.GA1724@lap.tuna.tsinghua.edu.cn> Message-ID: On Thu, Sep 13, 2012 at 2:22 AM, Alfredo Di Napoli < alfredo.dinapoli at gmail.com> wrote: > urxvtc -e sh -c 'echo a' >> xterm -e echo a >> > > I would like to, and in fact I've already tried, but urxvt is trickier > than other shells. Using the command you gave me does not create a new > window, tested both on XMonad and Gnome. This is > the error you can see using the option "-hold", this way: > > urxvt --hold -e "echo a" > > This opens a new window with the error: *urxvt: Unable to exec child. > * > I think you misunderstood; as I read it (and as I would expect it to work given the above descrtiption) that would be urxvt --hold -e sh -c 'echo a' -- brandon s allbery allbery.b at gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms -------------- next part -------------- An HTML attachment was scrubbed... URL: From alfredo.dinapoli at gmail.com Thu Sep 13 18:16:06 2012 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Thu, 13 Sep 2012 18:16:06 +0200 Subject: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell In-Reply-To: References: <20120913024226.GA1724@lap.tuna.tsinghua.edu.cn> Message-ID: <20120913161604.GA31344@gmail.com> If I remember correctly, I've also tried that combinations, without success. Anyway, I'm not at work so I can't test Cumino against gnome and Xmonad until tomorrow morning: I'll keep you posted! Bye, Alfredo > > I think you misunderstood; as I read it (and as I would expect it to work > given the above descrtiption) that would be > > urxvt --hold -e sh -c 'echo a' > > -- > brandon s allbery allbery.b at gmail.com > wandering unix systems administrator (available) (412) 475-9364 vm/sms From lykahb at gmail.com Thu Sep 13 20:23:09 2012 From: lykahb at gmail.com (Boris Lykah) Date: Thu, 13 Sep 2012 21:23:09 +0300 Subject: [Haskell-cafe] ANNOUNCE: Groundhog 0.1.0.1 - high-level database library Message-ID: I am happy to announce a new version of Groundhog, a library for fast high-level database access: http://hackage.haskell.org/package/groundhog http://hackage.haskell.org/package/groundhog-th http://hackage.haskell.org/package/groundhog-postgresql http://hackage.haskell.org/package/groundhog-sqlite Groundhog has been completely overhauled since the last release. Notably, it got support for PostgreSQL and natural foreign keys. I believe that it is a big step forward as this brings more flexibility to the design of the relational schemas while keeping the applications independent of the storage layer. Some of the solutions, particularly schema migration were based on Persistent code. Please see examples at http://github.com/lykahb/groundhog/tree/master/examples. Features: * Support for Sqlite and PostgreSQL. * Natural and composite foreign keys. Earlier it was possible to reference an entity only by the mandatory integer primary key. Now an entity can have several keys including autoincrement primary key (optional) and unique keys which have one or more columns. * Full support of embedded datatypes. You can access a field that contains an embedded datatype as a whole, or access some of the inner subfields individually. This powerful mechanism has allowed implementation of the composite keys, and can be used in future to work with PostgreSQL composite types or MongoDB embedded documents. Instead of serializing value to string, the Groundhog backends flatten tree of embedded datatypes to db columns. * Projections. You can choose what columns to query from a table in a type-safe manner. * Initialization and migration of database schema. * Sum types and polymorphic types. * Expression DSL for use in queries. * Basic list support. * YAML-based settings mechanism. It separates datatype definition and description which facilitates modularity. The settings are inferred from the analysis of the difinition, and overridden with values set by user. The Criterion benchmarks are available at http://lykahb.github.com/groundhog/SqliteBench.html and http://lykahb.github.com/groundhog/PostgreSQLBench.html. Future plans: * Support for joins * Database indexes * Investigate options for implementing MongoDB and MySQL backends Your feedback, suggestions for improvement and criticism are welcome. -- Regards, Boris From amindfv at gmail.com Fri Sep 14 00:28:34 2012 From: amindfv at gmail.com (Tom Murphy) Date: Thu, 13 Sep 2012 18:28:34 -0400 Subject: [Haskell-cafe] ANNOUNCE: Groundhog 0.1.0.1 - high-level database library In-Reply-To: References: Message-ID: How does this compare with other high-level Haskell db libraries? Tom On Sep 13, 2012 2:25 PM, "Boris Lykah" wrote: > I am happy to announce a new version of Groundhog, a library for fast > high-level database access: > http://hackage.haskell.org/package/groundhog > http://hackage.haskell.org/package/groundhog-th > http://hackage.haskell.org/package/groundhog-postgresql > http://hackage.haskell.org/package/groundhog-sqlite > > Groundhog has been completely overhauled since the last release. > Notably, it got support for PostgreSQL and natural foreign keys. I > believe that it is a big step forward as this brings more flexibility > to the design of the relational schemas while keeping the applications > independent of the storage layer. Some of the solutions, particularly > schema migration were based on Persistent code. > > Please see examples at > http://github.com/lykahb/groundhog/tree/master/examples. > > Features: > * Support for Sqlite and PostgreSQL. > * Natural and composite foreign keys. Earlier it was possible to > reference an entity only by the mandatory integer primary key. Now an > entity can have several keys including autoincrement primary key > (optional) and unique keys which have one or more columns. > * Full support of embedded datatypes. You can access a field that > contains an embedded datatype as a whole, or access some of the inner > subfields individually. This powerful mechanism has allowed > implementation of the composite keys, and can be used in future to > work with PostgreSQL composite types or MongoDB embedded documents. > Instead of serializing value to string, the Groundhog backends flatten > tree of embedded datatypes to db columns. > * Projections. You can choose what columns to query from a table in a > type-safe manner. > * Initialization and migration of database schema. > * Sum types and polymorphic types. > * Expression DSL for use in queries. > * Basic list support. > * YAML-based settings mechanism. It separates datatype definition and > description which facilitates modularity. The settings are inferred > from the analysis of the difinition, and overridden with values set by > user. > > The Criterion benchmarks are available at > http://lykahb.github.com/groundhog/SqliteBench.html and > http://lykahb.github.com/groundhog/PostgreSQLBench.html. > > Future plans: > * Support for joins > * Database indexes > * Investigate options for implementing MongoDB and MySQL backends > > Your feedback, suggestions for improvement and criticism are welcome. > > -- > Regards, > Boris > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wren at freegeek.org Fri Sep 14 01:29:32 2012 From: wren at freegeek.org (wren ng thornton) Date: Fri, 14 Sep 2012 01:29:32 +0200 Subject: [Haskell-cafe] Either Monad and Laziness In-Reply-To: <87vcfjxnfk.wl%f@mazzo.li> References: <20120912060330.83793.qmail@www1.g3.pair.com> <87vcfjxnfk.wl%f@mazzo.li> Message-ID: <50526C5C.40506@freegeek.org> On 9/12/12 5:37 PM, Francesco Mazzoli wrote: > At Wed, 12 Sep 2012 12:04:31 -0300, > Eric Velten de Melo wrote: >> It would be really awesome, though, if it were possible to use a >> parser written in Parsec with this, in the spirit of avoiding code >> rewriting and enhancing expressivity and abstraction. > > There is and > , which turn > attoparsec parsers into enumerators/conduits, and > , which is a compatibility > layer between attoaparsec and parsec. Good luck :). Not to mention attoparsec-iteratee, for the iteratee minded folks: http://hackage.haskell.org/package/attoparsec-iteratee -- Live well, ~wren From andrew.pennebaker at gmail.com Fri Sep 14 02:04:49 2012 From: andrew.pennebaker at gmail.com (Andrew Pennebaker) Date: Thu, 13 Sep 2012 20:04:49 -0400 Subject: [Haskell-cafe] How do I generate random numbers using random-fu, with platform-agnostic code? Message-ID: I can't figure out how to use Data.Random.Source.IO to generate random numbers in a multiplatform way. I can generate random numbers in Unix using Data.Random.Source.DevRandom, and there is an example in the GitHub documentation for Windows using Data.Random.Source.MWC, but there is no example code for using Data.Random.Source.IO. Cheers, Andrew Pennebaker www.yellosoft.us -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckkashyap at gmail.com Fri Sep 14 07:03:40 2012 From: ckkashyap at gmail.com (C K Kashyap) Date: Fri, 14 Sep 2012 10:33:40 +0530 Subject: [Haskell-cafe] Is Hackage down? Message-ID: Is it just me or is Hackage indeed been going down more frequently of late? Regards, Kashyap -------------- next part -------------- An HTML attachment was scrubbed... URL: From kdamodar2000 at gmail.com Fri Sep 14 07:08:55 2012 From: kdamodar2000 at gmail.com (damodar kulkarni) Date: Fri, 14 Sep 2012 10:38:55 +0530 Subject: [Haskell-cafe] Is Hackage down? In-Reply-To: References: Message-ID: It shows hackage down: http://www.downforeveryoneorjustme.com/http://hackage.haskell.org/ - damodar On Fri, Sep 14, 2012 at 10:33 AM, C K Kashyap wrote: > Is it just me or is Hackage indeed been going down more frequently of late? > > Regards, > Kashyap > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From magicloud.magiclouds at gmail.com Fri Sep 14 07:29:52 2012 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Fri, 14 Sep 2012 13:29:52 +0800 Subject: [Haskell-cafe] What is the good way to work with list comprehension and UTCTime? Message-ID: Hi, Simple usage, I could make an instance of Enum to UTCTime, so [utcTime..] could work. But that is so stiff. How if sometimes I want to step by 1 min, sometimes I want to step by 1 sec? So I think some way like [ t | addUTCTime last 60 ] could be nice. But I cannot figure it out.... Any idea? -- ??????? ??????? And for G+, please use magiclouds#gmail.com. From ktvoelker at gmail.com Fri Sep 14 08:04:51 2012 From: ktvoelker at gmail.com (Karl Voelker) Date: Thu, 13 Sep 2012 23:04:51 -0700 Subject: [Haskell-cafe] What is the good way to work with list comprehension and UTCTime? In-Reply-To: References: Message-ID: On Thu, Sep 13, 2012 at 10:29 PM, Magicloud Magiclouds < magicloud.magiclouds at gmail.com> wrote: > Hi, > Simple usage, I could make an instance of Enum to UTCTime, so > [utcTime..] could work. But that is so stiff. How if sometimes I want > to step by 1 min, sometimes I want to step by 1 sec? > So I think some way like [ t | addUTCTime last 60 ] could be nice. > But I cannot figure it out.... > Any idea? > Try using Prelude.iterate. -Karl -------------- next part -------------- An HTML attachment was scrubbed... URL: From alfredo.dinapoli at gmail.com Fri Sep 14 08:14:11 2012 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Fri, 14 Sep 2012 06:14:11 +0000 Subject: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell In-Reply-To: <20120913161604.GA31344@gmail.com> References: <20120913024226.GA1724@lap.tuna.tsinghua.edu.cn> <20120913161604.GA31344@gmail.com> Message-ID: Ok, I've added the support for urxvt. Bear in mind that it partially support urxvt, though: it works fine if you run GVim or Vim outside an already running tmux session, otherwise it won't start. The problem is due to the fact urxvt believes that the new session is launched within the running tmux session, whining about nested tmux session and not starting at all. You can unset the $TERM variable as workaround, but I don't like that apporach. If you come up with an alternative solution please let me know :) A. On 13 September 2012 16:16, Alfredo Di Napoli wrote: > If I remember correctly, I've also tried that combinations, without > success. > > Anyway, I'm not at work so I can't test Cumino against gnome and Xmonad > until tomorrow morning: I'll keep you posted! > > Bye, > Alfredo > > > > > I think you misunderstood; as I read it (and as I would expect it to work > > given the above descrtiption) that would be > > > > urxvt --hold -e sh -c 'echo a' > > > > -- > > brandon s allbery > allbery.b at gmail.com > > wandering unix systems administrator (available) (412) 475-9364vm/sms > -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnw at newartisans.com Fri Sep 14 08:21:03 2012 From: johnw at newartisans.com (John Wiegley) Date: Fri, 14 Sep 2012 01:21:03 -0500 Subject: [Haskell-cafe] Is Hackage down? In-Reply-To: (C. K. Kashyap's message of "Fri, 14 Sep 2012 10:33:40 +0530") References: Message-ID: >>>>> C K Kashyap writes: > Is it just me or is Hackage indeed been going down more frequently of late? It's not just you. From alfredo.dinapoli at gmail.com Fri Sep 14 08:50:07 2012 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Fri, 14 Sep 2012 06:50:07 +0000 Subject: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell In-Reply-To: References: <20120913024226.GA1724@lap.tuna.tsinghua.edu.cn> <20120913161604.GA31344@gmail.com> Message-ID: Sorry the typo, the variable is $TMUX and controls the nesting ot tmux session. It turns out that if affect not only urxvt but also xterm and gnome-terminal. Perhaps it could be useful to unset it programmatically, I'll keep you posted if I find a workaround. A. On 14 September 2012 06:14, Alfredo Di Napoli wrote: > Ok, I've added the support for urxvt. > Bear in mind that it partially support urxvt, though: it works fine if you > run GVim or Vim outside an already running tmux session, otherwise it won't > start. > The problem is due to the fact urxvt believes that the new session is > launched within the running tmux session, whining about nested tmux session > and not starting at all. > You can unset the $TERM variable as workaround, but I don't like that > apporach. > If you come up with an alternative solution please let me know :) > A. > > > On 13 September 2012 16:16, Alfredo Di Napoli wrote: > >> If I remember correctly, I've also tried that combinations, without >> success. >> >> Anyway, I'm not at work so I can't test Cumino against gnome and Xmonad >> until tomorrow morning: I'll keep you posted! >> >> Bye, >> Alfredo >> >> > >> > I think you misunderstood; as I read it (and as I would expect it to >> work >> > given the above descrtiption) that would be >> > >> > urxvt --hold -e sh -c 'echo a' >> > >> > -- >> > brandon s allbery >> allbery.b at gmail.com >> > wandering unix systems administrator (available) (412) 475-9364vm/sms >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roma at ro-che.info Fri Sep 14 10:03:01 2012 From: roma at ro-che.info (Roman Cheplyaka) Date: Fri, 14 Sep 2012 10:03:01 +0200 Subject: [Haskell-cafe] What is the good way to work with list comprehension and UTCTime? In-Reply-To: References: Message-ID: Consider using the time-lens package. import Data.Time.Lens import Data.Lens.Common List comprehension style: [modL seconds (+ fromIntegral n) t | n <- [0..]] [modL minutes (+ n) t | n <- [0..]] (you need fromIntegral for seconds, because it is of fractional type in Data.Time). iterate style, as suggested by Karl: iterate (seconds ^+= 1) t iterate (minutes ^+= 1) t On Fri, Sep 14, 2012 at 7:29 AM, Magicloud Magiclouds < magicloud.magiclouds at gmail.com> wrote: > Hi, > Simple usage, I could make an instance of Enum to UTCTime, so > [utcTime..] could work. But that is so stiff. How if sometimes I want > to step by 1 min, sometimes I want to step by 1 sec? > So I think some way like [ t | addUTCTime last 60 ] could be nice. > But I cannot figure it out.... > Any idea? > -- > ??????? > ??????? > > And for G+, please use magiclouds#gmail.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From magicloud.magiclouds at gmail.com Fri Sep 14 10:25:58 2012 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Fri, 14 Sep 2012 16:25:58 +0800 Subject: [Haskell-cafe] What is the good way to work with list comprehension and UTCTime? In-Reply-To: References: Message-ID: This is nice. Thanks to all. On Fri, Sep 14, 2012 at 4:03 PM, Roman Cheplyaka wrote: > Consider using the time-lens package. > > import Data.Time.Lens > import Data.Lens.Common > > List comprehension style: > > [modL seconds (+ fromIntegral n) t | n <- [0..]] > [modL minutes (+ n) t | n <- [0..]] > > (you need fromIntegral for seconds, because it is of fractional type in > Data.Time). > > iterate style, as suggested by Karl: > > iterate (seconds ^+= 1) t > iterate (minutes ^+= 1) t > > On Fri, Sep 14, 2012 at 7:29 AM, Magicloud Magiclouds > wrote: >> >> Hi, >> Simple usage, I could make an instance of Enum to UTCTime, so >> [utcTime..] could work. But that is so stiff. How if sometimes I want >> to step by 1 min, sometimes I want to step by 1 sec? >> So I think some way like [ t | addUTCTime last 60 ] could be nice. >> But I cannot figure it out.... >> Any idea? >> -- >> ??????? >> ??????? >> >> And for G+, please use magiclouds#gmail.com. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- ??????? ??????? And for G+, please use magiclouds#gmail.com. From florian.lorenzen at tu-berlin.de Fri Sep 14 12:45:19 2012 From: florian.lorenzen at tu-berlin.de (Florian Lorenzen) Date: Fri, 14 Sep 2012 12:45:19 +0200 Subject: [Haskell-cafe] Transforming a ADT to a GADT Message-ID: <50530ABF.7060904@tu-berlin.de> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello cafe, I have a question wrt. to GADTs and type families in GHC (7.6.1). I'd like to transform a value of an ADT to a GADT. Suppose I have the simple expression language > data Exp = Lit Int > | Succ Exp > | IsZero Exp > | If Exp Exp Exp and the GADT > data Term t where > TLit :: Int -> Term Int > TSucc :: Term Int -> Term Int > TIsZero :: Term Int -> Term Bool > TIf :: Term Bool -> Term ty -> Term ty -> Term ty that encodes the typing rules. Now, I'd like to have a function > typecheck :: Exp -> Maybe (Term t) > typecheck exp = <...> that returns the GADT value corresponding to `exp' if `exp' is type correct. I found a solution at http://okmij.org/ftp/tagless-final/TypecheckedDSLTH.hs but this has as type (slightly adapted) > typecheck :: Exp -> Maybe TypedTerm with > data TypedTerm = forall ty. (Typ ty) (Term ty) > data Typ ty = > TInt Int | TBool Bool That is, the GADT value is hidden inside the existential and cannot be unpacked. Therefore, I cannot write a type preserving transformation function like > transform :: Term t -> Term t that gets the result of the `typecheck' function as input. The solution mentioned above uses Template Haskell to extract the `Term t' type from the existential package and argues that type errors cannot occur during splicing. Is there a possibility to avoid the existential and hence Template Haskell? Of course, the result type of typecheck depends on the type and type correctness of its input. My idea was to express this dependency by parameterizing `Exp' and using a type family `ExpType' like: > typecheck :: Exp e -> Maybe (Term (ExpType e)) > typecheck (ELit > i) = Just (TLit i) > typecheck (ESucc exp1) = case typecheck exp1 of > Nothing -> Nothing > Just t -> Just (TSucc t) > <...> with > data TEXP = L | S TEXP | IZ TEXP | I TEXP TEXP TEXP -- datakind > > > data Exp (e::TEXP) where > ELit :: Int -> Exp L > ESucc :: Exp e1 -> Exp (S e1) > EIsZero :: Exp e1 -> Exp (IZ e1) > EIf :: Exp e1 -> Exp e2 -> Exp e3 -> Exp (I e1 e2 e3) It seems to me that `ExpType' then would be a reification of the type checker for `Exp' at the type level. But I did not know how to define it. Does it make sense at all? Is it possible in GHC? All the examples on the net I looked at either start with the GADT right away or use Template Haskell at some point. So, perhaps this `typecheck' function is not possible to write in GHC Haskell. I very much appreciate any hints and explanations on this. Best regards, Florian - -- Florian Lorenzen Technische Universit?t Berlin Fakult?t IV - Elektrotechnik und Informatik ?bersetzerbau und Programmiersprachen Sekr. TEL12-2, Ernst-Reuter-Platz 7, D-10587 Berlin Tel.: +49 (30) 314-24618 E-Mail: florian.lorenzen at tu-berlin.de WWW: http://www.user.tu-berlin.de/florenz/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iEYEARECAAYFAlBTCr8ACgkQvjzICpVvX7ZfTgCeOPflPtaEW/w1McjYWheaRaqq oUQAnRXSrGP3se+3oiI3nnd+B/rK8yx8 =X1hR -----END PGP SIGNATURE----- From alfredo.dinapoli at gmail.com Fri Sep 14 13:48:50 2012 From: alfredo.dinapoli at gmail.com (Alfredo Di Napoli) Date: Fri, 14 Sep 2012 11:48:50 +0000 Subject: [Haskell-cafe] ANN: Cumino 0.3 - Now supports sandboxed environments (e.g, Hsenv ones) Message-ID: Hi Caf?, I'm glat to annouce the third major improvement of my VIm plugin Cumino: https://github.com/adinapoli/cumino This one is a juicy one. If you have a sandboxed environment enabled (e.g. one created with Hsenv) and you start vim from the same shell, Cumino will automatically uses at startup the right ghci instance. This means that if you have installed only some packages in your sandbox env, you will have them available inside ghci :) Feedback are welcome, as always. A. -------------- next part -------------- An HTML attachment was scrubbed... URL: From leather at cs.uu.nl Fri Sep 14 14:01:10 2012 From: leather at cs.uu.nl (Sean Leather) Date: Fri, 14 Sep 2012 14:01:10 +0200 Subject: [Haskell-cafe] Transforming a ADT to a GADT In-Reply-To: <50530ABF.7060904@tu-berlin.de> References: <50530ABF.7060904@tu-berlin.de> Message-ID: On Fri, Sep 14, 2012 at 12:45 PM, Florian Lorenzen wrote: > I'd like to transform a value of an ADT to a GADT. Suppose I have the > simple expression language > > > data Exp = Lit Int > | Succ Exp > | IsZero Exp > | If Exp Exp Exp > > and the GADT > > > data Term t where > TLit :: Int -> Term Int > TSucc :: Term Int -> > Term Int > TIsZero :: Term Int -> Term Bool > TIf :: Term Bool -> Term > ty -> Term ty -> Term ty > > that encodes the typing rules. > > Now, I'd like to have a function > > > typecheck :: Exp -> Maybe (Term t) > typecheck exp = <...> > > that returns the GADT value corresponding to `exp' if `exp' is type > correct. > It's not pretty, but it should still be safe... import Control.Applicative import Unsafe.Coerce tcInt :: Exp -> Maybe (Term Int) tcInt (Lit i) = pure (TLit i) tcInt (Succ e) = TSucc <$> tcInt e tcInt (If c e1 e2) = TIf <$> tcBool c <*> tcInt e1 <*> tcInt e2 tcInt _ = empty tcBool :: Exp -> Maybe (Term Bool) tcBool (IsZero e) = TIsZero <$> tcInt e tcBool (If c e1 e2) = TIf <$> tcBool c <*> tcBool e1 <*> tcBool e2 tcBool _ = empty typecheck :: Exp -> Maybe (Term t) typecheck e = forget <$> tcInt e <|> forget <$> tcBool e where forget :: Term a -> Term b forget = unsafeCoerce Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: From florian.lorenzen at tu-berlin.de Fri Sep 14 14:13:17 2012 From: florian.lorenzen at tu-berlin.de (Florian Lorenzen) Date: Fri, 14 Sep 2012 14:13:17 +0200 Subject: [Haskell-cafe] Transforming a ADT to a GADT In-Reply-To: References: <50530ABF.7060904@tu-berlin.de> Message-ID: <50531F5D.4090000@tu-berlin.de> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dear Sean, thanks for your solution. It in the documentation of unsafeCoerce it says: "It [unsafeCoerce] is generally used when you want to write a program that you know is well-typed, but where Haskell's type system is not expressive enough to prove that it is well typed." May I conclude that the (GHC) Haskell type system is not powerful enough to type such a typecheck function? Best regards, Florian On 09/14/2012 02:01 PM, Sean Leather wrote: > On Fri, Sep 14, 2012 at 12:45 PM, Florian Lorenzen wrote: > > I'd like to transform a value of an ADT to a GADT. Suppose I have > the simple expression language > >> data Exp = Lit Int > | Succ Exp > | IsZero Exp > | If Exp Exp >> Exp > > and the GADT > >> data Term t where > TLit :: Int -> Term Int > TSucc :: Term Int >> -> > Term Int > TIsZero :: Term Int -> Term Bool > TIf :: Term Bool -> > Term ty -> Term ty -> Term ty > > that encodes the typing rules. > > Now, I'd like to have a function > >> typecheck :: Exp -> Maybe (Term t) > typecheck exp = <...> > > that returns the GADT value corresponding to `exp' if `exp' is > type correct. > > > It's not pretty, but it should still be safe... > > import Control.Applicative import Unsafe.Coerce > > tcInt :: Exp -> Maybe (Term Int) tcInt (Lit i) = pure (TLit > i) tcInt (Succ e) = TSucc <$> tcInt e tcInt (If c e1 e2) = > TIf <$> tcBool c <*> tcInt e1 <*> tcInt e2 tcInt _ = > empty > > tcBool :: Exp -> Maybe (Term Bool) tcBool (IsZero e) = TIsZero > <$> tcInt e tcBool (If c e1 e2) = TIf <$> tcBool c <*> tcBool e1 > <*> tcBool e2 tcBool _ = empty > > typecheck :: Exp -> Maybe (Term t) typecheck e = forget <$> tcInt e > <|> forget <$> tcBool e where forget :: Term a -> Term b forget = > unsafeCoerce > > Regards, Sean - -- Florian Lorenzen Technische Universit?t Berlin Fakult?t IV - Elektrotechnik und Informatik ?bersetzerbau und Programmiersprachen Sekr. TEL12-2, Ernst-Reuter-Platz 7, D-10587 Berlin Tel.: +49 (30) 314-24618 E-Mail: florian.lorenzen at tu-berlin.de WWW: http://www.user.tu-berlin.de/florenz/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iEYEARECAAYFAlBTH10ACgkQvjzICpVvX7ZIVACdEPtbEHbVeQcdgzQTanVkpeKq 8QsAn3b774JsVyMMVc1lIN2rFlTVheQD =zgOc -----END PGP SIGNATURE----- From hesselink at gmail.com Fri Sep 14 14:27:53 2012 From: hesselink at gmail.com (Erik Hesselink) Date: Fri, 14 Sep 2012 14:27:53 +0200 Subject: [Haskell-cafe] Transforming a ADT to a GADT In-Reply-To: References: <50530ABF.7060904@tu-berlin.de> Message-ID: On Fri, Sep 14, 2012 at 2:01 PM, Sean Leather wrote: > On Fri, Sep 14, 2012 at 12:45 PM, Florian Lorenzen wrote: >> >> I'd like to transform a value of an ADT to a GADT. Suppose I have the >> simple expression language >> >> > data Exp = Lit Int > | Succ Exp > | IsZero Exp > | If Exp Exp Exp >> >> and the GADT >> >> > data Term t where > TLit :: Int -> Term Int > TSucc :: Term Int -> >> Term Int > TIsZero :: Term Int -> Term Bool > TIf :: Term Bool -> Term >> ty -> Term ty -> Term ty >> >> that encodes the typing rules. >> >> Now, I'd like to have a function >> >> > typecheck :: Exp -> Maybe (Term t) > typecheck exp = <...> >> >> that returns the GADT value corresponding to `exp' if `exp' is type >> correct. > > > It's not pretty, but it should still be safe... > > import Control.Applicative > import Unsafe.Coerce > > tcInt :: Exp -> Maybe (Term Int) > tcInt (Lit i) = pure (TLit i) > tcInt (Succ e) = TSucc <$> tcInt e > tcInt (If c e1 e2) = TIf <$> tcBool c <*> tcInt e1 <*> tcInt e2 > tcInt _ = empty > > tcBool :: Exp -> Maybe (Term Bool) > tcBool (IsZero e) = TIsZero <$> tcInt e > tcBool (If c e1 e2) = TIf <$> tcBool c <*> tcBool e1 <*> tcBool e2 > tcBool _ = empty > > typecheck :: Exp -> Maybe (Term t) > typecheck e = forget <$> tcInt e <|> forget <$> tcBool e > where > forget :: Term a -> Term b > forget = unsafeCoerce I don't think this is safe. What will happen if you evaluate typecheck (Lit 1) :: Maybe (Term Bool) In general, I think you have to work inside an existential. So you hide the type of the parsed Term inside an existential. If you want to apply functions to this Term, you unpack, call the function, and repack. I don't think there's a way around this, since the type parameter to Term _is_ existential. You know there is some type, but you don't know what it is. If you make it polymorphic, the _called_ can choose it, which is the opposite of what you want. Erik From leather at cs.uu.nl Fri Sep 14 14:42:40 2012 From: leather at cs.uu.nl (Sean Leather) Date: Fri, 14 Sep 2012 14:42:40 +0200 Subject: [Haskell-cafe] Transforming a ADT to a GADT In-Reply-To: References: <50530ABF.7060904@tu-berlin.de> Message-ID: On Fri, Sep 14, 2012 at 2:27 PM, Erik Hesselink wrote: > I don't think this is safe. What will happen if you evaluate > typecheck (Lit 1) :: Maybe (Term Bool) > Indeed! Silly me. Caught by the lure again. Thanks. Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: From tsuyoshi.ito.2006 at gmail.com Fri Sep 14 15:11:57 2012 From: tsuyoshi.ito.2006 at gmail.com (Tsuyoshi Ito) Date: Fri, 14 Sep 2012 09:11:57 -0400 Subject: [Haskell-cafe] Transforming a ADT to a GADT In-Reply-To: <50530ABF.7060904@tu-berlin.de> References: <50530ABF.7060904@tu-berlin.de> Message-ID: Dear Florian, On Fri, Sep 14, 2012 at 6:45 AM, Florian Lorenzen wrote: > Now, I'd like to have a function > >> typecheck :: Exp -> Maybe (Term t) > typecheck exp = <...> > > that returns the GADT value corresponding to `exp' if `exp' is type > correct. If you can add ?deriving Typeable? to Term and you are fine with a less general type typecheck :: Typeable t => Exp -> Maybe (Term t) then you can use Data.Typeable.cast. ----- {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE GADTs #-} module ADTToGADT where import Control.Applicative import Data.Typeable data Exp = Lit Int | Succ Exp | IsZero Exp | If Exp Exp Exp data Term t where TLit :: Int -> Term Int TSucc :: Term Int -> Term Int TIsZero :: Term Int -> Term Bool TIf :: Term Bool -> Term ty -> Term ty -> Term ty deriving Typeable typecheck :: Typeable t => Exp -> Maybe (Term t) typecheck (Lit i) = cast $ TLit i typecheck (Succ e) = castTerm $ TSucc <$> typecheck e typecheck (IsZero e) = castTerm $ TIsZero <$> typecheck e typecheck (If c e1 e2) = TIf <$> typecheck c <*> typecheck e1 <*> typecheck e2 castTerm :: (Typeable a, Typeable b) => Maybe (Term a) -> Maybe (Term b) castTerm Nothing = Nothing castTerm (Just t) = cast t ----- Best regards, Tsuyoshi From hesselink at gmail.com Fri Sep 14 15:22:34 2012 From: hesselink at gmail.com (Erik Hesselink) Date: Fri, 14 Sep 2012 15:22:34 +0200 Subject: [Haskell-cafe] Transforming a ADT to a GADT In-Reply-To: References: <50530ABF.7060904@tu-berlin.de> Message-ID: On Fri, Sep 14, 2012 at 2:27 PM, Erik Hesselink wrote: > In general, I think you have to work inside an existential. So you > hide the type of the parsed Term inside an existential. If you want to > apply functions to this Term, you unpack, call the function, and > repack. Maybe I should expand what I mean by this. Let's say you have: data SomeTerm where SomeTerm :: Term a -> SomeTerm Your typecheck function goes: typecheck :: Exp -> SomeTerm and you want to apply: transform :: Term t -> Term t You should do something like: f (SomeTerm t) = SomeTerm (transform t) Or, more generally: onSomeTerm :: (forall t. Term t -> Term t) -> SomeTerm -> SomeTerm onSomeTerm f (SomeTerm t) = SomeTerm (f t) Erik From lykahb at gmail.com Fri Sep 14 15:57:33 2012 From: lykahb at gmail.com (Boris Lykah) Date: Fri, 14 Sep 2012 16:57:33 +0300 Subject: [Haskell-cafe] ANNOUNCE: Groundhog 0.1.0.1 - high-level database library In-Reply-To: References: Message-ID: Groundhog has design very similar to Persistent, so I would choose it for comparison. I don't have much of experience of using Persistent, so some facts may be inaccurate for the newer versions. The facts are based mostly on the Persistent documentation. You may be also interested in comparison of Persistent, HaskellDB, and Esqueleto from the announce of the library Esqueleto by Felipe Lessa http://blog.felipe.lessa.nom.br/?p=68 * Persistent creates both data definitions and auxiliary structures. This approach is not modular because it ties the data to a specific library. Groundhog examines existing data definitions defined in a normal way and uses this data to create the auxiliary structures. * Persistent entities always have autoincrement integer(for MongoDB bytestring) key. Groundhog entities may omit it and use a natural (composites are supported) key. An entity may have several keys. * Persistent stores embedded datatypes as a JSON string. Groundhog flattens the inner fields to several columns, which enables full access to inner fields of an embedded datatype. * Groundhog supports typesafe projections. Persistent can do them only with raw SQL or esqueleto. * Groundhog has expressive query DSL which enables comparing field-to-value, field-to-field, and use arbitrary arithmetic expressions. Persistent only supports field-to-value expressions with only one operator. * Groundhog does not support joins. Persistent supports only one-to-many joins for two tables, but esqueleto supports many types of joins for multiple tables. * Groundhog currently does not support Conduit or other resource-management libraries, IN clause, and migrations that add NOT NULL columns to non-empty tables. * Groundhog supports Sqlite and PostgreSQL. Persistent supports Sqlite, PostgreSQL, MySQL, and MongoDB. On Fri, Sep 14, 2012 at 1:28 AM, Tom Murphy wrote: > How does this compare with other high-level Haskell db libraries? > > Tom > > On Sep 13, 2012 2:25 PM, "Boris Lykah" wrote: >> >> I am happy to announce a new version of Groundhog, a library for fast >> high-level database access: >> http://hackage.haskell.org/package/groundhog >> http://hackage.haskell.org/package/groundhog-th >> http://hackage.haskell.org/package/groundhog-postgresql >> http://hackage.haskell.org/package/groundhog-sqlite >> >> Groundhog has been completely overhauled since the last release. >> Notably, it got support for PostgreSQL and natural foreign keys. I >> believe that it is a big step forward as this brings more flexibility >> to the design of the relational schemas while keeping the applications >> independent of the storage layer. Some of the solutions, particularly >> schema migration were based on Persistent code. >> >> Please see examples at >> http://github.com/lykahb/groundhog/tree/master/examples. >> >> Features: >> * Support for Sqlite and PostgreSQL. >> * Natural and composite foreign keys. Earlier it was possible to >> reference an entity only by the mandatory integer primary key. Now an >> entity can have several keys including autoincrement primary key >> (optional) and unique keys which have one or more columns. >> * Full support of embedded datatypes. You can access a field that >> contains an embedded datatype as a whole, or access some of the inner >> subfields individually. This powerful mechanism has allowed >> implementation of the composite keys, and can be used in future to >> work with PostgreSQL composite types or MongoDB embedded documents. >> Instead of serializing value to string, the Groundhog backends flatten >> tree of embedded datatypes to db columns. >> * Projections. You can choose what columns to query from a table in a >> type-safe manner. >> * Initialization and migration of database schema. >> * Sum types and polymorphic types. >> * Expression DSL for use in queries. >> * Basic list support. >> * YAML-based settings mechanism. It separates datatype definition and >> description which facilitates modularity. The settings are inferred >> from the analysis of the difinition, and overridden with values set by >> user. >> >> The Criterion benchmarks are available at >> http://lykahb.github.com/groundhog/SqliteBench.html and >> http://lykahb.github.com/groundhog/PostgreSQLBench.html. >> >> Future plans: >> * Support for joins >> * Database indexes >> * Investigate options for implementing MongoDB and MySQL backends >> >> Your feedback, suggestions for improvement and criticism are welcome. >> >> -- >> Regards, >> Boris >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe -- Regards, Boris From andrew.pennebaker at gmail.com Fri Sep 14 18:13:15 2012 From: andrew.pennebaker at gmail.com (Andrew Pennebaker) Date: Fri, 14 Sep 2012 12:13:15 -0400 Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius Message-ID: I've gotten mixed feedback from Reddit for my tutorial. It provides an overview of how functional and declarative programming in Haskell empower baddies, increasing the accuracy and efficiency of their atomic superweapons. What do you guys think of my tutorial, Haskell for the Evil Genius ? Cheers, Andrew Pennebaker www.yellosoft.us -------------- next part -------------- An HTML attachment was scrubbed... URL: From hellertime at gmail.com Fri Sep 14 19:14:30 2012 From: hellertime at gmail.com (Chris Heller) Date: Fri, 14 Sep 2012 13:14:30 -0400 Subject: [Haskell-cafe] What is the good way to work with list comprehension and UTCTime? Message-ID: You might want to have a look at the time-recurrence package: http://hackage.haskell.org/package/time-recurrence For your simple cases you would do something like: Each second: starting (UTCTime ...) $ recur secondly Each minute: starting (UTCTime ...) $ recur minutely The rules can get quite a bit more complex than that. I am the author of time-recurrence, so if you have questions feel free to ping me. -Chris On Fri, Sep 14, 2012 at 6:00 AM, wrote: > Send Haskell-Cafe mailing list submissions to > haskell-cafe at haskell.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://www.haskell.org/mailman/listinfo/haskell-cafe > or, via email, send a message with subject or body 'help' to > haskell-cafe-request at haskell.org > > You can reach the person managing the list at > haskell-cafe-owner at haskell.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Haskell-Cafe digest..." > > > Today's Topics: > > 1. Fwd: How Type inference work in presence of Functional > Dependencies (Dan Doel) > 2. Re: [ANN] Cumino 0.2 - Now supports pretty indentation > through stylish-haskell (Brandon Allbery) > 3. Re: [ANN] Cumino 0.2 - Now supports pretty indentation > through stylish-haskell (Alfredo Di Napoli) > 4. ANNOUNCE: Groundhog 0.1.0.1 - high-level database library > (Boris Lykah) > 5. Re: ANNOUNCE: Groundhog 0.1.0.1 - high-level database library > (Tom Murphy) > 6. Re: Either Monad and Laziness (wren ng thornton) > 7. How do I generate random numbers using random-fu, with > platform-agnostic code? (Andrew Pennebaker) > 8. Is Hackage down? (C K Kashyap) > 9. Re: Is Hackage down? (damodar kulkarni) > 10. What is the good way to work with list comprehension and > UTCTime? (Magicloud Magiclouds) > 11. Re: What is the good way to work with list comprehension and > UTCTime? (Karl Voelker) > 12. Re: [ANN] Cumino 0.2 - Now supports pretty indentation > through stylish-haskell (Alfredo Di Napoli) > 13. Re: Is Hackage down? (John Wiegley) > 14. Re: [ANN] Cumino 0.2 - Now supports pretty indentation > through stylish-haskell (Alfredo Di Napoli) > 15. Re: What is the good way to work with list comprehension and > UTCTime? (Roman Cheplyaka) > 16. Re: What is the good way to work with list comprehension and > UTCTime? (Magicloud Magiclouds) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 13 Sep 2012 10:44:17 -0400 > From: Dan Doel > Subject: [Haskell-cafe] Fwd: How Type inference work in presence of > Functional Dependencies > To: Haskell Caf? List > Message-ID: > < > CAHEA9tPsGTUX4Ke9eGCpA+-f_b_Ky9--y6RZkHPAmN9LW8MxHA at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > Copying the mailing list, because I forgot. > > On Thu, Sep 13, 2012 at 5:18 AM, satvik chauhan > wrote: > > Consider the code below : > > > > {-# LANGUAGE > > > MultiParamTypeClasses,FlexibleInstances,FunctionalDependencies,UndecidableInstances,FlexibleContexts > > #-} > > class Foo a c | a -> c > > instance Foo Int Float > > f :: (Foo Int a) => Int -> a > > f = undefined > > > > Now when I see the inferred type of f in ghci > > > >> :t f > > > >> f :: Int -> Float > > > > Now If I add the following code > > > > g :: Int -> Float > > g = undefined > > > > h :: (Foo Int a) => Int -> a > > h = g > > > > > > I get the error > > > > Could not deduce (a ~ Float) > > > > > > I am not able to understand what has happened here ? The restriction "Foo > > Int a" should have restricted the type of h to "Int -> Float" as shown in > > the inferred type of f. > > The answer, I believe, is that the difference between the fundep > implementation and type families is local constraint information. > Fundeps do no local propagation. > > So in your first definition, you've locally provided 'Int -> a', which > is acceptable to GHC. Then it figures out externally to the function > that '(Foo Int a) => Int -> a' is actually Int -> Float. > > In the second definition, you're trying to give 'Int -> Float', but > GHC only knows locally that you need to provide 'Int -> a' with a > constraint 'Foo Int a' which it _won't_ use to determine that a ~ > Float. > > This is not inherent to fundeps. One could make a version of fundeps > that has the local constraint rules (easily so by translating to the > new type families stuff). But, the difference is also the reason that > overlapping instances are supported for fundeps and not type families. > But I won't get into that right now. > > -- Dan > > > > ------------------------------ > > Message: 2 > Date: Thu, 13 Sep 2012 11:20:51 -0400 > From: Brandon Allbery > Subject: Re: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty > indentation through stylish-haskell > To: Alfredo Di Napoli > Cc: Ray , haskell-cafe > Message-ID: > KHDx1dGeO-s9EsG4H9nMsvQ at mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > On Thu, Sep 13, 2012 at 2:22 AM, Alfredo Di Napoli < > alfredo.dinapoli at gmail.com> wrote: > > > urxvtc -e sh -c 'echo a' > >> xterm -e echo a > >> > > > > I would like to, and in fact I've already tried, but urxvt is trickier > > than other shells. Using the command you gave me does not create a new > > window, tested both on XMonad and Gnome. This is > > the error you can see using the option "-hold", this way: > > > > urxvt --hold -e "echo a" > > > > This opens a new window with the error: *urxvt: Unable to exec child. > > * > > > > I think you misunderstood; as I read it (and as I would expect it to work > given the above descrtiption) that would be > > urxvt --hold -e sh -c 'echo a' > > -- > brandon s allbery allbery.b at gmail.com > wandering unix systems administrator (available) (412) 475-9364 vm/sms > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://www.haskell.org/pipermail/haskell-cafe/attachments/20120913/76483291/attachment-0001.htm > > > > ------------------------------ > > Message: 3 > Date: Thu, 13 Sep 2012 18:16:06 +0200 > From: Alfredo Di Napoli > Subject: Re: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty > indentation through stylish-haskell > To: haskell-cafe > Message-ID: <20120913161604.GA31344 at gmail.com> > Content-Type: text/plain; charset=utf-8 > > If I remember correctly, I've also tried that combinations, without > success. > > Anyway, I'm not at work so I can't test Cumino against gnome and Xmonad > until tomorrow morning: I'll keep you posted! > > Bye, > Alfredo > > > > > I think you misunderstood; as I read it (and as I would expect it to work > > given the above descrtiption) that would be > > > > urxvt --hold -e sh -c 'echo a' > > > > -- > > brandon s allbery > allbery.b at gmail.com > > wandering unix systems administrator (available) (412) 475-9364vm/sms > > > > ------------------------------ > > Message: 4 > Date: Thu, 13 Sep 2012 21:23:09 +0300 > From: Boris Lykah > Subject: [Haskell-cafe] ANNOUNCE: Groundhog 0.1.0.1 - high-level > database library > To: haskell-cafe at haskell.org > Message-ID: > y_wwN0-AwWjoMBvERY0XpgByCoMeuxZ1SegVKXinRV4-A at mail.gmail.com> > Content-Type: text/plain; charset=ISO-8859-1 > > I am happy to announce a new version of Groundhog, a library for fast > high-level database access: > http://hackage.haskell.org/package/groundhog > http://hackage.haskell.org/package/groundhog-th > http://hackage.haskell.org/package/groundhog-postgresql > http://hackage.haskell.org/package/groundhog-sqlite > > Groundhog has been completely overhauled since the last release. > Notably, it got support for PostgreSQL and natural foreign keys. I > believe that it is a big step forward as this brings more flexibility > to the design of the relational schemas while keeping the applications > independent of the storage layer. Some of the solutions, particularly > schema migration were based on Persistent code. > > Please see examples at > http://github.com/lykahb/groundhog/tree/master/examples. > > Features: > * Support for Sqlite and PostgreSQL. > * Natural and composite foreign keys. Earlier it was possible to > reference an entity only by the mandatory integer primary key. Now an > entity can have several keys including autoincrement primary key > (optional) and unique keys which have one or more columns. > * Full support of embedded datatypes. You can access a field that > contains an embedded datatype as a whole, or access some of the inner > subfields individually. This powerful mechanism has allowed > implementation of the composite keys, and can be used in future to > work with PostgreSQL composite types or MongoDB embedded documents. > Instead of serializing value to string, the Groundhog backends flatten > tree of embedded datatypes to db columns. > * Projections. You can choose what columns to query from a table in a > type-safe manner. > * Initialization and migration of database schema. > * Sum types and polymorphic types. > * Expression DSL for use in queries. > * Basic list support. > * YAML-based settings mechanism. It separates datatype definition and > description which facilitates modularity. The settings are inferred > from the analysis of the difinition, and overridden with values set by > user. > > The Criterion benchmarks are available at > http://lykahb.github.com/groundhog/SqliteBench.html and > http://lykahb.github.com/groundhog/PostgreSQLBench.html. > > Future plans: > * Support for joins > * Database indexes > * Investigate options for implementing MongoDB and MySQL backends > > Your feedback, suggestions for improvement and criticism are welcome. > > -- > Regards, > Boris > > > > ------------------------------ > > Message: 5 > Date: Thu, 13 Sep 2012 18:28:34 -0400 > From: Tom Murphy > Subject: Re: [Haskell-cafe] ANNOUNCE: Groundhog 0.1.0.1 - high-level > database library > To: Boris Lykah > Cc: haskell-cafe at haskell.org > Message-ID: > < > CAO9Q0tU187QkJL5UHyL3A6WvQpOhPWHHTHrMeoWYhOTcWEzHqg at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > How does this compare with other high-level Haskell db libraries? > > Tom > On Sep 13, 2012 2:25 PM, "Boris Lykah" wrote: > > > I am happy to announce a new version of Groundhog, a library for fast > > high-level database access: > > http://hackage.haskell.org/package/groundhog > > http://hackage.haskell.org/package/groundhog-th > > http://hackage.haskell.org/package/groundhog-postgresql > > http://hackage.haskell.org/package/groundhog-sqlite > > > > Groundhog has been completely overhauled since the last release. > > Notably, it got support for PostgreSQL and natural foreign keys. I > > believe that it is a big step forward as this brings more flexibility > > to the design of the relational schemas while keeping the applications > > independent of the storage layer. Some of the solutions, particularly > > schema migration were based on Persistent code. > > > > Please see examples at > > http://github.com/lykahb/groundhog/tree/master/examples. > > > > Features: > > * Support for Sqlite and PostgreSQL. > > * Natural and composite foreign keys. Earlier it was possible to > > reference an entity only by the mandatory integer primary key. Now an > > entity can have several keys including autoincrement primary key > > (optional) and unique keys which have one or more columns. > > * Full support of embedded datatypes. You can access a field that > > contains an embedded datatype as a whole, or access some of the inner > > subfields individually. This powerful mechanism has allowed > > implementation of the composite keys, and can be used in future to > > work with PostgreSQL composite types or MongoDB embedded documents. > > Instead of serializing value to string, the Groundhog backends flatten > > tree of embedded datatypes to db columns. > > * Projections. You can choose what columns to query from a table in a > > type-safe manner. > > * Initialization and migration of database schema. > > * Sum types and polymorphic types. > > * Expression DSL for use in queries. > > * Basic list support. > > * YAML-based settings mechanism. It separates datatype definition and > > description which facilitates modularity. The settings are inferred > > from the analysis of the difinition, and overridden with values set by > > user. > > > > The Criterion benchmarks are available at > > http://lykahb.github.com/groundhog/SqliteBench.html and > > http://lykahb.github.com/groundhog/PostgreSQLBench.html. > > > > Future plans: > > * Support for joins > > * Database indexes > > * Investigate options for implementing MongoDB and MySQL backends > > > > Your feedback, suggestions for improvement and criticism are welcome. > > > > -- > > Regards, > > Boris > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://www.haskell.org/pipermail/haskell-cafe/attachments/20120913/96747b7d/attachment-0001.htm > > > > ------------------------------ > > Message: 6 > Date: Fri, 14 Sep 2012 01:29:32 +0200 > From: wren ng thornton > Subject: Re: [Haskell-cafe] Either Monad and Laziness > To: haskell-cafe at haskell.org > Message-ID: <50526C5C.40506 at freegeek.org> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 9/12/12 5:37 PM, Francesco Mazzoli wrote: > > At Wed, 12 Sep 2012 12:04:31 -0300, > > Eric Velten de Melo wrote: > >> It would be really awesome, though, if it were possible to use a > >> parser written in Parsec with this, in the spirit of avoiding code > >> rewriting and enhancing expressivity and abstraction. > > > > There is and > > , which turn > > attoparsec parsers into enumerators/conduits, and > > , which is a > compatibility > > layer between attoaparsec and parsec. Good luck :). > > Not to mention attoparsec-iteratee, for the iteratee minded folks: > > http://hackage.haskell.org/package/attoparsec-iteratee > > > -- > Live well, > ~wren > > > > ------------------------------ > > Message: 7 > Date: Thu, 13 Sep 2012 20:04:49 -0400 > From: Andrew Pennebaker > Subject: [Haskell-cafe] How do I generate random numbers using > random-fu, with platform-agnostic code? > To: Haskell Cafe > Message-ID: > DYKggntLViDxnXUA at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > I can't figure out how to use Data.Random.Source.IO to generate random > numbers in a multiplatform way. > > I can generate random numbers in Unix using Data.Random.Source.DevRandom, > and there is an example in the GitHub documentation for Windows using > Data.Random.Source.MWC, but there is no example code for using > Data.Random.Source.IO. > > Cheers, > > Andrew Pennebaker > www.yellosoft.us > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://www.haskell.org/pipermail/haskell-cafe/attachments/20120913/f63ed3f0/attachment-0001.htm > > > > ------------------------------ > > Message: 8 > Date: Fri, 14 Sep 2012 10:33:40 +0530 > From: C K Kashyap > Subject: [Haskell-cafe] Is Hackage down? > To: Haskell Cafe > Message-ID: > < > CAGdT1gpVt10WoEkOr8tSiunOxfaPN4rk5V2KskAufztcqSa6Cw at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > Is it just me or is Hackage indeed been going down more frequently of late? > > Regards, > Kashyap > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://www.haskell.org/pipermail/haskell-cafe/attachments/20120914/14dde1d2/attachment-0001.htm > > > > ------------------------------ > > Message: 9 > Date: Fri, 14 Sep 2012 10:38:55 +0530 > From: damodar kulkarni > Subject: Re: [Haskell-cafe] Is Hackage down? > To: C K Kashyap > Cc: Haskell Cafe > Message-ID: > A0tc-27TKS7CcYYfyrOF1AA at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > It shows hackage down: > http://www.downforeveryoneorjustme.com/http://hackage.haskell.org/ > > - damodar > > On Fri, Sep 14, 2012 at 10:33 AM, C K Kashyap wrote: > > > Is it just me or is Hackage indeed been going down more frequently of > late? > > > > Regards, > > Kashyap > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://www.haskell.org/pipermail/haskell-cafe/attachments/20120914/c42a51b2/attachment-0001.htm > > > > ------------------------------ > > Message: 10 > Date: Fri, 14 Sep 2012 13:29:52 +0800 > From: Magicloud Magiclouds > Subject: [Haskell-cafe] What is the good way to work with list > comprehension and UTCTime? > To: haskell-cafe > Message-ID: > 4ghf+bcm8f72O1RifBJnLpA at mail.gmail.com> > Content-Type: text/plain; charset=UTF-8 > > Hi, > Simple usage, I could make an instance of Enum to UTCTime, so > [utcTime..] could work. But that is so stiff. How if sometimes I want > to step by 1 min, sometimes I want to step by 1 sec? > So I think some way like [ t | addUTCTime last 60 ] could be nice. > But I cannot figure it out.... > Any idea? > -- > ??????? > ??????? > > And for G+, please use magiclouds#gmail.com. > > > > ------------------------------ > > Message: 11 > Date: Thu, 13 Sep 2012 23:04:51 -0700 > From: Karl Voelker > Subject: Re: [Haskell-cafe] What is the good way to work with list > comprehension and UTCTime? > To: Magicloud Magiclouds > Cc: haskell-cafe > Message-ID: > < > CAFfow0zQc43kEgZkVdsD9Wr6PZJfEoLajPdiCRG5cjbEfOarFg at mail.gmail.com> > Content-Type: text/plain; charset="iso-8859-1" > > On Thu, Sep 13, 2012 at 10:29 PM, Magicloud Magiclouds < > magicloud.magiclouds at gmail.com> wrote: > > > Hi, > > Simple usage, I could make an instance of Enum to UTCTime, so > > [utcTime..] could work. But that is so stiff. How if sometimes I want > > to step by 1 min, sometimes I want to step by 1 sec? > > So I think some way like [ t | addUTCTime last 60 ] could be nice. > > But I cannot figure it out.... > > Any idea? > > > > Try using Prelude.iterate. > > -Karl > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://www.haskell.org/pipermail/haskell-cafe/attachments/20120913/5ab286e4/attachment-0001.htm > > > > ------------------------------ > > Message: 12 > Date: Fri, 14 Sep 2012 06:14:11 +0000 > From: Alfredo Di Napoli > Subject: Re: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty > indentation through stylish-haskell > To: haskell-cafe > Message-ID: > < > CAFqA6+X-0LTOir4i+oOGqiu64cqR_ayrgGnj-P+K2V+FrUcOJw at mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > Ok, I've added the support for urxvt. > Bear in mind that it partially support urxvt, though: it works fine if you > run GVim or Vim outside an already running tmux session, otherwise it won't > start. > The problem is due to the fact urxvt believes that the new session is > launched within the running tmux session, whining about nested tmux session > and not starting at all. > You can unset the $TERM variable as workaround, but I don't like that > apporach. > If you come up with an alternative solution please let me know :) > A. > > On 13 September 2012 16:16, Alfredo Di Napoli >wrote: > > > If I remember correctly, I've also tried that combinations, without > > success. > > > > Anyway, I'm not at work so I can't test Cumino against gnome and Xmonad > > until tomorrow morning: I'll keep you posted! > > > > Bye, > > Alfredo > > > > > > > > I think you misunderstood; as I read it (and as I would expect it to > work > > > given the above descrtiption) that would be > > > > > > urxvt --hold -e sh -c 'echo a' > > > > > > -- > > > brandon s allbery > > allbery.b at gmail.com > > > wandering unix systems administrator (available) (412) > 475-9364vm/sms > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://www.haskell.org/pipermail/haskell-cafe/attachments/20120914/34645cae/attachment-0001.htm > > > > ------------------------------ > > Message: 13 > Date: Fri, 14 Sep 2012 01:21:03 -0500 > From: "John Wiegley" > Subject: Re: [Haskell-cafe] Is Hackage down? > To: haskell-cafe at haskell.org > Message-ID: > Content-Type: text/plain > > >>>>> C K Kashyap writes: > > > Is it just me or is Hackage indeed been going down more frequently of > late? > > It's not just you. > > > > > ------------------------------ > > Message: 14 > Date: Fri, 14 Sep 2012 06:50:07 +0000 > From: Alfredo Di Napoli > Subject: Re: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty > indentation through stylish-haskell > To: haskell-cafe > Message-ID: > 7DcvBbNuBzxk7tDkcaaf8ERD78q4VucqGGtA at mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > Sorry the typo, the variable is $TMUX and controls the nesting ot tmux > session. It turns out that if affect not only urxvt but also xterm and > gnome-terminal. > Perhaps it could be useful to unset it programmatically, I'll keep you > posted if I find a workaround. > > A. > > On 14 September 2012 06:14, Alfredo Di Napoli >wrote: > > > Ok, I've added the support for urxvt. > > Bear in mind that it partially support urxvt, though: it works fine if > you > > run GVim or Vim outside an already running tmux session, otherwise it > won't > > start. > > The problem is due to the fact urxvt believes that the new session is > > launched within the running tmux session, whining about nested tmux > session > > and not starting at all. > > You can unset the $TERM variable as workaround, but I don't like that > > apporach. > > If you come up with an alternative solution please let me know :) > > A. > > > > > > On 13 September 2012 16:16, Alfredo Di Napoli < > alfredo.dinapoli at gmail.com>wrote: > > > >> If I remember correctly, I've also tried that combinations, without > >> success. > >> > >> Anyway, I'm not at work so I can't test Cumino against gnome and Xmonad > >> until tomorrow morning: I'll keep you posted! > >> > >> Bye, > >> Alfredo > >> > >> > > >> > I think you misunderstood; as I read it (and as I would expect it to > >> work > >> > given the above descrtiption) that would be > >> > > >> > urxvt --hold -e sh -c 'echo a' > >> > > >> > -- > >> > brandon s allbery > >> allbery.b at gmail.com > >> > wandering unix systems administrator (available) (412) > 475-9364vm/sms > >> > > > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://www.haskell.org/pipermail/haskell-cafe/attachments/20120914/0b8897fd/attachment-0001.htm > > > > ------------------------------ > > Message: 15 > Date: Fri, 14 Sep 2012 10:03:01 +0200 > From: Roman Cheplyaka > Subject: Re: [Haskell-cafe] What is the good way to work with list > comprehension and UTCTime? > To: Magicloud Magiclouds > Cc: haskell-cafe > Message-ID: > < > CAD+QkRoxe0TuwrO3VayE78emfVFFz_rv1RdE+oaX1xanpqpyKg at mail.gmail.com> > Content-Type: text/plain; charset="gb2312" > > Consider using the time-lens package. > > import Data.Time.Lens > import Data.Lens.Common > > List comprehension style: > > [modL seconds (+ fromIntegral n) t | n <- [0..]] > [modL minutes (+ n) t | n <- [0..]] > > (you need fromIntegral for seconds, because it is of fractional type in > Data.Time). > > iterate style, as suggested by Karl: > > iterate (seconds ^+= 1) t > iterate (minutes ^+= 1) t > > On Fri, Sep 14, 2012 at 7:29 AM, Magicloud Magiclouds < > magicloud.magiclouds at gmail.com> wrote: > > > Hi, > > Simple usage, I could make an instance of Enum to UTCTime, so > > [utcTime..] could work. But that is so stiff. How if sometimes I want > > to step by 1 min, sometimes I want to step by 1 sec? > > So I think some way like [ t | addUTCTime last 60 ] could be nice. > > But I cannot figure it out.... > > Any idea? > > -- > > ??????? > > ??????? > > > > And for G+, please use magiclouds#gmail.com. > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://www.haskell.org/pipermail/haskell-cafe/attachments/20120914/067fc717/attachment-0001.htm > > > > ------------------------------ > > Message: 16 > Date: Fri, 14 Sep 2012 16:25:58 +0800 > From: Magicloud Magiclouds > Subject: Re: [Haskell-cafe] What is the good way to work with list > comprehension and UTCTime? > To: Roman Cheplyaka > Cc: haskell-cafe > Message-ID: > < > CABErt4fEAnEaFjhSjbYDMX7y0jJJkCO8WAq-ToXjGc5xRtGg4A at mail.gmail.com> > Content-Type: text/plain; charset=UTF-8 > > This is nice. Thanks to all. > > On Fri, Sep 14, 2012 at 4:03 PM, Roman Cheplyaka wrote: > > Consider using the time-lens package. > > > > import Data.Time.Lens > > import Data.Lens.Common > > > > List comprehension style: > > > > [modL seconds (+ fromIntegral n) t | n <- [0..]] > > [modL minutes (+ n) t | n <- [0..]] > > > > (you need fromIntegral for seconds, because it is of fractional type in > > Data.Time). > > > > iterate style, as suggested by Karl: > > > > iterate (seconds ^+= 1) t > > iterate (minutes ^+= 1) t > > > > On Fri, Sep 14, 2012 at 7:29 AM, Magicloud Magiclouds > > wrote: > >> > >> Hi, > >> Simple usage, I could make an instance of Enum to UTCTime, so > >> [utcTime..] could work. But that is so stiff. How if sometimes I want > >> to step by 1 min, sometimes I want to step by 1 sec? > >> So I think some way like [ t | addUTCTime last 60 ] could be nice. > >> But I cannot figure it out.... > >> Any idea? > >> -- > >> ??????? > >> ??????? > >> > >> And for G+, please use magiclouds#gmail.com. > >> > >> _______________________________________________ > >> Haskell-Cafe mailing list > >> Haskell-Cafe at haskell.org > >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > > > -- > ??????? > ??????? > > And for G+, please use magiclouds#gmail.com. > > > > ------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > End of Haskell-Cafe Digest, Vol 109, Issue 19 > ********************************************* > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex at stangl.us Fri Sep 14 19:50:22 2012 From: alex at stangl.us (Alex Stangl) Date: Fri, 14 Sep 2012 12:50:22 -0500 Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius In-Reply-To: References: Message-ID: <20120914175022.GA38630@scout.stangl.us> On Fri, Sep 14, 2012 at 12:13:15PM -0400, Andrew Pennebaker wrote: > I've gotten mixed feedback from Reddit for my tutorial. It provides an > overview of how functional and declarative programming in Haskell empower > baddies, increasing the accuracy and efficiency of their atomic > superweapons. What do you guys think of my tutorial, Haskell for the Evil > Genius ? Hopefully you'll get more feedback here, although my recent post here soliciting feedback netted me nothing. FWIW, my feedback is below. Alex Under Declarative, you aren't creating a "named expression, 2 + 2", really. You are redefining (+). Under Lazy, your example of binding fib 30 is not a good example of memoization. With memoization you typically call the underlying computation the first time, and memoize it for repeated retrieval later, not hardwire in values at compile time. Here you never ever call the real fib at all. On top of everything else, it'd be too easy to introduce a typo into one of your hardwired constant values. Under Infinite, you should use "sieve (n:ns)" pattern matching instead of calling head. Under Type-Safe Subtle distinction, but returning () is not the same as returning nothing at all. s/ommitted/omitted/ You've got an unusual indentation scheme. Consider adopting a more standard one for your tutorial. In general, monotonically decreasing is not sufficient to prove you will hit a base case. For example, decreasing by 5 would still be monotonically decreasing, and could jump right over your base cases. (Not arguing that the code is incorrect, but rather than your explanation is a little misleading/incomplete.) Again, further confusion about what memoization really is. Under Records "Functions are already defined by their data structures; they are already semantically bundled..." doesn't seem to make sense. "... acts on the specific constructor, blasting fools, murdering crowds..." makes it sound like fireOn actually has side effects. From conal at conal.net Fri Sep 14 19:53:02 2012 From: conal at conal.net (Conal Elliott) Date: Fri, 14 Sep 2012 10:53:02 -0700 Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius In-Reply-To: References: Message-ID: Hi Andrew, To save others the search, here's the/a reddit URL: http://www.reddit.com/r/programming/related/nhnyd/nfa_in_a_single_line_of_haskell/. The terribly misleading/mistaken remarks on fib & memoization are still in your post. As hammar commented on reddit commenter, you're not memoizing in that example; just shadowing one fib definition with another (very partial) one. (BTW, I highly recommend compiling with -Wall in all cases and then addressing all reported issues. Doing so would have issued a shadowing warning.) Another comment: As a declarative language, Haskell manipulates expressions, eventually > reducing expressions to values. > Huh? In what sense do declarative languages manipulate expressions? Sounds like a classic syntax/semantics confusion, especially when interpreters and/or lazy evaluation (implementation issues, not language properties) are in the mix. Regards, - Conal On Fri, Sep 14, 2012 at 9:13 AM, Andrew Pennebaker < andrew.pennebaker at gmail.com> wrote: > I've gotten mixed feedback from Reddit for my tutorial. It provides an > overview of how functional and declarative programming in Haskell empower > baddies, increasing the accuracy and efficiency of their atomic > superweapons. What do you guys think of my tutorial, Haskell for the Evil > Genius ? > > Cheers, > > Andrew Pennebaker > www.yellosoft.us > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ericvmelo at gmail.com Fri Sep 14 23:16:23 2012 From: ericvmelo at gmail.com (Eric Velten de Melo) Date: Fri, 14 Sep 2012 18:16:23 -0300 Subject: [Haskell-cafe] Either Monad and Laziness In-Reply-To: <50526C5C.40506@freegeek.org> References: <20120912060330.83793.qmail@www1.g3.pair.com> <87vcfjxnfk.wl%f@mazzo.li> <50526C5C.40506@freegeek.org> Message-ID: On 13 September 2012 20:29, wren ng thornton wrote: > On 9/12/12 5:37 PM, Francesco Mazzoli wrote: >> >> At Wed, 12 Sep 2012 12:04:31 -0300, >> Eric Velten de Melo wrote: >>> >>> It would be really awesome, though, if it were possible to use a >>> parser written in Parsec with this, in the spirit of avoiding code >>> rewriting and enhancing expressivity and abstraction. >> >> >> There is and >> , which turn >> attoparsec parsers into enumerators/conduits, and >> , which is a >> compatibility >> layer between attoaparsec and parsec. Good luck :). > > > Not to mention attoparsec-iteratee, for the iteratee minded folks: > > http://hackage.haskell.org/package/attoparsec-iteratee > Hm... I guess I'm spoiled for choice then. :) But now I'm kinda lost. Is there an easy way to explain the difference between: -iteratee -conduit -enumerator I'm very curious about everything concerning Haskell and new interesting abstractions and ways of doing things, but I might not have the time to delve deeper into that. > > -- > Live well, > ~wren > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From andrew.pennebaker at gmail.com Fri Sep 14 23:18:24 2012 From: andrew.pennebaker at gmail.com (Andrew Pennebaker) Date: Fri, 14 Sep 2012 17:18:24 -0400 Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius In-Reply-To: <20120914175022.GA38630@scout.stangl.us> References: <20120914175022.GA38630@scout.stangl.us> Message-ID: A summary of the changes I've included so far: > Under Declarative, you aren't creating a "named expression, 2 + 2", really. > You are redefining (+). > > Noted and reflected in the new version. > Under Lazy, your example of binding fib 30 is not a good example of > memoization. With memoization you typically call the underlying computation > the first time, and memoize it for repeated retrieval later, not hardwire > in > values at compile time. Here you never ever call the real fib at all. On > top > of everything else, it'd be too easy to introduce a typo into one of your > hardwired constant values. > > Noted and reflected in the new version. After several comments to this effect, I do not want to misrepresent memoization in the tutorial. Sometimes it is useful to be slightly inaccurate in a tutorial in order to help bridge the gap between someone with no experience in a something vs the wealth of knowledge and complexity in the thing itself. This is not one of those times, and fortunately, fixing the misrepresentation in my tutorial is as easy as removing the hardcoded call. One thing I want to double check is that Haskell does, in fact, automatically memoize all pure function calls. Is this true? I would still like to provide a performance comparison of the Fibonacci code with and without memoization, for readers who enjoy numerical evidence, using the Unix "time" command, but I don't know how to turn memoization off. I guess I would have to reimplement the algorithm in a way that can't make use of memoization. Any suggestions? Under Infinite, you should use "sieve (n:ns)" pattern matching instead of > calling head. > Thank you! I try to make use of Haskell pattern matching wherever I can. Since I needed to refer to the whole list, as well as the head and tail, I originally used "head" instead of pattern matching. Noted and reflected in the new version. > Under Type-Safe > Subtle distinction, but returning () is not the same as returning nothing > at all. > True. Noted and reflected in the new version. What's the Haskell name for () again? I fear explaining the exact type information of IO () may be too much for a brief introduction to Haskell to cover. > s/ommitted/omitted/ > Noted and reflected in the new version. > You've got an unusual indentation scheme. Consider adopting a more standard > one for your tutorial. > I'm in the camp of hard tabs rather than soft tabs, and that preference is probably responsible for much of the difference in indentation scheme. Unfortunately, HTML is terrible at representing hard tabs in
 code
with a custom width preference; they all come out looking like some idiot
pressed space bar eight times. I could use JavaScript to remedy this, but
for now, I like to directly copy and paste my working code from .HS files
into 
 tags just in case.

If tabs are *not* the issue, then maybe I'm not indenting far enough to the
right for some tastes? Or maybe it's my tendency to put "where" on its own
line, something a Perl obfuscater would detest. I dunno. If someone would
suggest a more idiomatic indentation scheme for my code so that I know
exactly what is different, I can take a look.


> In general, monotonically decreasing is not sufficient to prove you will
> hit
> a base case. For example, decreasing by 5 would still be monotonically
> decreasing, and could jump right over your base cases.
> (Not arguing that the code is incorrect, but rather than your explanation
> is
> a little misleading/incomplete.)
>

Understood. Noted and reflected in the new version.

Incidentally, when will Nat be available in Haskell? The Fibonacci
algorithm is designed to work only over natural numbers, and the best way
to express this in the type system is with Nat. But this type doesn't seem
available out-of-the-box for Haskell users. Unless I'm using my Haskell
Platform (GHC 7.0.3) is slightly outdated. Eh?


> Again, further confusion about what memoization really is.
>
>
> Under Records
>
> "Functions are already defined by their data structures; they are already
> semantically bundled..." doesn't seem to make sense.
>

Noted and reflected... I'm trying to convey to an audience largely composed
of Java and C++ fanatics how Haskell records are much better than OOP, how
GADTs are more intuitive, robust, ... OOP doesn't even compare! That's what
I'm trying to get across in that bit. And it's hard to do this in just a
few sentences, especially when the reader isn't even familiar with GADTs in
the first place.

"... acts on the specific constructor, blasting fools, murdering crowds..."
> makes it sound like fireOn actually has side effects.
>

A truly fair point. Would you like to contribute a monad for blowing up the
moon?

Another comment:


> "As a declarative language, Haskell manipulates expressions, eventually
> reducing expressions to values."


> Huh? In what sense do declarative languages manipulate expressions? Sounds
> like a classic syntax/semantics confusion, especially when interpreters
> and/or lazy evaluation (implementation issues, not language properties) are
> in the mix.


Noted and reflected in the new version.

I'm trying to introduce the concept of declarative programming as opposed
to imperative programming. Declarative programming according to
Wikipedia
:

is a programming paradigm that expresses the logic of a computation without
> describing its control flow.


I believe this is done in Haskell and other declarative languages by
treating code as manipulable, reducible expressions, where imperative
languages would use machine instructions.

---

Now, besides the code and the description of the code, I know we're not
English majors, but what do you think of the overall tone, pacing, etc.? Is
it entertaining? Is it humorous? Is it boring? Is it offensive? Is it too
brief or too laborious?

Thanks all for your suggestions.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From trebla at vex.net  Sat Sep 15 00:33:50 2012
From: trebla at vex.net (Albert Y. C. Lai)
Date: Fri, 14 Sep 2012 18:33:50 -0400
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
Message-ID: <5053B0CE.5060206@vex.net>

On 12-09-14 05:18 PM, Andrew Pennebaker wrote:
> One thing I want to double check is that Haskell does, in fact,
> automatically memoize all pure function calls. Is this true?

A simple back-of-envelope calculation that immediately raises doubts:

2 seconds on a 2 GHz computer is 4x10^9 clock cycles, or something 
between 10^9 to 4x10^9 steps. This sounds more like 2^30 recursive calls 
to fib, not 30. Even with interpreter inefficiency.

A simple experiment to nail the coffin:

Experiment #1:

fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib n = fib (n - 1) + fib (n - 2)

main :: IO ()
main = mapM_ (print . fib) (replicate 10 30)

Null hypothesis: fibs are memoized, therefore the first printing takes 2 
seconds, the remaining 9 printings are free.
Alternative hypothesis: fibs are not memoized, therefore every printing 
takes 2 seconds.
Observation: ______________________
Which hypothesis to reject: _______

A few advanced experiments to mess with your mind:

Experiment #2:

fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib n = fib (n - 1) + fib (n - 2)

main :: IO ()
main = let y = fib 30 in mapM_ print (replicate 10 y)

Question: Is anything memoized here? Which thing?

Experiment #3:

fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib n = fib (n - 1) + fib (n - 2)

main :: IO ()
main = mapM_ print (replicate 10 (fib 30))

Question: is this like #1? or is this like #2?

Experiment #4:

fib :: Int -> Int
fib n = mem !! n

mem :: [Int]
mem = map aux [0..]
-- remark: even [Int] is not a very efficient data structure for this

aux 0 = 0
aux 1 = 1
aux n = mem!!(n-1) + mem!!(n-2)

main :: IO ()
main = mapM_ (print . fib) (replicate 10 30)

Question: How fast is this compared to #1? Why?

Final remark: Evil geniuses should use the scientific method, not the 
opinionative method.


From alex at stangl.us  Sat Sep 15 01:06:19 2012
From: alex at stangl.us (Alex Stangl)
Date: Fri, 14 Sep 2012 18:06:19 -0500
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
Message-ID: <20120914230619.GA39527@scout.stangl.us>

On Fri, Sep 14, 2012 at 05:18:24PM -0400, Andrew Pennebaker wrote:
> A summary of the changes I've included so far:
> > Under Declarative, you aren't creating a "named expression, 2 + 2", really.
> > You are redefining (+).
> Noted and reflected in the new version.

It may not be obvious to readers when you are putting (+) or fib in the
let clause, that you are shadowing the function in the outer scope, so
for example, a reader might be surprised at the results of trying
let 2 + 2 = 5 in 1 + 1
(or similar experiments with your "memoized" fib)

It's not clear whether you believe you are only overriding behavior for
the specific case of 2 + 2, or if you realize that you've completely
redefined (+).


> Noted and reflected in the new version. After several comments to this
> effect, I do not want to misrepresent memoization in the tutorial.
> Sometimes it is useful to be slightly inaccurate in a tutorial in order to
> help bridge the gap between someone with no experience in a something vs
> the wealth of knowledge and complexity in the thing itself. This is not one
> of those times, and fortunately, fixing the misrepresentation in my
> tutorial is as easy as removing the hardcoded call.
> 
> One thing I want to double check is that Haskell does, in fact,
> automatically memoize all pure function calls. Is this true?

Generally you store the memoized results in some structure list a list
or array defined at the top level. You don't get "automatic"
memoization, nor would it be desirable since it would quickly fill
memory with memoized results of every function call, unless it could
intelligently gauge which ones to keep around. Check out the memoization
section of the Haskell wiki for more info.


> I would still like to provide a performance comparison of the Fibonacci
> code with and without memoization, for readers who enjoy numerical
> evidence, using the Unix "time" command, but I don't know how to turn
> memoization off. I guess I would have to reimplement the algorithm in a way
> that can't make use of memoization. Any suggestions?

See above. Off is default -- you need to add an array to get the
memoization. The array can be initialized with the lazy list of fibs,
which in turn rely upon the array itself to retrieve memoized values.
Downside to this approach is you need to define your array bounds
upfront. Alternately, you could memoize more simply (and w/o bounds)
by putting the values into a top-level list, however the values get
more expensive to access, the deeper they are in the list.


> Under Infinite, you should use "sieve (n:ns)" pattern matching instead of
> > calling head.
> Thank you! I try to make use of Haskell pattern matching wherever I can.
> Since I needed to refer to the whole list, as well as the head and tail, I
> originally used "head" instead of pattern matching. Noted and reflected in
> the new version.

Are you aware you can use an "as pattern" (e.g., nl@(n:ns)) so you can
refer to the whole list as nl when you like, but still have destructured
as well?


> > Under Type-Safe
> > Subtle distinction, but returning () is not the same as returning nothing
> > at all.
> True. Noted and reflected in the new version. What's the Haskell name for
> () again? I fear explaining the exact type information of IO () may be too
> much for a brief introduction to Haskell to cover.

() is called unit.


> > You've got an unusual indentation scheme. Consider adopting a more standard
> > one for your tutorial.
> I'm in the camp of hard tabs rather than soft tabs, and that preference is
> probably responsible for much of the difference in indentation scheme.
> Unfortunately, HTML is terrible at representing hard tabs in 
 code
> with a custom width preference; they all come out looking like some idiot
> pressed space bar eight times. I could use JavaScript to remedy this, but
> for now, I like to directly copy and paste my working code from .HS files
> into 
 tags just in case.
> 
> If tabs are *not* the issue, then maybe I'm not indenting far enough to the
> right for some tastes? Or maybe it's my tendency to put "where" on its own
> line, something a Perl obfuscater would detest. I dunno. If someone would
> suggest a more idiomatic indentation scheme for my code so that I know
> exactly what is different, I can take a look.

Unless the lines get too long, you'd usually see something like:
     do args <- getArgs
        fcontents <- readFile (head args)
        ...
        putStrLn results


By the way, your fib.hs (extended) is still in poor form, showing up to
fib 30 hardwired. Generally you would just hardwire your first one or two
values to "seed" your computation, like the first two Fibonacci numbers,
or first prime, etc., and then any memoization is accomplished as
described above, using some array or other structure to hold previously
computed values.


> Incidentally, when will Nat be available in Haskell?

Don't know, sorry.


> The Fibonacci
> algorithm is designed to work only over natural numbers, and the best way
> to express this in the type system is with Nat. But this type doesn't seem
> available out-of-the-box for Haskell users.

It's not unusual for a function to be partially defined this way. You
could equally well express the Fibonacci (or any) sequence as an
infinite list. You can only use non-negative values for your list
lookup, so if you view this as a deficiency, then the ubiquitous list
shares the same deficiency.


> Noted and reflected... I'm trying to convey to an audience largely composed
> of Java and C++ fanatics how Haskell records are much better than OOP, how
> GADTs are more intuitive, robust, ... OOP doesn't even compare! That's what
> I'm trying to get across in that bit. And it's hard to do this in just a
> few sentences, especially when the reader isn't even familiar with GADTs in
> the first place.

I meant to also mention in my previous email, your section on Records
doesn't actually deal with what the Haskell community considers
records (e.g., algebraic datatype with labelled fields.) You're just
using a simple algebraic datatype, so it'd be better not to call it a
record, as that's bound to lead to confusion.


> Now, besides the code and the description of the code, I know we're not
> English majors, but what do you think of the overall tone, pacing, etc.? Is
> it entertaining? Is it humorous? Is it boring? Is it offensive? Is it too
> brief or too laborious?

Very subjective, but the "evil genius" thing doesn't work for me. I like
the "launch missiles" analogy when discussing side-effects, but I don't
care for it as the entire basis to wind a tutorial around. It is
humorous, not boring. I find the pacing OK, but it's hard for me to put
myself into the mindset of somebody encountering the material for the
first time. Putting an appropriate quote under headings is a nice
touch.

Alex


From andrew.pennebaker at gmail.com  Sat Sep 15 01:35:36 2012
From: andrew.pennebaker at gmail.com (Andrew Pennebaker)
Date: Fri, 14 Sep 2012 19:35:36 -0400
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: <5053B0CE.5060206@vex.net>
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	<5053B0CE.5060206@vex.net>
Message-ID: 

>
> Experiment #4:
>
> fib :: Int -> Int
> fib n = mem !! n
>
> mem :: [Int]
> mem = map aux [0..]
> -- remark: even [Int] is not a very efficient data structure for this
>
> aux 0 = 0
> aux 1 = 1
> aux n = mem!!(n-1) + mem!!(n-2)
>
> main :: IO ()
> main = mapM_ (print . fib) (replicate 10 30)
>
> Question: How fast is this compared to #1? Why?
>

Final remark: Evil geniuses should use the scientific method, not the
> opinionative method.


Noted and reflected in the new version.

Thank you for taking the time to write out a detailed, practical analysis
of the question. Yes, I should assume less and test more. I tried
these outas
requested, and came up with results demonstrating that Haskell, does
not, as I mistakenly interpreted, automatically memoize all function calls.
Which makes sense, otherwise memory would quickly run out.

I found some useful reference code on the Haskell Wiki and constructed my
own memoized Fibonacci function using the MemoTrie library, which,
fortunately, is builtin with Haskell Platform and therefore does not
require the tutorial reader to install additional code.

The new version of the tutorial includes an ordinary recursive Fibonacci
function (fib1.hs), and the same code but renamed to fib', memoized using
the memo function from the MemoTrie library (fib2.hs), and exposed as fib.
Unix time information provides real numbers for comparison: The memoized
version is clearly much faster.

I rewrote the section, deleting the part that stated memoization was
automatic, and added text describing how Haskell makes memoization easy.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From corentin.dupont at gmail.com  Sat Sep 15 01:46:13 2012
From: corentin.dupont at gmail.com (Corentin Dupont)
Date: Sat, 15 Sep 2012 01:46:13 +0200
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
Message-ID: 

Well, to make it short, I liked it!
As suggestions, little things like first class functions and partial
application can be easily introduced.
For example the line:
map (+1) [1..10]
contains these concepts and it very short and expressive.

On the story side, why not introducing a character? This would help
personalize the story. It would be nice if a real story is told also,
beside the Haskell story, like a character building something or making a
(evil) journey learning Haskell.

Cheers,
Corentin


On Fri, Sep 14, 2012 at 11:18 PM, Andrew Pennebaker <
andrew.pennebaker at gmail.com> wrote:

> A summary of the changes I've included so far:
>
>
>> Under Declarative, you aren't creating a "named expression, 2 + 2",
>> really.
>> You are redefining (+).
>>
>>
> Noted and reflected in the new version.
>
>
>> Under Lazy, your example of binding fib 30 is not a good example of
>> memoization. With memoization you typically call the underlying
>> computation
>> the first time, and memoize it for repeated retrieval later, not hardwire
>> in
>> values at compile time. Here you never ever call the real fib at all. On
>> top
>> of everything else, it'd be too easy to introduce a typo into one of your
>> hardwired constant values.
>>
>>
> Noted and reflected in the new version. After several comments to this
> effect, I do not want to misrepresent memoization in the tutorial.
> Sometimes it is useful to be slightly inaccurate in a tutorial in order to
> help bridge the gap between someone with no experience in a something vs
> the wealth of knowledge and complexity in the thing itself. This is not one
> of those times, and fortunately, fixing the misrepresentation in my
> tutorial is as easy as removing the hardcoded call.
>
> One thing I want to double check is that Haskell does, in fact,
> automatically memoize all pure function calls. Is this true?
>
> I would still like to provide a performance comparison of the Fibonacci
> code with and without memoization, for readers who enjoy numerical
> evidence, using the Unix "time" command, but I don't know how to turn
> memoization off. I guess I would have to reimplement the algorithm in a way
> that can't make use of memoization. Any suggestions?
>
> Under Infinite, you should use "sieve (n:ns)" pattern matching instead of
>> calling head.
>>
>
> Thank you! I try to make use of Haskell pattern matching wherever I can.
> Since I needed to refer to the whole list, as well as the head and tail, I
> originally used "head" instead of pattern matching. Noted and reflected in
> the new version.
>
>
>> Under Type-Safe
>> Subtle distinction, but returning () is not the same as returning nothing
>> at all.
>>
>
> True. Noted and reflected in the new version. What's the Haskell name for
> () again? I fear explaining the exact type information of IO () may be too
> much for a brief introduction to Haskell to cover.
>
>
>> s/ommitted/omitted/
>>
>
> Noted and reflected in the new version.
>
>
>> You've got an unusual indentation scheme. Consider adopting a more
>> standard
>> one for your tutorial.
>>
>
> I'm in the camp of hard tabs rather than soft tabs, and that preference is
> probably responsible for much of the difference in indentation scheme.
> Unfortunately, HTML is terrible at representing hard tabs in 
 code
> with a custom width preference; they all come out looking like some idiot
> pressed space bar eight times. I could use JavaScript to remedy this, but
> for now, I like to directly copy and paste my working code from .HS files
> into 
 tags just in case.
>
> If tabs are *not* the issue, then maybe I'm not indenting far enough to
> the right for some tastes? Or maybe it's my tendency to put "where" on its
> own line, something a Perl obfuscater would detest. I dunno. If someone
> would suggest a more idiomatic indentation scheme for my code so that I
> know exactly what is different, I can take a look.
>
>
>> In general, monotonically decreasing is not sufficient to prove you will
>> hit
>> a base case. For example, decreasing by 5 would still be monotonically
>> decreasing, and could jump right over your base cases.
>> (Not arguing that the code is incorrect, but rather than your explanation
>> is
>> a little misleading/incomplete.)
>>
>
> Understood. Noted and reflected in the new version.
>
> Incidentally, when will Nat be available in Haskell? The Fibonacci
> algorithm is designed to work only over natural numbers, and the best way
> to express this in the type system is with Nat. But this type doesn't seem
> available out-of-the-box for Haskell users. Unless I'm using my Haskell
> Platform (GHC 7.0.3) is slightly outdated. Eh?
>
>
>> Again, further confusion about what memoization really is.
>>
>>
>> Under Records
>>
>> "Functions are already defined by their data structures; they are already
>> semantically bundled..." doesn't seem to make sense.
>>
>
> Noted and reflected... I'm trying to convey to an audience largely
> composed of Java and C++ fanatics how Haskell records are much better than
> OOP, how GADTs are more intuitive, robust, ... OOP doesn't even compare!
> That's what I'm trying to get across in that bit. And it's hard to do this
> in just a few sentences, especially when the reader isn't even familiar
> with GADTs in the first place.
>
> "... acts on the specific constructor, blasting fools, murdering crowds..."
>> makes it sound like fireOn actually has side effects.
>>
>
> A truly fair point. Would you like to contribute a monad for blowing up
> the moon?
>
> Another comment:
>
>
>> "As a declarative language, Haskell manipulates expressions, eventually
>> reducing expressions to values."
>
>
>> Huh? In what sense do declarative languages manipulate expressions?
>> Sounds like a classic syntax/semantics confusion, especially when
>> interpreters and/or lazy evaluation (implementation issues, not language
>> properties) are in the mix.
>
>
> Noted and reflected in the new version.
>
> I'm trying to introduce the concept of declarative programming as opposed
> to imperative programming. Declarative programming according to Wikipedia
> :
>
> is a programming paradigm that expresses the logic of a computation
>> without describing its control flow.
>
>
> I believe this is done in Haskell and other declarative languages by
> treating code as manipulable, reducible expressions, where imperative
> languages would use machine instructions.
>
> ---
>
> Now, besides the code and the description of the code, I know we're not
> English majors, but what do you think of the overall tone, pacing, etc.? Is
> it entertaining? Is it humorous? Is it boring? Is it offensive? Is it too
> brief or too laborious?
>
> Thanks all for your suggestions.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From alex.solla at gmail.com  Sat Sep 15 01:47:51 2012
From: alex.solla at gmail.com (Alexander Solla)
Date: Fri, 14 Sep 2012 16:47:51 -0700
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
Message-ID: 

On Fri, Sep 14, 2012 at 2:18 PM, Andrew Pennebaker <
andrew.pennebaker at gmail.com> wrote:

> A summary of the changes I've included so far:
>
> Noted and reflected... I'm trying to convey to an audience largely
> composed of Java and C++ fanatics how Haskell records are much better than
> OOP, how GADTs are more intuitive, robust, ... OOP doesn't even compare!
> That's what I'm trying to get across in that bit. And it's hard to do this
> in just a few sentences, especially when the reader isn't even familiar
> with GADTs in the first place.
>

But, Haskell records aren't better than OOP.

I am not trying to be controversial here -- Haskell records would
"naturally" implement prototype-based OOP, like JavaScript uses, if they
(Haskell records) weren't so useless.  This is basically why "lenses" were
designed (i.e., to make consistent syntax for getters and setters)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From andrew.pennebaker at gmail.com  Sat Sep 15 02:23:42 2012
From: andrew.pennebaker at gmail.com (Andrew Pennebaker)
Date: Fri, 14 Sep 2012 20:23:42 -0400
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	
Message-ID: 

>
> But, Haskell records aren't better than OOP.
>
> I am not trying to be controversial here -- Haskell records would
> "naturally" implement prototype-based OOP, like JavaScript uses, if they
> (Haskell records) weren't so useless.  This is basically why "lenses" were
> designed (i.e., to make consistent syntax for getters and setters)
>

Hey, I don't want the tutorial to be controversial either, especially since
my word choice of words like "better" are highly subjective. I find
it extraordinarily empowering that Haskell's type system allows programmers
to use a wide variety of programming paradigms: functional, declarative,
imperative, lazy, eager, parallel, quantum, matrix, CUDA, multithreaded,
distributed, logical, object oriented...

When I describe Haskell's type system as better than OOP, what I mean is
this: You can code OOP in Haskell, because the type system can adapt to
that. But it's much harder to go the other way, trying to code GADTs in
Java/C++. In order to get the effect, you'll have to code something as
complex as Scala, at which point you might as well just use Haskell (unless
you really really really need the JVM for compatibility). It's the same
with Lisp or JavaScript or Smalltalk or Ruby: Allowing the programmer to
roll his own paradigm, such as OOP, is more powerful than offering only
that paradigm. More to the point, the monad system enables all of this, and
I'm not sure how to reword this tutorial to reflect that; monads themselves
are generally treated as an advanced lesson, and this one tries to hit the
ground running.

Does anyone know of a brief introductory Haskell tutorial that engages
monads? LYAH covers monads, but it does so after a few chapters of simpler,
pure function Haskell coding. I know of some brief tutorials for monads
that explain them in a variety of creative ways, but they all assume the
reader is at least somewhat familiar with Haskell.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From krismicinski at gmail.com  Sat Sep 15 02:56:36 2012
From: krismicinski at gmail.com (Kristopher Micinski)
Date: Fri, 14 Sep 2012 20:56:36 -0400
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	
	
Message-ID: 

On Fri, Sep 14, 2012 at 8:23 PM, Andrew Pennebaker
 wrote:
> [snip..]
> Does anyone know of a brief introductory Haskell tutorial that engages
> monads? LYAH covers monads, but it does so after a few chapters of simpler,
> pure function Haskell coding. I know of some brief tutorials for monads that
> explain them in a variety of creative ways, but they all assume the reader
> is at least somewhat familiar with Haskell.

My opinion: you are walking down the potentially disastrous road of
trying to introduce monads in as small a tutorial as yours.  If the
person reading the tutorial is *indeed* an evil genius, I'd at least
start by showing an example of a monad that wasn't a disingenuous
presentation of their full capabilities (I'm taking a long cold stare
at  the people who write tutorials that say "hey, Maybe is a monad,
and Maybe is simple, so monads a pretty simple too!"), like the Cont
monad.  But, you say, "hell, Cont has quite a complex set of things
going on!"  And I say, yes, it's sufficiently complicated to force
people to work out the underlying details.

(As a side note, I've had an itching feeling to introduce monads to
students via having them write an interpreter and presenting it by
proxy of state based semantics in something of the spirit of Imp.)

Monads are a complex subject, not overly complex, I would say "they
let you chain things together and hide behavior under the rug," but
even this isn't helpful to someone to hasn't seen them before.  So my
argument is that if you introduce monads, you do so with a great
example that demonstrates a nontrivial monad (State or Cont, *not*
Maybe or IO).  This is a case where forcing people to work out the
math is imperative (hehe, get it, it's a pun..), programmers' natural
tendency when they see IO examples is to say "oh hey, I'll just copy
that pattern, and that's how you do IO," where in reality this doesn't
showcase everything monads really do.

If you want to *link* to some good tutorials, I think that reading the
"All about monads" tutorial is a great way to learn Haskell, period.

Everyone in the Haskell cafe probably has a secret dream to give the
best "five minute monad talk."  Challenge: get someone to have a
competition at one of the conferences where students all give their
best "five minute monad talk" and try to find the most comprehensible
one!

Perhaps that was a bit of a rant, apologies if so,

kris


From andrew.pennebaker at gmail.com  Sat Sep 15 03:08:27 2012
From: andrew.pennebaker at gmail.com (Andrew Pennebaker)
Date: Fri, 14 Sep 2012 21:08:27 -0400
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	
	
	
Message-ID: 

>
> Everyone in the Haskell cafe probably has a secret dream to give the
> best "five minute monad talk."  Challenge: get someone to have a
> competition at one of the conferences where students all give their
> best "five minute monad talk" and try to find the most comprehensible
> one!
>

Haha, maybe that's why I'm writing.

Agree on all points, not just this quotation.

Yeah, IO and Maybe are the first monads most new Haskell programmers
encounter.  Perhaps a tour of RVars or the accelerate library would give a
better impression. I bet a lot of students get the concept of pure
functional programming, and if you shock them with: "So how would you
implement a PRNG?", they would understand the role monads play.

Given that Maybe and Either don't modify state, nor do they communicate
with outside interfaces, nor do they specify computation ordering, I don't
understand why they're implemented as monads. Why not a primitive typeclass
or even datatype declaration?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From allbery.b at gmail.com  Sat Sep 15 03:22:55 2012
From: allbery.b at gmail.com (Brandon Allbery)
Date: Fri, 14 Sep 2012 21:22:55 -0400
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	
	
	
	
Message-ID: 

On Fri, Sep 14, 2012 at 9:08 PM, Andrew Pennebaker <
andrew.pennebaker at gmail.com> wrote:

> Given that Maybe and Either don't modify state, nor do they communicate
>> with outside interfaces, nor do they specify computation ordering, I don't
>> understand why they're implemented as monads. Why not a primitive typeclass
>> or even datatype declaration?
>
>
They're not used in their monadic guise as often as they should be, IMO.
 Either String has for a while been an "error monad" (more commonly,
EitherT String as ErrorT) but has annoying shortcomings --- but they're an
obvious mechanism for reporting and tracking / short-circuiting failure in
computations (carrying a failure reason in the case of Either).

-- 
brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From joelburget at gmail.com  Sat Sep 15 04:08:29 2012
From: joelburget at gmail.com (Joel Burget)
Date: Fri, 14 Sep 2012 19:08:29 -0700
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	
	
	
	
Message-ID: <0C9308961819430285C7874293BA30EE@gmail.com>

I find the Monad instance for Maybe and Either very useful. You can do things like the following (which technically only uses the Applicative instance):

Prelude Control.Applicative> (*3) <$> (+2) <$> Just 1
Just 9
Prelude Control.Applicative> (*3) <$> (+2) <$> Nothing
Nothing
Prelude Control.Applicative> (*3) <$> (+2) <$> Left "error" :: Either String Int
Left "error"
Prelude Control.Applicative> (*3) <$> (+2) <$> Right 1 :: Either String Int
Right 9



Also, Maybe and Either are not "implemented as monads". They are defined using `data` like you suggest:

data Maybe a = Nothing | Just a
data Either a b = Left a | Right b

You can even look up their definitions using ghci using `:i Either` or `:i Maybe`. Monad comes in because they're both instances of the Monad type class.

Take a look at the list monad for another one that doesn't modify state or communicate with an outside interface.

- Joel 

On Friday, September 14, 2012 at 6:08 PM, Andrew Pennebaker wrote:

> > Everyone in the Haskell cafe probably has a secret dream to give the
> > best "five minute monad talk."  Challenge: get someone to have a
> > competition at one of the conferences where students all give their
> > best "five minute monad talk" and try to find the most comprehensible
> > one!
> 
> Haha, maybe that's why I'm writing.
> 
> Agree on all points, not just this quotation.
> 
> Yeah, IO and Maybe are the first monads most new Haskell programmers encounter.  Perhaps a tour of RVars or the accelerate library would give a better impression. I bet a lot of students get the concept of pure functional programming, and if you shock them with: "So how would you implement a PRNG?", they would understand the role monads play. 
> 
> Given that Maybe and Either don't modify state, nor do they communicate with outside interfaces, nor do they specify computation ordering, I don't understand why they're implemented as monads. Why not a primitive typeclass or even datatype declaration? 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org (mailto:Haskell-Cafe at haskell.org)
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From andrew.pennebaker at gmail.com  Sat Sep 15 04:13:53 2012
From: andrew.pennebaker at gmail.com (Andrew Pennebaker)
Date: Fri, 14 Sep 2012 22:13:53 -0400
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	
	
	
Message-ID: 

>
> Challenge: get someone to have a competition at one of the conferences
> where students all give their
> best "five minute monad talk" and try to find the most comprehensible one!
>

Challenge accepted .
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From oleg at okmij.org  Sat Sep 15 13:02:01 2012
From: oleg at okmij.org (oleg at okmij.org)
Date: 15 Sep 2012 11:02:01 -0000
Subject: [Haskell-cafe] Transforming a ADT to a GADT
Message-ID: <20120915110201.49794.qmail@www1.g3.pair.com>


Florian Lorenzen wrote:
> Now, I'd like to have a function
> > typecheck :: Exp -> Maybe (Term t) 
> > typecheck exp = <...>
> that returns the GADT value corresponding to `exp' if `exp' is type
> correct.

Let us examine that type:
	typecheck :: forall t. Exp -> Maybe (Term t) 

Do you really mean that given expression exp, (typecheck exp) should
return a (Maybe (Term t)) value for any t whatsoever? In other words,
you are interested in a type-*checking* problem: given an expression _and_
given a type, return Just (Term t) if the given expression has the given
type. Both expression and the type are the input. Incidentally, this
problem is like `read': we give the read function a string
and we should tell it to which type to parse. If that is what you
mean, then the solution using Typeable will work (although you may
prefer avoiding Typeable -- in which case you should build type
witnesses on your own).


> that returns the GADT value corresponding to `exp' if `exp' is type
> correct.
Your comment suggests that you mean typecheck exp should return
(Just term) just in case `exp' is well-typed, that is, has _some_
type. The English formulation of the problem already points us towards 
an existential. The typechecking function should return (Just term)
and a witness of its type:

	typecheck :: Exp -> Sigma (t:Type) (Term t)

Then my
> data TypedTerm = forall ty. (Typ ty) (Term ty)

is an approximation of the Sigma type. As Erik Hesselink rightfully
pointed out, this type does not preclude type transformation
functions. Indeed you have to unpack and then repack. If you 
want to know the concrete type, you can pattern-match on the type
witness (Typ ty), to see if the inferred type is an Int, for example.


Chances are that you wanted the following

	typecheck :: {e:Exp} -> Result e
where Result e has the type (Just (Term t)) (with some t dependent on
e) if e is typeable, and Nothing otherwise. But this is a dependent
function type (Pi-type). No wonder we have to go through contortions
like Template Haskell to emulate dependent types in Haskell. Haskell
was not designed to be a dependently-typed language.



From t at tmh.cc  Sat Sep 15 16:20:26 2012
From: t at tmh.cc (Taylor Hedberg)
Date: Sat, 15 Sep 2012 10:20:26 -0400
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: <0C9308961819430285C7874293BA30EE@gmail.com>
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	
	
	
	
	<0C9308961819430285C7874293BA30EE@gmail.com>
Message-ID: <20120915142026.GN18179@euporie.thebe.ath.cx>

Joel Burget, Fri 2012-09-14 @ 19:08:29-0700:
> I find the Monad instance for Maybe and Either very useful. You can do
> things like the following (which technically only uses the Applicative
> instance):
> 
> Prelude Control.Applicative> (*3) <$> (+2) <$> Just 1
> Just 9
> Prelude Control.Applicative> (*3) <$> (+2) <$> Nothing
> Nothing
> Prelude Control.Applicative> (*3) <$> (+2) <$> Left "error" :: Either String Int
> Left "error"
> Prelude Control.Applicative> (*3) <$> (+2) <$> Right 1 :: Either String Int
> Right 9

Nitpick: You are using the Functor instances of Maybe and Either here,
not Applicative. (<$>) == fmap; it just happens to be defined in the
Control.Applicative module.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: 

From simon at joyful.com  Sat Sep 15 16:36:30 2012
From: simon at joyful.com (Simon Michael)
Date: Sat, 15 Sep 2012 07:36:30 -0700
Subject: [Haskell-cafe] ANN: darcsden-1.0
Message-ID: <69CEE391-C6C0-406E-9DC5-C8851537956C@joyful.com>

I'm pleased to announce the release of darcsden 1.0!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
darcsden is a web application for browsing and managing darcs repositories                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
(and issue trackers, and their owners), and an SSH server which lets users                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
push changes to the app without needing a full system login. It can be                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
used for browsing your local repositories, for publishing your repos on                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
the web, or for running a public repo hosting site. It is available under                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
the BSD license.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
darcsden was created by Alex Suraci. The last release was 0.5, in 2010.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
I've been tinkering with it and using it to publish repos on my site for a                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
while. In recent months, with help from the Darcs community I made a                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
serious attempt to make it more robust and to run a reliable instance at                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
http://hub.darcs.net , with promising results. Alex and I feel this is a                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
good time to release an official darcsden 1.0, containing hub's                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
reliability/functionality updates (but not the UI style tweaks).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
Home: http://hackage.haskell.org/package/darcsden                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
Release notes:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
--------------                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
Changes in this release fall into several themes:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
Deployability/Hackability                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * dependencies have been updated; darcsden now uses the latest GHC,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
    darcs and snap                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * cabal build flags have been added:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
    - darcs28: build with released darcs 2.8.2+ instead of latest                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
      darcs-screened ? default: true                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
    - ssh, closing, highlighting: build the ssh server, issue-closing                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
      script, and highlighting features ? default: true (disable these                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
      for easier building on windows)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * settings allowing easier custom deployment are available in                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    src/DarcsDen/Settings.hs: base hostname, path and URL, home link,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
    front page content, root directory, log files, maximum request time,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
    maximum displayable patch/file size, database hosts/ports, etc.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * the db setup required for issue trackers has been added                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * the register form has a security question to reduce junk signups                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * issue trackers can be enabled/disabled per-repo                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * a robots.txt file has been added (default: allow all bots)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * non-content pages now have NOINDEX meta tag to discourage search                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
    indexing                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * user repos and log files have moved to subdirectories for easier                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
    management                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * a makefile has been added for developer convenience                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
Reliability                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * error messages are more user-friendly                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * intermittent browsing errors and eventual stylesheet loss due to                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
    non-thread-safe working directory in libdarcs have been fixed                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * viewing a patch or file with binary data no longer gives an error                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * patch content larger than 200K is elided, avoiding some timeouts                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * viewing a patch shows the page right away and fetches the patch data                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    asynchronously, with a more friendly message if it times out                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * viewing a non-existent patch id shows a 404 instead of an exception                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * source code highlighting is faster (using highlighting-kate); viewing                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    a complex file (like minified jquery.js) no longer times out                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * the error-prone repo bootstrap feature has been dropped                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * patch author names are now replaced with user links reliably (when the                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    email address matches)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * repo links now work when the current url ends in /                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * . (period) is supported in repo names                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * merge now redirects properly when it completes                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * the login button in the issue tracker now works                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * private repos are now listed for their owners                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * private repos are no longer darcs gettable by non-owners                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * patch author names now link to local users and hide email addresses                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    reliably                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * input fields now accept at most 1000 characters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * ssh access now supports DSA public keys                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
Usability                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * the site favicon now works in Chrome                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * the register form now disables browser autofill and is readable in                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
    Chrome                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * navigation buttons are clearer and more context-sensitive                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * the front page remains accessible after login                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * users are listed on the front page                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * repos are listed alphabetically                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * page headings are more consistent when browsing files                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * files view displays directory names in bold                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * when viewing file content, long lines now use all space to window edge                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * all markdown files are now rendered as markdown, not just README                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * the patches view has been renamed branches, and shows all related                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    repos including upstream                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * merging patches can now also be done by repo members                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * pagination controls also appear at the top and have a stable layout                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
    for easy clicking                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * patch view lists files alphabetically                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * patch view now also displays added/removed file content                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * all issues, closed issues views have been added                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * code blocks on issue pages no longer overflow their background                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * list styles have been improved in markdown                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
  * button transition, border radius and box shadow styles have been                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
    updated for modern browsers                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
Credits:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
--------                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
Alex Suraci created darcsden. Simon Michael led this release, with help                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
from Ganesh Sittampalam, Guillaume Hoffmann, Niklas Haas, Daniel                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
Patterson, Owen Stephens and Scott Lawrence.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
darcsden depends on Darcs, Snap, GHC, and the rest of the Haskell                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
ecosystem.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
Contributing:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
-------------                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
I think darcsden fills a strategic niche in the Darcs ecosystem and                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
deserves wider use and more active development. It has a small, clean                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
codebase and is fun to hack on, not least because (if you contribute to                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
hub's darcsden branch) useful changes will quickly be deployed at                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
hub.darcs.net, providing a tight dogfooding/feedback loop. Here's how to                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
contribute a patch there:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
- register at hub.darcs.net, add your ssh key in settings                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
- fork http://hub.darcs.net/simon/darcsden                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
- darcs get http://hub.darcs.net/yourname/darcsden                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
- (edit, record)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
- darcs push yourname at hub.darcs.net:darcsden                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
- your change appears at http://hub.darcs.net/simon/darcsden/patches ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  ping me by IRC or email to merge it                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
Best,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
-Simon, Alex and the Darcs team                          

From simon at joyful.com  Sat Sep 15 17:09:02 2012
From: simon at joyful.com (Simon Michael)
Date: Sat, 15 Sep 2012 08:09:02 -0700
Subject: [Haskell-cafe] readable version (ANN: darcsden-1.0, hub.darcs.net)
In-Reply-To: <69CEE391-C6C0-406E-9DC5-C8851537956C@joyful.com>
References: <69CEE391-C6C0-406E-9DC5-C8851537956C@joyful.com>
Message-ID: 

Email.. advanced alien technology that some day I will master.
Here are more readable versions:

http://hub.darcs.net/simon/darcsden-1.0/browse/ANNOUNCE.md

http://hub.darcs.net/simon/hub.darcs.net-conf/browse/ANNOUNCE.md



From krismicinski at gmail.com  Sat Sep 15 19:24:50 2012
From: krismicinski at gmail.com (Kristopher Micinski)
Date: Sat, 15 Sep 2012 13:24:50 -0400
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: <0C9308961819430285C7874293BA30EE@gmail.com>
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	
	
	
	
	<0C9308961819430285C7874293BA30EE@gmail.com>
Message-ID: 

On Fri, Sep 14, 2012 at 10:08 PM, Joel Burget  wrote:
> [snip]
>
> Also, Maybe and Either are not "implemented as monads". They are defined
> using `data` like you suggest:
>
> data Maybe a = Nothing | Just a
> data Either a b = Left a | Right b
>

That's not my point, or my objection.  My objection is to people who
present monads showing examples that begin with Maybe or Either, or
these 'trivial monads,' types onto which you can strip monadic
behavior fairly simply.  I'm not saying they're bad as monads, or
useless, but I think the step from Maybe as a datatype to using it as
a monad is great enough that explaining monads by way of introducing
them with Maybe as an example is sort of confusing because it
trivializes what's actually going on.

I'm honestly not sure what you mean by Maybe or Either being
"implemented as monads," versus others.  Monad is just a type class,
there's always an underlying type.  Perhaps you mean that people
actually *care* about things in Maybe outside of it being used as a
monad, versus other things where you don't touch the underlying type.

This isn't intended to start an argument, however, and I'd prefer not
to argue over methodology, I just wanted to throw out there that if
you say "monads, think about maybe, and add some stuff, then that's it
is, what's all the fuss about!?"  I think the hard part for people
understanding monads isn't the definition of monads, but rather that
you are forced to really tackle higher order behavior in a very direct
way.  (For example, say you're new to Haskell, you probably don't know
about CPS, and you read about Cont in a monad tutorial.  Is it the
monad that makes it hard?  No, it's probably the concept of CPS.)

kris


From krismicinski at gmail.com  Sat Sep 15 19:26:11 2012
From: krismicinski at gmail.com (Kristopher Micinski)
Date: Sat, 15 Sep 2012 13:26:11 -0400
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	
	
	
	
Message-ID: 

On Fri, Sep 14, 2012 at 10:13 PM, Andrew Pennebaker
 wrote:
>> Challenge: get someone to have a competition at one of the conferences
>> where students all give their
>> best "five minute monad talk" and try to find the most comprehensible one!
>
>
> Challenge accepted.
>

Great!  Maybe I'll try to write up a post on this challenge and put it
on my blog, and try to solicit responses from others too, perhaps
putting up a wiki page somewhere where people can post their attempts!

(By the way, I consider this hard, I'm not touting myself as having a
good solution for this, I'm genuinely interested in others'
responses!)

kris


From joelburget at gmail.com  Sat Sep 15 22:01:49 2012
From: joelburget at gmail.com (Joel Burget)
Date: Sat, 15 Sep 2012 13:01:49 -0700
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	
	
	
	
	<0C9308961819430285C7874293BA30EE@gmail.com>
	
Message-ID: 

Kris,

Sorry for the confusion, I wasn't directly addressing your post. I was trying to correct what I perceived as a misconception in the last paragraph of Andrew's message, beginning with "Given that?".

- Joel


On Saturday, September 15, 2012 at 10:24 AM, Kristopher Micinski wrote:

> On Fri, Sep 14, 2012 at 10:08 PM, Joel Burget  wrote:
> > [snip]
> >  
> > Also, Maybe and Either are not "implemented as monads". They are defined
> > using `data` like you suggest:
> >  
> > data Maybe a = Nothing | Just a
> > data Either a b = Left a | Right b
> >  
>  
>  
> That's not my point, or my objection. My objection is to people who
> present monads showing examples that begin with Maybe or Either, or
> these 'trivial monads,' types onto which you can strip monadic
> behavior fairly simply. I'm not saying they're bad as monads, or
> useless, but I think the step from Maybe as a datatype to using it as
> a monad is great enough that explaining monads by way of introducing
> them with Maybe as an example is sort of confusing because it
> trivializes what's actually going on.
>  
> I'm honestly not sure what you mean by Maybe or Either being
> "implemented as monads," versus others. Monad is just a type class,
> there's always an underlying type. Perhaps you mean that people
> actually *care* about things in Maybe outside of it being used as a
> monad, versus other things where you don't touch the underlying type.
>  
> This isn't intended to start an argument, however, and I'd prefer not
> to argue over methodology, I just wanted to throw out there that if
> you say "monads, think about maybe, and add some stuff, then that's it
> is, what's all the fuss about!?" I think the hard part for people
> understanding monads isn't the definition of monads, but rather that
> you are forced to really tackle higher order behavior in a very direct
> way. (For example, say you're new to Haskell, you probably don't know
> about CPS, and you read about Cont in a monad tutorial. Is it the
> monad that makes it hard? No, it's probably the concept of CPS.)
>  
> kris  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From conal at conal.net  Sat Sep 15 22:48:03 2012
From: conal at conal.net (Conal Elliott)
Date: Sat, 15 Sep 2012 13:48:03 -0700
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
Message-ID: 

On Fri, Sep 14, 2012 at 2:18 PM, Andrew Pennebaker wrote:

> A summary of the changes I've included so far:
> [...]
>
> Another comment:
>
>
>> "As a declarative language, Haskell manipulates expressions, eventually
>> reducing expressions to values."
>
>
>> Huh? In what sense do declarative languages manipulate expressions?
>> Sounds like a classic syntax/semantics confusion, especially when
>> interpreters and/or lazy evaluation (implementation issues, not language
>> properties) are in the mix.
>
>
> Noted and reflected in the new version.
>
> I'm trying to introduce the concept of declarative programming as opposed
> to imperative programming. Declarative programming according to Wikipedia
> :
>
> is a programming paradigm that expresses the logic of a computation
>> without describing its control flow.
>
>
> I believe this is done in Haskell and other declarative languages by
> treating code as manipulable, reducible expressions, where imperative
> languages would use machine instructions.
>

I'm struggling to find anything in this belief/opinion that I can relate
to. How did you come by it? What experiments can you perform to check
whether it's true or false? I second Albert Lai's recommendation to use the
scientific method.

Along these lines, I still see "Haskell manipulates reducible expressions,
eventually reducing them to values" in your tutorial, which again I suspect
comes from confusion between syntax & semantics and/or between meaning and
possible execution strategy.

Regards, - Conal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From alex.solla at gmail.com  Sun Sep 16 07:21:09 2012
From: alex.solla at gmail.com (Alexander Solla)
Date: Sat, 15 Sep 2012 22:21:09 -0700
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	
	
	
	
Message-ID: 

On Fri, Sep 14, 2012 at 7:13 PM, Andrew Pennebaker <
andrew.pennebaker at gmail.com> wrote:

> Challenge: get someone to have a competition at one of the conferences
>> where students all give their
>> best "five minute monad talk" and try to find the most comprehensible one!
>>
>
> Challenge accepted .
>


What did any of that have to do with monads?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From Ramana.Kumar at cl.cam.ac.uk  Sun Sep 16 09:54:58 2012
From: Ramana.Kumar at cl.cam.ac.uk (Ramana Kumar)
Date: Sun, 16 Sep 2012 08:54:58 +0100
Subject: [Haskell-cafe] Invitation to connect on LinkedIn
In-Reply-To: 
References: <1663877330.956242.1347464551072.JavaMail.app@ela4-app2319.prod>
	
Message-ID: 

On Wed, Sep 12, 2012 at 7:21 PM, damodar kulkarni wrote:

> Hi,
> Correct me if I am wrong, but by looking at the way the message is
> created, I think, LinkedIn is acting a kind of spammer these days. Shall we
> lodge protest against it as a community?
>

I'd support such a protest.


> As an aside, can we not automatically delete all messages to haskell
> mailing-lists whose "from" field contains "LinkedIn" (and the likes of it)
> in it?
>
> -Damodar
>
> On Wed, Sep 12, 2012 at 9:12 PM, Sakari Joinen via LinkedIn <
> member at linkedin.com> wrote:
>
>>
>>    [image: LinkedIn Logo] 
>>
>>
>>
>>   Steve,
>>
>>    Sakari Joinen wants to connect with you on LinkedIn.
>>
>>  Sakari Joinen
>>  Senior QA Engineer at Rocketpack  View Profile ?
>>
>>   Accept
>>
>>
>>
>>  You are receiving Invitation emails. Unsubscribe.
>>
>>
>> This email was intended for Steve Severance (Principal at Alpha Heavy
>> Industries). Learn why we included this.
>> ? 2012, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043,
>> USA
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>>
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From liugaoang at gmail.com  Sun Sep 16 10:15:55 2012
From: liugaoang at gmail.com (Gaoang Liu)
Date: Sun, 16 Sep 2012 01:15:55 -0700 (PDT)
Subject: [Haskell-cafe] Could not find module `Text.Regex'
In-Reply-To: <27366745.post@talk.nabble.com>
References: <27366745.post@talk.nabble.com>
Message-ID: <080e3151-f8a4-4a18-9677-c83502b9d4ac@googlegroups.com>

yeah , cabal install regex.compat fixes my problems ,2 .  Thx .

On Friday, January 29, 2010 11:51:23 AM UTC+8, zaxis wrote:
>
>
> import Text.Regex
>
> date_by_ntday dateStr ntday = do
>     let [y,m,d] = map (\x -> read x::Int) $ splitRegex (mkRegex "-") 
> dateStr
>     ....
>
> %ghc --version 
> The Glorious Glasgow Haskell Compilation System, version 6.12.1
>
> Which package(s) do i need to use Text.Regex ?
>
> Sincerely!
>
> -----
> fac n = foldr (*) 1 [1..n]
> -- 
> View this message in context: 
> http://old.nabble.com/Could-not-find-module-%60Text.Regex%27-tp27366745p27366745.html
> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskel... at haskell.org 
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From marcotmarcot at gmail.com  Sun Sep 16 12:57:37 2012
From: marcotmarcot at gmail.com (=?UTF-8?Q?Marco_T=C3=BAlio_Pimenta_Gontijo?=)
Date: Sun, 16 Sep 2012 07:57:37 -0300
Subject: [Haskell-cafe] cost-centre names
Message-ID: 

Hi.

I have a question about cost-centre names, as shown on .hp files
produced by +RTS -hc.  They have the form A/B/C/D/E/F/G/...  Usually,
it seems that it means A, called by B, called by C, etc, but that's
not the case sometimes.  I have a case here (called with -L200):
replaceOneOf?/clean/tagsText/anyTag/dropTagClose/parseObservations/specificTagText/tagText/parseOab/dropTagText/dropTill/tag/tagOpen...

tagsText calls clean which calls replaceOneOf', but anyTag does not
call tagsText.  parseObservations calls dropTagClose which calss
anyTag, but specificTagText does not call parseObservations.  They
seem to be grouped by three.

Is this correct?  How should I interpret it?

Greetings.

-- 
marcot
http://marcot.eti.br/


From marcotmarcot at gmail.com  Sun Sep 16 13:05:33 2012
From: marcotmarcot at gmail.com (=?UTF-8?Q?Marco_T=C3=BAlio_Pimenta_Gontijo?=)
Date: Sun, 16 Sep 2012 08:05:33 -0300
Subject: [Haskell-cafe] Type error with Type families
Message-ID: 

Hi.

I cannot make this program type check:

    {-# LANGUAGE TypeFamilies, FlexibleContexts #-}
    import qualified Data.ListLike as LL

    class LL.ListLike full (Item full) => ReplaceOneOf full where
      type Item full :: *
      replaceOneOf :: [Item full] -> full -> full -> full
      replaceOneOf from to list
        | LL.null list = list
        | x `element` from
          = LL.concat [to, replaceOneOf from to $ LL.dropWhile
(`element` from) xs]
        | otherwise = LL.cons x $ replaceOneOf from to xs
        where
          x = LL.head list
          xs = LL.tail list
      element :: Item full -> [Item full] -> Bool

The error message is:

    Line 9: 1 error(s), 0 warning(s)

    Could not deduce (Item full0 ~ Item full)
    from the context (ReplaceOneOf full)
      bound by the class declaration for `ReplaceOneOf'
      at /home/marcot/tmp/test_flymake.hs:(4,1)-(15,45)
    NB: `Item' is a type function, and may not be injective
    Expected type: [Item full0]
      Actual type: [Item full]
    In the second argument of `element', namely `from'
    In the expression: x `element` from

I have tried using asTypeOf, but it did not work:

    {-# LANGUAGE TypeFamilies, FlexibleContexts, ScopedTypeVariables #-}
    import qualified Data.ListLike as LL

    class LL.ListLike full (Item full) => ReplaceOneOf full where
      type Item full :: *
      replaceOneOf :: Item full -> [Item full] -> full -> full -> full
      replaceOneOf xt from to list
        | LL.null list = list
        | (x `asTypeOf` xt) `element` from
          = LL.concat [to, replaceOneOf xt from to $ LL.dropWhile
(`element` from) xs]
        | otherwise = LL.cons x $ replaceOneOf xt from to xs
        where
          x = LL.head list
          xs = LL.tail list
      element :: Item full -> [Item full] -> Bool

Can someone point me to a solution?

Greetings.

-- 
marcot
http://marcot.eti.br/


From miguelimo38 at yandex.ru  Sun Sep 16 13:44:18 2012
From: miguelimo38 at yandex.ru (MigMit)
Date: Sun, 16 Sep 2012 15:44:18 +0400
Subject: [Haskell-cafe] Type error with Type families
In-Reply-To: 
References: 
Message-ID: 

It shoudn't typecheck.

Suppose you have instances like

instance ReplaceOneOf Foo where
  type Item Foo = Baz
  element  = elementFoo

instance ReplaceOneOf Bar where
  type Item Bar = Baz
  element = elementBar

Now if you call replaceOneOf manyBazs foo1 foo2, Haskell should consult "element :: Baz -> [Baz] -> Baz" ? but which one, elementBar or elementFoo?

The error message is a bit criptic, but what it really means is that Haskell sees the possibility of such confusion and has to resort to the general "element" function of type Item something -> [Item something] -> Item something, and then fails to unify this "Item something" with "Item full". It correctly notes that the type function "Item" is not injective, which means that "Item Foo ~ Item Bar" is possible even if "Foo ~ Bar".

For the solution. I assume that the standard "elementOf" function doesn't suit you. If so, you can make your Items instances of another class:

class Element item where element :: item -> [item] -> Bool

and change ReplaceOneOf declaration to

class (LL.ListLike full (Item full), Element (Item full)) => ReplaceOneOf full where
...

On Sep 16, 2012, at 3:05 PM, Marco T?lio Pimenta Gontijo  wrote:

> Hi.
> 
> I cannot make this program type check:
> 
>    {-# LANGUAGE TypeFamilies, FlexibleContexts #-}
>    import qualified Data.ListLike as LL
> 
>    class LL.ListLike full (Item full) => ReplaceOneOf full where
>      type Item full :: *
>      replaceOneOf :: [Item full] -> full -> full -> full
>      replaceOneOf from to list
>        | LL.null list = list
>        | x `element` from
>          = LL.concat [to, replaceOneOf from to $ LL.dropWhile
> (`element` from) xs]
>        | otherwise = LL.cons x $ replaceOneOf from to xs
>        where
>          x = LL.head list
>          xs = LL.tail list
>      element :: Item full -> [Item full] -> Bool
> 
> The error message is:
> 
>    Line 9: 1 error(s), 0 warning(s)
> 
>    Could not deduce (Item full0 ~ Item full)
>    from the context (ReplaceOneOf full)
>      bound by the class declaration for `ReplaceOneOf'
>      at /home/marcot/tmp/test_flymake.hs:(4,1)-(15,45)
>    NB: `Item' is a type function, and may not be injective
>    Expected type: [Item full0]
>      Actual type: [Item full]
>    In the second argument of `element', namely `from'
>    In the expression: x `element` from
> 
> I have tried using asTypeOf, but it did not work:
> 
>    {-# LANGUAGE TypeFamilies, FlexibleContexts, ScopedTypeVariables #-}
>    import qualified Data.ListLike as LL
> 
>    class LL.ListLike full (Item full) => ReplaceOneOf full where
>      type Item full :: *
>      replaceOneOf :: Item full -> [Item full] -> full -> full -> full
>      replaceOneOf xt from to list
>        | LL.null list = list
>        | (x `asTypeOf` xt) `element` from
>          = LL.concat [to, replaceOneOf xt from to $ LL.dropWhile
> (`element` from) xs]
>        | otherwise = LL.cons x $ replaceOneOf xt from to xs
>        where
>          x = LL.head list
>          xs = LL.tail list
>      element :: Item full -> [Item full] -> Bool
> 
> Can someone point me to a solution?
> 
> Greetings.
> 
> -- 
> marcot
> http://marcot.eti.br/
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



From jpm at cs.uu.nl  Sun Sep 16 13:45:47 2012
From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=)
Date: Sun, 16 Sep 2012 12:45:47 +0100
Subject: [Haskell-cafe] Transforming a ADT to a GADT
In-Reply-To: <50530ABF.7060904@tu-berlin.de>
References: <50530ABF.7060904@tu-berlin.de>
Message-ID: 

Hi Florian,

Will this do?

class Tc a where
  tc :: Exp -> Maybe (Term a)

instance Tc Int where
  tc (Lit i)      = return (TLit i)
  tc (Succ i)     = tc i >>= return . TSucc
  tc (IsZero i)   = Nothing
  tc e            = tcIf e

instance Tc Bool where
  tc (Lit i)      = Nothing
  tc (Succ i)     = Nothing
  tc (IsZero i)   = tc i >>= return . TIsZero
  tc e            = tcIf e

tcIf :: (Tc a) => Exp -> Maybe (Term a)
tcIf (If c e1 e2) = do c' <- tc c
                       e1' <- tc e1
                       e2' <- tc e2
                       return (TIf c' e1' e2')


Cheers,
Pedro

On Fri, Sep 14, 2012 at 11:45 AM, Florian Lorenzen <
florian.lorenzen at tu-berlin.de> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello cafe,
>
> I have a question wrt. to GADTs and type families in GHC (7.6.1).
>
> I'd like to transform a value of an ADT to a GADT. Suppose I have the
> simple expression language
>
> > data Exp = Lit Int > | Succ Exp > | IsZero Exp > | If Exp Exp Exp
>
> and the GADT
>
> > data Term t where > TLit :: Int -> Term Int > TSucc :: Term Int ->
> Term Int > TIsZero :: Term Int -> Term Bool > TIf :: Term Bool -> Term
> ty -> Term ty -> Term ty
>
> that encodes the typing rules.
>
> Now, I'd like to have a function
>
> > typecheck :: Exp -> Maybe (Term t) > typecheck exp = <...>
>
> that returns the GADT value corresponding to `exp' if `exp' is type
> correct.
>
> I found a solution at
> http://okmij.org/ftp/tagless-final/TypecheckedDSLTH.hs but this has as
> type (slightly adapted)
>
> > typecheck :: Exp -> Maybe TypedTerm
>
> with
>
> > data TypedTerm = forall ty. (Typ ty) (Term ty) > data Typ ty =
> > TInt
> Int | TBool Bool
>
> That is, the GADT value is hidden inside the existential and cannot be
> unpacked. Therefore, I cannot write a type preserving transformation
> function like
>
> > transform :: Term t -> Term t
>
> that gets the result of the `typecheck' function as input.
>
> The solution mentioned above uses Template Haskell to extract the
> `Term t' type from the existential package and argues that type errors
> cannot occur during splicing.
>
> Is there a possibility to avoid the existential and hence Template
> Haskell?
>
> Of course, the result type of typecheck depends on the type and type
> correctness of its input.
>
> My idea was to express this dependency by parameterizing `Exp' and
> using a type family `ExpType' like:
>
> > typecheck :: Exp e -> Maybe (Term (ExpType e)) > typecheck (ELit
> > i)
> = Just (TLit i) > typecheck (ESucc exp1) = case typecheck exp1 of >
> Nothing -> Nothing > Just t -> Just (TSucc t) > <...>
>
> with
>
> > data TEXP = L | S TEXP | IZ TEXP | I TEXP TEXP TEXP -- datakind >
> > >
> data Exp (e::TEXP) where > ELit :: Int -> Exp L > ESucc :: Exp e1 ->
> Exp (S e1) > EIsZero :: Exp e1 -> Exp (IZ e1) > EIf :: Exp e1 -> Exp
> e2 -> Exp e3 -> Exp (I e1 e2 e3)
>
> It seems to me that `ExpType' then would be a reification of the type
> checker for `Exp' at the type level. But I did not know how to define
> it. Does it make sense at all? Is it possible in GHC?
>
> All the examples on the net I looked at either start with the GADT
> right away or use Template Haskell at some point. So, perhaps this
> `typecheck' function is not possible to write in GHC Haskell.
>
> I very much appreciate any hints and explanations on this.
>
> Best regards,
>
> Florian
>
>
>
> - --
> Florian Lorenzen
>
> Technische Universit?t Berlin
> Fakult?t IV - Elektrotechnik und Informatik
> ?bersetzerbau und Programmiersprachen
>
> Sekr. TEL12-2, Ernst-Reuter-Platz 7, D-10587 Berlin
>
> Tel.:   +49 (30) 314-24618
> E-Mail: florian.lorenzen at tu-berlin.de
> WWW:    http://www.user.tu-berlin.de/florenz/
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
>
> iEYEARECAAYFAlBTCr8ACgkQvjzICpVvX7ZfTgCeOPflPtaEW/w1McjYWheaRaqq
> oUQAnRXSrGP3se+3oiI3nnd+B/rK8yx8
> =X1hR
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From rendel at informatik.uni-marburg.de  Sun Sep 16 16:48:50 2012
From: rendel at informatik.uni-marburg.de (Tillmann Rendel)
Date: Sun, 16 Sep 2012 16:48:50 +0200
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	
	
	
Message-ID: <5055E6D2.3030702@informatik.uni-marburg.de>

Hi,

Kristopher Micinski wrote:
> Everyone in the Haskell cafe probably has a secret dream to give the
> best "five minute monad talk."

(1) Most programming languages support side effects. There are different 
kinds of side effects such as accessing mutable variables, reading 
files, running in parallel, raising exceptions, nondeterministically 
returning more than one answer, and many more. Most languages have some 
of these effects built into their semantics, and do not support the 
others at all.

(2) Haskell is pure, so it doesn't support any side effects. Instead, 
when Haskell programmers want to perform a side effect, they explicitly 
construct a description of the side effecting computation as a value. 
For every group of related side effects, there is a Haskell type that 
describes computations that can have that group of side effects.

(3) Some of these types are built in, such as IO for accessing the world 
outside the processor and ST for accessing local mutable variables. 
Other such types are defined in Haskell libraries, such as for 
computations that can fail and for computations that can return multiple 
answers. Application programmers often define their own types for the 
side effects they need to describe, tailoring the language to their needs.

(4) All computation types have a common interface for operations that 
are independent of the exact side effects performed. Some functions work 
with arbitrary computations, just using this interface. For example, we 
can compose a computation with itself in order to run it twice. Such 
generic operations are highly reusable.

(5) The common interface for constructing computations is called 
"Monad". It is inspired by the mathematical theory that some computer 
scientists use when they describe what exactly the semantics of a 
programming language with side effects is. So most other languages 
support some monad natively without the programmer ever noticing, 
whereas Haskell programmers can choose (and even implement) exactly the 
monads they want. This makes Haskell a very good language for side 
effecting computation.

   Tillmann


From felipe.lessa at gmail.com  Sun Sep 16 18:57:52 2012
From: felipe.lessa at gmail.com (Felipe Almeida Lessa)
Date: Sun, 16 Sep 2012 13:57:52 -0300
Subject: [Haskell-cafe] cost-centre names
In-Reply-To: 
References: 
Message-ID: 

On Sun, Sep 16, 2012 at 7:57 AM, Marco T?lio Pimenta Gontijo
 wrote:
> I have a question about cost-centre names, as shown on .hp files
> produced by +RTS -hc.  They have the form A/B/C/D/E/F/G/...  Usually,
> it seems that it means A, called by B, called by C, etc, but that's
> not the case sometimes.  I have a case here (called with -L200):
> replaceOneOf?/clean/tagsText/anyTag/dropTagClose/parseObservations/specificTagText/tagText/parseOab/dropTagText/dropTill/tag/tagOpen...
>
> tagsText calls clean which calls replaceOneOf', but anyTag does not
> call tagsText.  parseObservations calls dropTagClose which calss
> anyTag, but specificTagText does not call parseObservations.  They
> seem to be grouped by three.
>
> Is this correct?  How should I interpret it?

That's probably because anyTag took a closure as argument, and that
closure called tagsText when forced.  Does that make sense?

Cheers,

-- 
Felipe.


From myles.maxfield at gmail.com  Sun Sep 16 21:40:17 2012
From: myles.maxfield at gmail.com (Myles C. Maxfield)
Date: Sun, 16 Sep 2012 12:40:17 -0700
Subject: [Haskell-cafe] Dynamic Programming with Data.Vector
Message-ID: 

Hello,

I've been writing dynamic programming (dp) algorithms in imperative
languages for years, and I was thinking recently about how to use it in a
Haskell context. In particular, I want to write a function that takes an
ordered collection of items and produces a new item to insert into the
ordered collection.

The most straightforward way to do this would be to use a list, something
like the following:

recurse :: [Integer] -> [Integer]
recurse l = newValue : recurse (take (length l + 1) infiniteList)
  where newValue = ...

infiniteList :: [Integer]
infiniteList = initialList ++ recurse initialList
  where initialList = ...

solution :: Integer
solution = infiniteList !! 5

I'm assuming that this can run fast because I'm assuming the 'take'
function won't actually duplicate the list ([1] doesn't actually list the
running time of 'take') Is this a correct assumption to make?

Secondarily, and most importantly for me, I'm curious about how to make
this fast when the computation of 'newValue' requires random access to the
inputted list. I'm assuming that I would use Vectors instead of lists for
this kind of computation, and [2] describes how I can use the O(1) 'slice'
instead of 'take' above. However, both of Vector's cons and snoc functions
are O(n) which defeats the purpose of using this kind of algorithm.
Obviously, I can solve this problem with mutable vectors, but that's quite
inelegant.

Overall, I'm looking for a function, similar to Data.Vector's 'generate'
function, but instead of the generation function taking the destination
index, I'd like it to take the elements that have previously been
constructed. Is there such a function? If there isn't one, is this kind of
function feasible to write? If such a function doesn't exist and is
feasible to write, I'd be happy to try to write and contribute it.

[1]
http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html#g:11
[2]
http://hackage.haskell.org/packages/archive/vector/0.9.1/doc/html/Data-Vector.html#g:6
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From vincent.berthoux at gmail.com  Sun Sep 16 21:54:28 2012
From: vincent.berthoux at gmail.com (Vincent Berthoux)
Date: Sun, 16 Sep 2012 21:54:28 +0200
Subject: [Haskell-cafe] [ANNOUNCE] Juicy.Pixels v2.0
Message-ID: 

Hello,

    I'm pleased to announce the release of Juicy.Pixels (a pure Haskell
library for image loading and writing) in version 2.0.

The new features of this version are a Gif file decoder, and a rework of
the plane extraction part to be type safe

  github: https://github.com/Twinside/Juicy.Pixels
  hackage: http://hackage.haskell.org/package/JuicyPixels


Thanks

    Vincent Berthoux
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From conal at conal.net  Sun Sep 16 21:55:43 2012
From: conal at conal.net (Conal Elliott)
Date: Sun, 16 Sep 2012 12:55:43 -0700
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: <5055E6D2.3030702@informatik.uni-marburg.de>
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	
	
	
	<5055E6D2.3030702@informatik.uni-marburg.de>
Message-ID: 

Hi Tillmann. Wow. Lovely and spot on! And I almost never hear monad
explanations without wincing. Thanks for sharing.  -- Conal

On Sun, Sep 16, 2012 at 7:48 AM, Tillmann Rendel <
rendel at informatik.uni-marburg.de> wrote:

> Hi,
>
>
> Kristopher Micinski wrote:
>
>> Everyone in the Haskell cafe probably has a secret dream to give the
>> best "five minute monad talk."
>>
>
> (1) Most programming languages support side effects. There are different
> kinds of side effects such as accessing mutable variables, reading files,
> running in parallel, raising exceptions, nondeterministically returning
> more than one answer, and many more. Most languages have some of these
> effects built into their semantics, and do not support the others at all.
>
> (2) Haskell is pure, so it doesn't support any side effects. Instead, when
> Haskell programmers want to perform a side effect, they explicitly
> construct a description of the side effecting computation as a value. For
> every group of related side effects, there is a Haskell type that describes
> computations that can have that group of side effects.
>
> (3) Some of these types are built in, such as IO for accessing the world
> outside the processor and ST for accessing local mutable variables. Other
> such types are defined in Haskell libraries, such as for computations that
> can fail and for computations that can return multiple answers. Application
> programmers often define their own types for the side effects they need to
> describe, tailoring the language to their needs.
>
> (4) All computation types have a common interface for operations that are
> independent of the exact side effects performed. Some functions work with
> arbitrary computations, just using this interface. For example, we can
> compose a computation with itself in order to run it twice. Such generic
> operations are highly reusable.
>
> (5) The common interface for constructing computations is called "Monad".
> It is inspired by the mathematical theory that some computer scientists use
> when they describe what exactly the semantics of a programming language
> with side effects is. So most other languages support some monad natively
> without the programmer ever noticing, whereas Haskell programmers can
> choose (and even implement) exactly the monads they want. This makes
> Haskell a very good language for side effecting computation.
>
>   Tillmann
>
>
> ______________________________**_________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/**mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From krismicinski at gmail.com  Sun Sep 16 22:03:15 2012
From: krismicinski at gmail.com (Kristopher Micinski)
Date: Sun, 16 Sep 2012 16:03:15 -0400
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	
	
	
	<5055E6D2.3030702@informatik.uni-marburg.de>
	
Message-ID: 

Agreed.  Great.  I still contend that it would be cool to get this to
be a real thing at something like the Haskell workshop, I think
hearing the different perspectives would be an interesting insight
into the many different ways to explain monads.  But I suppose the way
to start would be to put up a webpage for collecting them..

kris

On Sun, Sep 16, 2012 at 3:55 PM, Conal Elliott  wrote:
> Hi Tillmann. Wow. Lovely and spot on! And I almost never hear monad
> explanations without wincing. Thanks for sharing.  -- Conal
>
> On Sun, Sep 16, 2012 at 7:48 AM, Tillmann Rendel
>  wrote:
>>
>> Hi,
>>
>>
>> Kristopher Micinski wrote:
>>>
>>> Everyone in the Haskell cafe probably has a secret dream to give the
>>> best "five minute monad talk."
>>
>>
>> (1) Most programming languages support side effects. There are different
>> kinds of side effects such as accessing mutable variables, reading files,
>> running in parallel, raising exceptions, nondeterministically returning more
>> than one answer, and many more. Most languages have some of these effects
>> built into their semantics, and do not support the others at all.
>>
>> (2) Haskell is pure, so it doesn't support any side effects. Instead, when
>> Haskell programmers want to perform a side effect, they explicitly construct
>> a description of the side effecting computation as a value. For every group
>> of related side effects, there is a Haskell type that describes computations
>> that can have that group of side effects.
>>
>> (3) Some of these types are built in, such as IO for accessing the world
>> outside the processor and ST for accessing local mutable variables. Other
>> such types are defined in Haskell libraries, such as for computations that
>> can fail and for computations that can return multiple answers. Application
>> programmers often define their own types for the side effects they need to
>> describe, tailoring the language to their needs.
>>
>> (4) All computation types have a common interface for operations that are
>> independent of the exact side effects performed. Some functions work with
>> arbitrary computations, just using this interface. For example, we can
>> compose a computation with itself in order to run it twice. Such generic
>> operations are highly reusable.
>>
>> (5) The common interface for constructing computations is called "Monad".
>> It is inspired by the mathematical theory that some computer scientists use
>> when they describe what exactly the semantics of a programming language with
>> side effects is. So most other languages support some monad natively without
>> the programmer ever noticing, whereas Haskell programmers can choose (and
>> even implement) exactly the monads they want. This makes Haskell a very good
>> language for side effecting computation.
>>
>>   Tillmann
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>


From krismicinski at gmail.com  Sun Sep 16 22:06:39 2012
From: krismicinski at gmail.com (Kristopher Micinski)
Date: Sun, 16 Sep 2012 16:06:39 -0400
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	
	
	
	<5055E6D2.3030702@informatik.uni-marburg.de>
	
Message-ID: 

Agreed.  Great.  I still contend that it would be cool to get this to
be a real thing at something like the Haskell workshop, I think
hearing the different perspectives would be an interesting insight
into the many different ways to explain monads.  But I suppose the way
to start would be to put up a webpage for collecting them..

kris

On Sun, Sep 16, 2012 at 3:55 PM, Conal Elliott  wrote:
> Hi Tillmann. Wow. Lovely and spot on! And I almost never hear monad
> explanations without wincing. Thanks for sharing.  -- Conal
>
> On Sun, Sep 16, 2012 at 7:48 AM, Tillmann Rendel
>  wrote:
>>
>> Hi,
>>
>>
>> Kristopher Micinski wrote:
>>>
>>> Everyone in the Haskell cafe probably has a secret dream to give the
>>> best "five minute monad talk."
>>
>>
>> (1) Most programming languages support side effects. There are different
>> kinds of side effects such as accessing mutable variables, reading files,
>> running in parallel, raising exceptions, nondeterministically returning more
>> than one answer, and many more. Most languages have some of these effects
>> built into their semantics, and do not support the others at all.
>>
>> (2) Haskell is pure, so it doesn't support any side effects. Instead, when
>> Haskell programmers want to perform a side effect, they explicitly construct
>> a description of the side effecting computation as a value. For every group
>> of related side effects, there is a Haskell type that describes computations
>> that can have that group of side effects.
>>
>> (3) Some of these types are built in, such as IO for accessing the world
>> outside the processor and ST for accessing local mutable variables. Other
>> such types are defined in Haskell libraries, such as for computations that
>> can fail and for computations that can return multiple answers. Application
>> programmers often define their own types for the side effects they need to
>> describe, tailoring the language to their needs.
>>
>> (4) All computation types have a common interface for operations that are
>> independent of the exact side effects performed. Some functions work with
>> arbitrary computations, just using this interface. For example, we can
>> compose a computation with itself in order to run it twice. Such generic
>> operations are highly reusable.
>>
>> (5) The common interface for constructing computations is called "Monad".
>> It is inspired by the mathematical theory that some computer scientists use
>> when they describe what exactly the semantics of a programming language with
>> side effects is. So most other languages support some monad natively without
>> the programmer ever noticing, whereas Haskell programmers can choose (and
>> even implement) exactly the monads they want. This makes Haskell a very good
>> language for side effecting computation.
>>
>>   Tillmann
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>


From miguelimo38 at yandex.ru  Sun Sep 16 22:15:00 2012
From: miguelimo38 at yandex.ru (MigMit)
Date: Mon, 17 Sep 2012 00:15:00 +0400
Subject: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
In-Reply-To: 
References: 
	<20120914175022.GA38630@scout.stangl.us>
	
	
	
	
	<5055E6D2.3030702@informatik.uni-marburg.de>
	
	
Message-ID: <1B72A367-00BB-4ECA-BDEA-18D78A20559B@yandex.ru>

Mind if I join you in praising this?

On Sep 17, 2012, at 12:06 AM, Kristopher Micinski  wrote:

> Agreed.  Great.  I still contend that it would be cool to get this to
> be a real thing at something like the Haskell workshop, I think
> hearing the different perspectives would be an interesting insight
> into the many different ways to explain monads.  But I suppose the way
> to start would be to put up a webpage for collecting them..
> 
> kris
> 
> On Sun, Sep 16, 2012 at 3:55 PM, Conal Elliott  wrote:
>> Hi Tillmann. Wow. Lovely and spot on! And I almost never hear monad
>> explanations without wincing. Thanks for sharing.  -- Conal
>> 
>> On Sun, Sep 16, 2012 at 7:48 AM, Tillmann Rendel
>>  wrote:
>>> 
>>> Hi,
>>> 
>>> 
>>> Kristopher Micinski wrote:
>>>> 
>>>> Everyone in the Haskell cafe probably has a secret dream to give the
>>>> best "five minute monad talk."
>>> 
>>> 
>>> (1) Most programming languages support side effects. There are different
>>> kinds of side effects such as accessing mutable variables, reading files,
>>> running in parallel, raising exceptions, nondeterministically returning more
>>> than one answer, and many more. Most languages have some of these effects
>>> built into their semantics, and do not support the others at all.
>>> 
>>> (2) Haskell is pure, so it doesn't support any side effects. Instead, when
>>> Haskell programmers want to perform a side effect, they explicitly construct
>>> a description of the side effecting computation as a value. For every group
>>> of related side effects, there is a Haskell type that describes computations
>>> that can have that group of side effects.
>>> 
>>> (3) Some of these types are built in, such as IO for accessing the world
>>> outside the processor and ST for accessing local mutable variables. Other
>>> such types are defined in Haskell libraries, such as for computations that
>>> can fail and for computations that can return multiple answers. Application
>>> programmers often define their own types for the side effects they need to
>>> describe, tailoring the language to their needs.
>>> 
>>> (4) All computation types have a common interface for operations that are
>>> independent of the exact side effects performed. Some functions work with
>>> arbitrary computations, just using this interface. For example, we can
>>> compose a computation with itself in order to run it twice. Such generic
>>> operations are highly reusable.
>>> 
>>> (5) The common interface for constructing computations is called "Monad".
>>> It is inspired by the mathematical theory that some computer scientists use
>>> when they describe what exactly the semantics of a programming language with
>>> side effects is. So most other languages support some monad natively without
>>> the programmer ever noticing, whereas Haskell programmers can choose (and
>>> even implement) exactly the monads they want. This makes Haskell a very good
>>> language for side effecting computation.
>>> 
>>>  Tillmann
>>> 
>>> 
>>> _______________________________________________
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
>>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>> 
>> 
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



From myles.maxfield at gmail.com  Sun Sep 16 22:34:47 2012
From: myles.maxfield at gmail.com (Myles C. Maxfield)
Date: Sun, 16 Sep 2012 13:34:47 -0700
Subject: [Haskell-cafe] Dynamic Programming with Data.Vector
In-Reply-To: 
References: 
Message-ID: 

Someone replied saying that I could use a HashMap and a fold to do this,
and that solution should work quite well.

Bonus points if there's a solution without the space overhead of a hashmap
:-) I'm hoping for an unboxed vector.

--Myles

On Sun, Sep 16, 2012 at 12:40 PM, Myles C. Maxfield <
myles.maxfield at gmail.com> wrote:

> Hello,
>
> I've been writing dynamic programming (dp) algorithms in imperative
> languages for years, and I was thinking recently about how to use it in a
> Haskell context. In particular, I want to write a function that takes an
> ordered collection of items and produces a new item to insert into the
> ordered collection.
>
> The most straightforward way to do this would be to use a list, something
> like the following:
>
> recurse :: [Integer] -> [Integer]
> recurse l = newValue : recurse (take (length l + 1) infiniteList)
>   where newValue = ...
>
> infiniteList :: [Integer]
> infiniteList = initialList ++ recurse initialList
>   where initialList = ...
>
> solution :: Integer
> solution = infiniteList !! 5
>
> I'm assuming that this can run fast because I'm assuming the 'take'
> function won't actually duplicate the list ([1] doesn't actually list the
> running time of 'take') Is this a correct assumption to make?
>
> Secondarily, and most importantly for me, I'm curious about how to make
> this fast when the computation of 'newValue' requires random access to the
> inputted list. I'm assuming that I would use Vectors instead of lists for
> this kind of computation, and [2] describes how I can use the O(1) 'slice'
> instead of 'take' above. However, both of Vector's cons and snoc functions
> are O(n) which defeats the purpose of using this kind of algorithm.
> Obviously, I can solve this problem with mutable vectors, but that's quite
> inelegant.
>
> Overall, I'm looking for a function, similar to Data.Vector's 'generate'
> function, but instead of the generation function taking the destination
> index, I'd like it to take the elements that have previously been
> constructed. Is there such a function? If there isn't one, is this kind of
> function feasible to write? If such a function doesn't exist and is
> feasible to write, I'd be happy to try to write and contribute it.
>
> [1]
> http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html#g:11
> [2]
> http://hackage.haskell.org/packages/archive/vector/0.9.1/doc/html/Data-Vector.html#g:6
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ok at cs.otago.ac.nz  Mon Sep 17 00:04:01 2012
From: ok at cs.otago.ac.nz (Richard O'Keefe)
Date: Mon, 17 Sep 2012 10:04:01 +1200
Subject: [Haskell-cafe] What is the good way to work with list
	comprehension and UTCTime?
In-Reply-To: 
References: 
Message-ID: <615D2378-2E08-41A4-AD95-BA869E72DDE3@cs.otago.ac.nz>


On 15/09/2012, at 5:14 AM, Chris Heller wrote:

> You might want to have a look at the time-recurrence package: http://hackage.haskell.org/package/time-recurrence
> 
> For your simple cases you would do something like:
> 
> Each second:
> 
>     starting (UTCTime ...) $ recur secondly
> 
> Each minute:
> 
>     starting (UTCTime ...) $ recur minutely

Ouch.  Look up "minutely" (my-NEWT-ly) in an English
dictionary.  Look up "secondly" while you're there.



From aslatter at gmail.com  Mon Sep 17 01:14:06 2012
From: aslatter at gmail.com (Antoine Latter)
Date: Sun, 16 Sep 2012 18:14:06 -0500
Subject: [Haskell-cafe] What is the good way to work with list
 comprehension and UTCTime?
In-Reply-To: <615D2378-2E08-41A4-AD95-BA869E72DDE3@cs.otago.ac.nz>
References: 
	<615D2378-2E08-41A4-AD95-BA869E72DDE3@cs.otago.ac.nz>
Message-ID: 

On Sun, Sep 16, 2012 at 5:04 PM, Richard O'Keefe  wrote:
>
> On 15/09/2012, at 5:14 AM, Chris Heller wrote:
>
>> You might want to have a look at the time-recurrence package: http://hackage.haskell.org/package/time-recurrence
>>
>> For your simple cases you would do something like:
>>
>> Each second:
>>
>>     starting (UTCTime ...) $ recur secondly
>>
>> Each minute:
>>
>>     starting (UTCTime ...) $ recur minutely
>
> Ouch.  Look up "minutely" (my-NEWT-ly) in an English
> dictionary.  Look up "secondly" while you're there.
>
>

You can blame RFC 5545 for that one. In section 3.3.10. our frequencies are:

freq        = "SECONDLY" / "MINUTELY" / "HOURLY" / "DAILY"
                   / "WEEKLY" / "MONTHLY" / "YEARLY"

Antoine


From hellertime at gmail.com  Mon Sep 17 02:34:40 2012
From: hellertime at gmail.com (Heller Time)
Date: Sun, 16 Sep 2012 20:34:40 -0400
Subject: [Haskell-cafe] What is the good way to work with list
	comprehension and UTCTime?
In-Reply-To: 
References: 
	<615D2378-2E08-41A4-AD95-BA869E72DDE3@cs.otago.ac.nz>
	
Message-ID: 

Antoine has it right, the language is lifted from the RFC.

Chris Heller
SAS - Advanced Analytics
Teragram Research & Development
phone: 1-617-576-6800 x54237
mobile: 1-617-460-3643
email: heller at teragram.com

On Sep 16, 2012, at 7:14 PM, Antoine Latter  wrote:

> On Sun, Sep 16, 2012 at 5:04 PM, Richard O'Keefe  wrote:
>> 
>> On 15/09/2012, at 5:14 AM, Chris Heller wrote:
>> 
>>> You might want to have a look at the time-recurrence package: http://hackage.haskell.org/package/time-recurrence
>>> 
>>> For your simple cases you would do something like:
>>> 
>>> Each second:
>>> 
>>>    starting (UTCTime ...) $ recur secondly
>>> 
>>> Each minute:
>>> 
>>>    starting (UTCTime ...) $ recur minutely
>> 
>> Ouch.  Look up "minutely" (my-NEWT-ly) in an English
>> dictionary.  Look up "secondly" while you're there.
>> 
>> 
> 
> You can blame RFC 5545 for that one. In section 3.3.10. our frequencies are:
> 
> freq        = "SECONDLY" / "MINUTELY" / "HOURLY" / "DAILY"
>                   / "WEEKLY" / "MONTHLY" / "YEARLY"
> 
> Antoine


From wren at freegeek.org  Mon Sep 17 07:40:37 2012
From: wren at freegeek.org (wren ng thornton)
Date: Mon, 17 Sep 2012 01:40:37 -0400
Subject: [Haskell-cafe] Either Monad and Laziness
In-Reply-To: 
References: <20120912060330.83793.qmail@www1.g3.pair.com>
	
	
	<87vcfjxnfk.wl%f@mazzo.li> <50526C5C.40506@freegeek.org>
	
Message-ID: <5056B7D5.7090203@freegeek.org>

On 9/14/12 5:16 PM, Eric Velten de Melo wrote:
> But now I'm kinda lost. Is there an easy way to explain the difference between:
> -iteratee
> -conduit
> -enumerator

John Lato's iteratee library is the original one based on Oleg 
Kiselyov's work. I've used it a fair deal and am quite fond of it.

Some folks didn't like it so much though; whence enumerator, conduit, 
pipes, pipes-core,... I've followed the discussions back and forth over 
those libraries, but I've not used them nor sat down to compare them 
head-to-head.

-- 
Live well,
~wren


From florian.lorenzen at tu-berlin.de  Mon Sep 17 10:04:18 2012
From: florian.lorenzen at tu-berlin.de (Florian Lorenzen)
Date: Mon, 17 Sep 2012 10:04:18 +0200
Subject: [Haskell-cafe] Transforming a ADT to a GADT
In-Reply-To: <20120915110201.49794.qmail@www1.g3.pair.com>
References: <20120915110201.49794.qmail@www1.g3.pair.com>
Message-ID: <5056D982.9050201@tu-berlin.de>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thanks Oleg for this elaboration. I'm now happy with the solution
involving an existential. I first did not realize that I still could
apply functions of type `Term t -> Term t` as soon as I open the package.

On 09/15/2012 01:02 PM, oleg at okmij.org wrote:
> Florian Lorenzen wrote: Chances are that you wanted the following
> 
> typecheck :: {e:Exp} -> Result e where Result e has the type (Just 
> (Term t)) (with some t dependent on e) if e is typeable, and 
> Nothing otherwise. But this is a dependent function type
> (Pi-type). No wonder we have to go through contortions like
> Template Haskell to emulate dependent types in Haskell. Haskell was
> not designed to be a dependently-typed language.
Yes, this is what I was looking for. I know, Haskell is not
dependently typed. But since many dependently typed idioms (like
printf) can already be expressed using the GHC Haskell type system, I
was wondering if this one was also possible.

Best regards,

Florian

- -- 
Florian Lorenzen

Technische Universit?t Berlin
Fakult?t IV - Elektrotechnik und Informatik
?bersetzerbau und Programmiersprachen

Sekr. TEL12-2, Ernst-Reuter-Platz 7, D-10587 Berlin

Tel.:   +49 (30) 314-24618
E-Mail: florian.lorenzen at tu-berlin.de
WWW:    http://www.user.tu-berlin.de/florenz/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlBW2YIACgkQvjzICpVvX7alFwCgkS5Gq2CfJqxX5ZV2TJQslSDn
a9IAoJCj3HY5J8kU5T1HcCJGDFbUaLrc
=G/Zf
-----END PGP SIGNATURE-----


From florian.lorenzen at tu-berlin.de  Mon Sep 17 10:05:12 2012
From: florian.lorenzen at tu-berlin.de (Florian Lorenzen)
Date: Mon, 17 Sep 2012 10:05:12 +0200
Subject: [Haskell-cafe] Transforming a ADT to a GADT
In-Reply-To: 
References: <50530ABF.7060904@tu-berlin.de>
	
	
	
Message-ID: <5056D9B8.5090807@tu-berlin.de>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thanks Erik. This made the issue clear to me.

Best regards,

Florian

On 09/14/2012 03:22 PM, Erik Hesselink wrote:
> On Fri, Sep 14, 2012 at 2:27 PM, Erik Hesselink
>  wrote:
>> In general, I think you have to work inside an existential. So
>> you hide the type of the parsed Term inside an existential. If
>> you want to apply functions to this Term, you unpack, call the
>> function, and repack.
> 
> Maybe I should expand what I mean by this. Let's say you have:
> 
> data SomeTerm where SomeTerm :: Term a -> SomeTerm
> 
> Your typecheck function goes:
> 
> typecheck :: Exp -> SomeTerm
> 
> and you want to apply:
> 
> transform :: Term t -> Term t
> 
> You should do something like:
> 
> f (SomeTerm t) = SomeTerm (transform t)
> 
> Or, more generally:
> 
> onSomeTerm :: (forall t. Term t -> Term t) -> SomeTerm -> SomeTerm 
> onSomeTerm f (SomeTerm t) =  SomeTerm (f t)
> 
> Erik
> 

- -- 
Florian Lorenzen

Technische Universit?t Berlin
Fakult?t IV - Elektrotechnik und Informatik
?bersetzerbau und Programmiersprachen

Sekr. TEL12-2, Ernst-Reuter-Platz 7, D-10587 Berlin

Tel.:   +49 (30) 314-24618
E-Mail: florian.lorenzen at tu-berlin.de
WWW:    http://www.user.tu-berlin.de/florenz/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlBW2bgACgkQvjzICpVvX7Zr3QCfbIqkX9WqM69NLyk98aqyNcYe
RrUAniGndhj9OTl9XIoUBC/hoBI1lwML
=hReY
-----END PGP SIGNATURE-----


From florian.lorenzen at tu-berlin.de  Mon Sep 17 10:12:53 2012
From: florian.lorenzen at tu-berlin.de (Florian Lorenzen)
Date: Mon, 17 Sep 2012 10:12:53 +0200
Subject: [Haskell-cafe] Transforming a ADT to a GADT
In-Reply-To: 
References: <50530ABF.7060904@tu-berlin.de>
	
Message-ID: <5056DB85.9090900@tu-berlin.de>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jos?, it occurs to me that with this solution, I always have to
prescribe the type as in

> tc (Succ (Lit 5)) :: Maybe (Term Int)

Otherwise, I obtain the message

Ambiguous type variable `a0' in the constraint:
      (Tc a0) arising from a use of `tc'

But as Oleg already pointed out, I want to have a value `Just term ::
Maybe (Term t)' if the input is well-typed for some type which I don't
know.

Best regards,

Florian

On 09/16/2012 01:45 PM, Jos? Pedro Magalh?es wrote:
> Hi Florian,
> 
> Will this do?
> 
> class Tc a where tc :: Exp -> Maybe (Term a)
> 
> instance Tc Int where tc (Lit i)      = return (TLit i) tc (Succ i)
> = tc i >>= return . TSucc tc (IsZero i)   = Nothing tc e
> = tcIf e
> 
> instance Tc Bool where tc (Lit i)      = Nothing tc (Succ i)     =
> Nothing tc (IsZero i)   = tc i >>= return . TIsZero tc e
> = tcIf e
> 
> tcIf :: (Tc a) => Exp -> Maybe (Term a) tcIf (If c e1 e2) = do c'
> <- tc c e1' <- tc e1 e2' <- tc e2 return (TIf c' e1' e2')
> 
> 
> Cheers, Pedro
> 
> On Fri, Sep 14, 2012 at 11:45 AM, Florian Lorenzen 
>  > wrote:
> 
> Hello cafe,
> 
> I have a question wrt. to GADTs and type families in GHC (7.6.1).
> 
> I'd like to transform a value of an ADT to a GADT. Suppose I have
> the simple expression language
> 
>> data Exp = Lit Int > | Succ Exp > | IsZero Exp > | If Exp Exp
>> Exp
> 
> and the GADT
> 
>> data Term t where > TLit :: Int -> Term Int > TSucc :: Term Int
>> ->
> Term Int > TIsZero :: Term Int -> Term Bool > TIf :: Term Bool ->
> Term ty -> Term ty -> Term ty
> 
> that encodes the typing rules.
> 
> Now, I'd like to have a function
> 
>> typecheck :: Exp -> Maybe (Term t) > typecheck exp = <...>
> 
> that returns the GADT value corresponding to `exp' if `exp' is
> type correct.
> 
> I found a solution at 
> http://okmij.org/ftp/tagless-final/TypecheckedDSLTH.hs but this has
> as type (slightly adapted)
> 
>> typecheck :: Exp -> Maybe TypedTerm
> 
> with
> 
>> data TypedTerm = forall ty. (Typ ty) (Term ty) > data Typ ty = 
>> TInt
> Int | TBool Bool
> 
> That is, the GADT value is hidden inside the existential and cannot
> be unpacked. Therefore, I cannot write a type preserving
> transformation function like
> 
>> transform :: Term t -> Term t
> 
> that gets the result of the `typecheck' function as input.
> 
> The solution mentioned above uses Template Haskell to extract the 
> `Term t' type from the existential package and argues that type
> errors cannot occur during splicing.
> 
> Is there a possibility to avoid the existential and hence Template 
> Haskell?
> 
> Of course, the result type of typecheck depends on the type and
> type correctness of its input.
> 
> My idea was to express this dependency by parameterizing `Exp' and 
> using a type family `ExpType' like:
> 
>> typecheck :: Exp e -> Maybe (Term (ExpType e)) > typecheck (ELit 
>> i)
> = Just (TLit i) > typecheck (ESucc exp1) = case typecheck exp1 of
> > Nothing -> Nothing > Just t -> Just (TSucc t) > <...>
> 
> with
> 
>> data TEXP = L | S TEXP | IZ TEXP | I TEXP TEXP TEXP -- datakind
>> >
>>> 
> data Exp (e::TEXP) where > ELit :: Int -> Exp L > ESucc :: Exp e1
> -> Exp (S e1) > EIsZero :: Exp e1 -> Exp (IZ e1) > EIf :: Exp e1 ->
> Exp e2 -> Exp e3 -> Exp (I e1 e2 e3)
> 
> It seems to me that `ExpType' then would be a reification of the
> type checker for `Exp' at the type level. But I did not know how to
> define it. Does it make sense at all? Is it possible in GHC?
> 
> All the examples on the net I looked at either start with the GADT 
> right away or use Template Haskell at some point. So, perhaps this 
> `typecheck' function is not possible to write in GHC Haskell.
> 
> I very much appreciate any hints and explanations on this.
> 
> Best regards,
> 
> Florian
> 
> 
> 
> 
> _______________________________________________ Haskell-Cafe
> mailing list Haskell-Cafe at haskell.org
>  
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 

- -- 
Florian Lorenzen

Technische Universit?t Berlin
Fakult?t IV - Elektrotechnik und Informatik
?bersetzerbau und Programmiersprachen

Sekr. TEL12-2, Ernst-Reuter-Platz 7, D-10587 Berlin

Tel.:   +49 (30) 314-24618
E-Mail: florian.lorenzen at tu-berlin.de
WWW:    http://www.user.tu-berlin.de/florenz/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlBW24UACgkQvjzICpVvX7bWZACfVWRiNrJVl/ue5sk/AFsAK36m
zeUAniWoGahDymxAqkBK6JWQ5jNzDR6f
=FRcI
-----END PGP SIGNATURE-----


From edgar.klerks at gmail.com  Mon Sep 17 10:24:07 2012
From: edgar.klerks at gmail.com (Edgar Klerks)
Date: Mon, 17 Sep 2012 10:24:07 +0200
Subject: [Haskell-cafe] List indexer
In-Reply-To: <20120908065539.GA81973@scout.stangl.us>
References: <20120908065539.GA81973@scout.stangl.us>
Message-ID: 

Hi

I find it useful. I benchmarked it with criterion and your test file (see
below) and it is a *lot* faster:

warming up
estimating clock resolution...
mean is 3.776987 us (160001 iterations)
found 887 outliers among 159999 samples (0.6%)
  662 (0.4%) high severe
estimating cost of a clock call...
mean is 1.404134 us (27 iterations)
found 5 outliers among 27 samples (18.5%)
  1 (3.7%) low mild
  1 (3.7%) high mild
  3 (11.1%) high severe

benchmarking randAccess IndexList
mean: 2.614148 ms, lb 2.603860 ms, ub 2.642045 ms, ci 0.950
std dev: 79.90122 us, lb 33.73238 us, ub 165.6168 us, ci 0.950
found 13 outliers among 100 samples (13.0%)
  12 (12.0%) high severe
variance introduced by outliers: 25.781%
variance is moderately inflated by outliers

benchmarking randAccess list
mean: 42.62869 ms, lb 42.38446 ms, ub 43.48986 ms, ci 0.950
std dev: 2.088308 ms, lb 598.3515 us, ub 4.751391 ms, ci 0.950
found 3 outliers among 100 samples (3.0%)
  2 (2.0%) high severe
variance introduced by outliers: 47.437%
variance is moderately inflated by outliers

benchmarking seqAccess IndexList
mean: 6.347177 ms, lb 6.325560 ms, ub 6.369031 ms, ci 0.950
std dev: 111.3361 us, lb 102.5431 us, ub 123.4909 us, ci 0.950
variance introduced by outliers: 10.386%
variance is moderately inflated by outliers

benchmarking seqAccess list
collecting 100 samples, 1 iterations each, in estimated 207.9468 s
mean: 1.919024 s, lb 1.916933 s, ub 1.927423 s, ci 0.950
std dev: 19.69444 ms, lb 1.966086 ms, ub 46.74818 ms, ci 0.950


Maybe an elevator list is a nice name?

Greets,

Edgar


module Main where
import Criterion.Main
import System.Random
-- | Type of index wrapping an underlying list
data LI a = LI Int [LInode a]
data LInode a = LiNonLeaf (LInode a) (LInode a) | LiLeaf (LInode a) [a]

-- | Constructs index from specified list and fanout
fromList :: [a] -> Int -> LI a
fromList l fo =
  let topLevel = mkTopLevelNode l
      mkTopLevelNode l = LiLeaf (mkTopLevelNode (drop fo l)) l
      mkLevel plv = let lv = mkMidLevelNode plv
                    in lv : mkLevel lv
      mkMidLevelNode l = LiNonLeaf (mkMidLevelNode (nodeDrop fo l)) l
  in LI fo (topLevel : mkLevel topLevel)

-- drop i nodes from a linear node stream
nodeDrop :: Int -> LInode a -> LInode a
nodeDrop 0 n = n
nodeDrop i n = let i' = i - 1
               in case n of
                    LiNonLeaf n' _ -> nodeDrop i' n'
                    LiLeaf    n' _ -> nodeDrop i' n'

-- | access specified element of underlying list using index to speed access
(!) :: LI a -> Int -> a
(!) (LI fo ns) i =
  let getLevel k (n : ns) = let (q,r) = k `quotRem` fo
                                l = if q == 0
                                      then n
                                      else parent $ getLevel q ns
                            in nodeDrop r l
      parent (LiNonLeaf _ p) = p
      (q, r) = i `quotRem` fo
      (LiLeaf _ l) = getLevel q ns
  in l !! r

a = [1 :: Int ..]
b = fromList a 4

testSequential hi = [(!) b n | n <- [1,3..hi :: Int]]
testSequentialList hi = [a!!n | n <- [1,3..hi :: Int]]

randAccess hi =
             let seed = 12345813
                 g = mkStdGen seed
                 lst = [1,3..hi]
                 lst' = fromList lst 32
                 nIter = 1000
                 randR _ 0 = []
                 randR g n = let (a,g') = randomR (0, hi `div` 2 - 1) g
                                 n' = n - 1
                             --in (lst!!a) : randR g' n'
                             in (lst'!a) : randR g' n'
             in sum $ randR g nIter
-- main = putStrLn $ show $ randAccess

randAccessList  hi =
             let seed = 12345813
                 g = mkStdGen seed
                 lst = [1,3..hi]
                 nIter = 1000
                 randR _ 0 = []
                 randR g n = let (a,g') = randomR (0, hi `div` 2 - 1) g
                                 n' = n - 1
                             in (lst!!a) : randR g' n'
             in sum $ randR g nIter

main = let hi = 50000 in defaultMain [ bench "randAccess IndexList" (nf
(randAccess) hi),
                     bench "randAccess list" (nf (randAccessList) hi),
                     bench "seqAccess IndexList" (nf (testSequential) hi),
                     bench "seqAccess list" (nf (testSequentialList) hi)
                    ]


On Sat, Sep 8, 2012 at 8:55 AM, Alex Stangl  wrote:

> Hi,
>
> I have written a small "wrapper" to speed random-access to a list. The
> usage scenario I have in mind is a "stream" computation yielding an
> infinite list, and I want to randomly access elements w/o having to
> traverse the entire list from the beginning for each access.
>
> I suspected something similar must already exist, but nothing I looked
> at seemed to do the trick. IntMap seems to want a finite input list.
> Ditto for the various array types, except possibly dynamic array.
>
> Attached is the list indexer I came up with, and a small test program
> (I swap the commented-out lines to switch btw. list & list index tests).
> I am interested to hear any feedback on this -- whether it duplicates
> something that already exists, or whether there's a better approach, and
> comments on the code, etc. Also if somebody can suggest a better name
> (so as not to overlay the word index too much.) I'll publish it on
> hackage (or at least github) if people think it's useful. It sped up
> the program I initally wrote it for enormously.
>
> Thanks,
>
> Alex
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From rl at cse.unsw.edu.au  Mon Sep 17 15:07:41 2012
From: rl at cse.unsw.edu.au (Roman Leshchinskiy)
Date: Mon, 17 Sep 2012 14:07:41 +0100
Subject: [Haskell-cafe] Dynamic Programming with Data.Vector
In-Reply-To: 
References: 
Message-ID: 

Myles C. Maxfield wrote:
>
> Overall, I'm looking for a function, similar to Data.Vector's 'generate'
> function, but instead of the generation function taking the destination
> index, I'd like it to take the elements that have previously been
> constructed. Is there such a function? If there isn't one, is this kind of
> function feasible to write? If such a function doesn't exist and is
> feasible to write, I'd be happy to try to write and contribute it.

Indeed there is, it's called constructN (or constructrN if you want to
construct it right to left).

Roman





From myles.maxfield at gmail.com  Mon Sep 17 18:42:55 2012
From: myles.maxfield at gmail.com (Myles C. Maxfield)
Date: Mon, 17 Sep 2012 09:42:55 -0700
Subject: [Haskell-cafe] Dynamic Programming with Data.Vector
In-Reply-To: 
References: 
	
Message-ID: 

Aha there it is! Thanks so much. I didn't see it because it's under the
"Unfolding" section instead of the "Construction" section.

--Myles

On Mon, Sep 17, 2012 at 6:07 AM, Roman Leshchinskiy wrote:

> Myles C. Maxfield wrote:
> >
> > Overall, I'm looking for a function, similar to Data.Vector's 'generate'
> > function, but instead of the generation function taking the destination
> > index, I'd like it to take the elements that have previously been
> > constructed. Is there such a function? If there isn't one, is this kind
> of
> > function feasible to write? If such a function doesn't exist and is
> > feasible to write, I'd be happy to try to write and contribute it.
>
> Indeed there is, it's called constructN (or constructrN if you want to
> construct it right to left).
>
> Roman
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ryani.spam at gmail.com  Mon Sep 17 19:47:09 2012
From: ryani.spam at gmail.com (Ryan Ingram)
Date: Mon, 17 Sep 2012 10:47:09 -0700
Subject: [Haskell-cafe] guards in applicative style
In-Reply-To: 
References: 
Message-ID: 

Not exactly what you asked for, but...

    filter (uncurry somePredicate) $ (,) <$> list1 <*> list2

does the job.

Using only applicative operations, it's impossible to affect the 'shape' of
the result--this is the difference in power between applicative and monad.

  -- ryan


On Wed, Sep 12, 2012 at 7:40 AM, felipe zapata  wrote:

> Hi Haskellers,
>
> Suppose I have two list and I want to calculate
> the cartesian product between the two of them,
> constrained to a predicate.
> In List comprehension notation is just
>
> result = [ (x, y) | x <- list1, y <-list2, somePredicate x y ]
>
> or in monadic notation
>
> result = do
>  x <- list1
>  y <- list2
>  guard (somePredicate x y)
> return $ (x,y)
>
> Then I was wondering if we can do something similar using an applicative
> style
>
> result = (,) <$> list1 <*> list2 (somePredicate ???)
>
> The question is then,
> there is a way for defining a guard in applicative Style?
>
> Thanks in advance,
>
> Felipe Zapata.
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ryani.spam at gmail.com  Mon Sep 17 19:59:39 2012
From: ryani.spam at gmail.com (Ryan Ingram)
Date: Mon, 17 Sep 2012 10:59:39 -0700
Subject: [Haskell-cafe] Type error with Type families
In-Reply-To: 
References: 
Message-ID: 

The problem is that the function 'element' is ambiguous, for the reasons
MigMit pointed out.

The standard solution to this problem is to add a dummy argument to fix the
type argument to the type function:

data Proxy a = Proxy

class ... => ReplaceOneOf full where
    type Item full ::  *

    -- implementations can just ignore the first argument
    element :: Proxy full -> Item full -> [Item full] -> Bool

    replaceOneOf :: ...
        ...
        | element (Proxy :: Proxy full) x from = ...

Now the choice of which 'element' to use can be determined by the type of
the proxy.

  -- ryan

On Sun, Sep 16, 2012 at 4:05 AM, Marco T?lio Pimenta Gontijo <
marcotmarcot at gmail.com> wrote:

> Hi.
>
> I cannot make this program type check:
>
>     {-# LANGUAGE TypeFamilies, FlexibleContexts #-}
>     import qualified Data.ListLike as LL
>
>     class LL.ListLike full (Item full) => ReplaceOneOf full where
>       type Item full :: *
>       replaceOneOf :: [Item full] -> full -> full -> full
>       replaceOneOf from to list
>         | LL.null list = list
>         | x `element` from
>           = LL.concat [to, replaceOneOf from to $ LL.dropWhile
> (`element` from) xs]
>         | otherwise = LL.cons x $ replaceOneOf from to xs
>         where
>           x = LL.head list
>           xs = LL.tail list
>       element :: Item full -> [Item full] -> Bool
>
> The error message is:
>
>     Line 9: 1 error(s), 0 warning(s)
>
>     Could not deduce (Item full0 ~ Item full)
>     from the context (ReplaceOneOf full)
>       bound by the class declaration for `ReplaceOneOf'
>       at /home/marcot/tmp/test_flymake.hs:(4,1)-(15,45)
>     NB: `Item' is a type function, and may not be injective
>     Expected type: [Item full0]
>       Actual type: [Item full]
>     In the second argument of `element', namely `from'
>     In the expression: x `element` from
>
> I have tried using asTypeOf, but it did not work:
>
>     {-# LANGUAGE TypeFamilies, FlexibleContexts, ScopedTypeVariables #-}
>     import qualified Data.ListLike as LL
>
>     class LL.ListLike full (Item full) => ReplaceOneOf full where
>       type Item full :: *
>       replaceOneOf :: Item full -> [Item full] -> full -> full -> full
>       replaceOneOf xt from to list
>         | LL.null list = list
>         | (x `asTypeOf` xt) `element` from
>           = LL.concat [to, replaceOneOf xt from to $ LL.dropWhile
> (`element` from) xs]
>         | otherwise = LL.cons x $ replaceOneOf xt from to xs
>         where
>           x = LL.head list
>           xs = LL.tail list
>       element :: Item full -> [Item full] -> Bool
>
> Can someone point me to a solution?
>
> Greetings.
>
> --
> marcot
> http://marcot.eti.br/
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From alex.solla at gmail.com  Mon Sep 17 23:27:20 2012
From: alex.solla at gmail.com (Alexander Solla)
Date: Mon, 17 Sep 2012 14:27:20 -0700
Subject: [Haskell-cafe] Type error with Type families
In-Reply-To: 
References: 
	
Message-ID: 

On Mon, Sep 17, 2012 at 10:59 AM, Ryan Ingram  wrote:

> The problem is that the function 'element' is ambiguous, for the reasons
> MigMit pointed out.
>
> The standard solution to this problem is to add a dummy argument to fix
> the type argument to the type function:
>
> data Proxy a = Proxy
>
> class ... => ReplaceOneOf full where
>     type Item full ::  *
>
>     -- implementations can just ignore the first argument
>     element :: Proxy full -> Item full -> [Item full] -> Bool
>
>     replaceOneOf :: ...
>         ...
>         | element (Proxy :: Proxy full) x from = ...
>
> Now the choice of which 'element' to use can be determined by the type of
> the proxy.


It might be best if we point users to a "standard" Proxy type so we don't
end up lots of packages defining distinct/incompatible types for the same
code.

Edward Kmett's "tagged" package has a Proxy type.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From jwlato at gmail.com  Tue Sep 18 01:58:38 2012
From: jwlato at gmail.com (John Lato)
Date: Tue, 18 Sep 2012 07:58:38 +0800
Subject: [Haskell-cafe] Either Monad and Laziness
Message-ID: 

> Subject: Re: [Haskell-cafe] Either Monad and Laziness
>
> On 9/14/12 5:16 PM, Eric Velten de Melo wrote:
>> But now I'm kinda lost. Is there an easy way to explain the difference between:
>> -iteratee
>> -conduit
>> -enumerator

I tend to group them into three families.  'iteratee' and 'enumerator'
are fairly directly drawn from Oleg's code, with mostly implementation
differences (at least when compared to the other families).  They've
tended to keep Oleg's original names (iteratee, enumerator,
enumeratee).

The biggest user-visible difference between iteratee and enumerator is
the level of datastream abstraction.  iteratee abstracts over the
stream, and enumerator abstracts over elements of the stream.  The
stream is explicitly a list of elements.  This exposes some of the
details of data chunking to the user, which has both advantages and
disadvantages (iteratee exposes this also, but it's not necessary as
is the case for enumerator).

The second family (chronologically) includes conduit and (maybe)
iterIO.  I've written a little about this group at
http://johnlato.blogspot.sg/2012/06/understandings-of-iteratees.html
Although they serve the same goals in spirit, the implementation may
or may not necessarily be an iteratee/enumerator arrangement (e.g.
conduit).  This is a technical observation, not a criticism, depending
on exactly what you consider to define the style in the first place.
This group has usually renamed functions.  I discuss some of the other
differences on my blog.

The third familiy is all the pipes-* stuff.  This group tends towards
emphasizing the relationship between iteratee/enumerator pairs and
coroutines, and also emphasizing (to use Oleg terminology) composition
of enumeratees.  I've been meaning to write more about this group, but
thus far have been unable to do so.

I'd rather not hijack by evangelizing, but obviously I think iteratee
provides several important advantages over the other options.

John L.


From magicloud.magiclouds at gmail.com  Tue Sep 18 03:52:22 2012
From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds)
Date: Tue, 18 Sep 2012 09:52:22 +0800
Subject: [Haskell-cafe] What is the good way to work with list
 comprehension and UTCTime?
In-Reply-To: 
References: 
	<615D2378-2E08-41A4-AD95-BA869E72DDE3@cs.otago.ac.nz>
	
Message-ID: 

Thank you. Will do.

On Mon, Sep 17, 2012 at 7:14 AM, Antoine Latter  wrote:
> On Sun, Sep 16, 2012 at 5:04 PM, Richard O'Keefe  wrote:
>>
>> On 15/09/2012, at 5:14 AM, Chris Heller wrote:
>>
>>> You might want to have a look at the time-recurrence package: http://hackage.haskell.org/package/time-recurrence
>>>
>>> For your simple cases you would do something like:
>>>
>>> Each second:
>>>
>>>     starting (UTCTime ...) $ recur secondly
>>>
>>> Each minute:
>>>
>>>     starting (UTCTime ...) $ recur minutely
>>
>> Ouch.  Look up "minutely" (my-NEWT-ly) in an English
>> dictionary.  Look up "secondly" while you're there.
>>
>>
>
> You can blame RFC 5545 for that one. In section 3.3.10. our frequencies are:
>
> freq        = "SECONDLY" / "MINUTELY" / "HOURLY" / "DAILY"
>                    / "WEEKLY" / "MONTHLY" / "YEARLY"
>
> Antoine
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



-- 
???????
???????

And for G+, please use magiclouds#gmail.com.


From jose.lopes at ist.utl.pt  Tue Sep 18 05:09:54 2012
From: jose.lopes at ist.utl.pt (=?ISO-8859-1?Q?Jos=E9_Lopes?=)
Date: Tue, 18 Sep 2012 04:09:54 +0100
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
Message-ID: <5057E602.6040900@ist.utl.pt>

Hello everyone,

I just wanted to share a package I created called Fmark, now available
on HackageDB.

Feedback both on the project and on the code is greatly appreciated :)

Fmark (Friendly Markup) is a very simple markup language without
syntax and simple but sophisticated document styling, capable of
producing PDF and XML files.

The key philosophy behind this markup language is to eliminate the
strange syntactic characters seen in most markup languages, but
at the same time try to maintain a high level of expressiveness, using
only document reconstruction.

Check it out
http://hackage.haskell.org/package/fmark
https://github.com/jabolopes/fmark

Best regards,
Jos?

-- 
Jos? Ant?nio Branquinho de Oliveira Lopes
58612 - MEIC-A
Instituto Superior T?cnico (IST), Universidade T?cnica de Lisboa (UTL)
jose.lopes at ist.utl.pt



From krismicinski at gmail.com  Tue Sep 18 05:25:51 2012
From: krismicinski at gmail.com (Kristopher Micinski)
Date: Mon, 17 Sep 2012 23:25:51 -0400
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: <5057E602.6040900@ist.utl.pt>
References: <5057E602.6040900@ist.utl.pt>
Message-ID: 

Jose,

So I'm interested to hear you opinion on this as well...

I use Pandoc with Markdown through Hakyll, which allows you to do a
fair amount of cute things that are just really helpful for
maintaining a blog (for example..).  But I didn't get this from
reading your github readme: what makes your markup language special?
Could you give an example of how the language is more expressive than
(say) markdown processed through Pandoc (I only mention because it
lets you process LaTeX, very helpful, right...) or something
comparable?

kris

On Mon, Sep 17, 2012 at 11:09 PM, Jos? Lopes  wrote:
> Hello everyone,
>
> I just wanted to share a package I created called Fmark, now available
> on HackageDB.
>
> Feedback both on the project and on the code is greatly appreciated :)
>
> Fmark (Friendly Markup) is a very simple markup language without
> syntax and simple but sophisticated document styling, capable of
> producing PDF and XML files.
>
> The key philosophy behind this markup language is to eliminate the
> strange syntactic characters seen in most markup languages, but
> at the same time try to maintain a high level of expressiveness, using
> only document reconstruction.
>
> Check it out
> http://hackage.haskell.org/package/fmark
> https://github.com/jabolopes/fmark
>
> Best regards,
> Jos?
>
> --
> Jos? Ant?nio Branquinho de Oliveira Lopes
> 58612 - MEIC-A
> Instituto Superior T?cnico (IST), Universidade T?cnica de Lisboa (UTL)
> jose.lopes at ist.utl.pt
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


From jose.lopes at ist.utl.pt  Tue Sep 18 05:57:40 2012
From: jose.lopes at ist.utl.pt (=?ISO-8859-1?Q?Jos=E9_Lopes?=)
Date: Tue, 18 Sep 2012 04:57:40 +0100
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: 
References: <5057E602.6040900@ist.utl.pt>
	
Message-ID: <5057F134.8040304@ist.utl.pt>

Hello Kris,

Thank you for your email.

At this moment, Fmark is not as powerful as Markdown, also because Fmark 
just started.
Markdown offers things such as Blockquotes, Lists, Code blocks, links, 
emphasis, images, etc.
Fmark does not offer as many features: for now, there are only 
paragraphs, headings,
subsections (endless nesting) and footnotes. In the near future, I want 
to bolds/italics,
ordered and unordered lists, links, and later on as many elements as 
possible :)

The problem with Fmark is also its greatest feature. While other markup 
languages
introduce special syntactic characters to give meaning to the document's 
elements,
I would like to take a different approach: I want to use characters that 
people already
use in document writing to achieve the same result. For example, in 
Mediawiki a
heading is some text surrounded by equal signs. But in Fmark a heading 
is simply some
text that does not end in a punctuation character, such as period or an 
exclamation mark.
I argue that this is a more "natural" approach.

I want to find a natural way of not burdening the user with the task of 
having to learn
some special syntax in order to write a document. Instead I want to find 
"natural" ways
of writing and use those ways to reconstruct the elements in a document. 
Of course,
what is natural is subjective and that is why I want to find a good 
tradeoff between
expressiveness and simplicity in the syntax. For example, in Fmark a 
footnote is some
text surrounded by square brackets. Maybe you find this natural, maybe 
you don't. If a
handful of people defend a more natural way of writing footnotes I want 
to implement
the way they say. If there is a more natural way of doing this I want to 
find it. But for now
I think square brackets are better than the equal signs or any other 
strange syntactic
character such as exclamation marks and so on...

Another thing about Fmark is styles. I want to use fmark personally to 
write papers, using
Latex as backend. While experimenting with previous versions of Fmark I 
realized that I
could not specify the title, the author, the date, and the abstract. 
which are essential in a
paper. I came up with an idea which I think is quite interesting. I 
wrote another document
also using Fmark which only had the words "Title", "Author", "Date", and 
"Abstract". And
then I combined these two documents together, such that, Fmark 
associated title, author,
date and abstract, with the corresponding content. I thought the idea 
was interesting
because the content and style documents have both the same structure and 
are both
written in Fmark. Of course, there is still a long way to go, in order 
to be able to fully
customize a document.

But styles are a good and simple approach, similar to document classes 
in Latex: the idea is
to write one document (content) and then use multiple (predefined, user 
defined) styles, such
as, article, report, etc, to stylize your document. Another interesting 
thing I have been thinking
about (but not implemented yet) is recursion in document styling. In a 
way, weaving a style
with content can be compared to matching a regular expression.

Anyway, these are just some key ideas. I see Fmark as a work in progress 
and in a way as a
research project, trying to find a natural way of writing documents 
while escaping as much
as possible from the syntax of a programming language. I also have a 
metagoal with this
project: if my father (the non programming guy) could use it to write 
his PhD dissertation,
I would be quite happy :)

If you have any more questions I would be happy to answer.
But if you're interested in using markup languages for blogs perhaps a 
HTML backend
in Fmark would be more interesting for you. Although, XML + JavaScript + 
CSS is also possible.

Best regards,
Jos?

On 18-09-2012 04:25, Kristopher Micinski wrote:
> Jose,
>
> So I'm interested to hear you opinion on this as well...
>
> I use Pandoc with Markdown through Hakyll, which allows you to do a
> fair amount of cute things that are just really helpful for
> maintaining a blog (for example..).  But I didn't get this from
> reading your github readme: what makes your markup language special?
> Could you give an example of how the language is more expressive than
> (say) markdown processed through Pandoc (I only mention because it
> lets you process LaTeX, very helpful, right...) or something
> comparable?
>
> kris
>
> On Mon, Sep 17, 2012 at 11:09 PM, Jos? Lopes  wrote:
>> Hello everyone,
>>
>> I just wanted to share a package I created called Fmark, now available
>> on HackageDB.
>>
>> Feedback both on the project and on the code is greatly appreciated :)
>>
>> Fmark (Friendly Markup) is a very simple markup language without
>> syntax and simple but sophisticated document styling, capable of
>> producing PDF and XML files.
>>
>> The key philosophy behind this markup language is to eliminate the
>> strange syntactic characters seen in most markup languages, but
>> at the same time try to maintain a high level of expressiveness, using
>> only document reconstruction.
>>
>> Check it out
>> http://hackage.haskell.org/package/fmark
>> https://github.com/jabolopes/fmark
>>
>> Best regards,
>> Jos?
>>
>> --
>> Jos? Ant?nio Branquinho de Oliveira Lopes
>> 58612 - MEIC-A
>> Instituto Superior T?cnico (IST), Universidade T?cnica de Lisboa (UTL)
>> jose.lopes at ist.utl.pt
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe

-- 
Jos? Ant?nio Branquinho de Oliveira Lopes
Instituto Superior T?cnico
Technical University of Lisbon



From ok at cs.otago.ac.nz  Tue Sep 18 06:00:49 2012
From: ok at cs.otago.ac.nz (Richard O'Keefe)
Date: Tue, 18 Sep 2012 16:00:49 +1200
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: <5057E602.6040900@ist.utl.pt>
References: <5057E602.6040900@ist.utl.pt>
Message-ID: 


On 18/09/2012, at 3:09 PM, Jos? Lopes wrote:
> Fmark (Friendly Markup) is a very simple markup language without
> syntax and simple but sophisticated document styling, capable of
> producing PDF and XML files.

Do you _really_ mean "without syntax"?

Nope, thought not:

	Fmark relies merely on spacing, indentation,
	and common punctuation (e.g., periods, exclamation
	and interrogation marks) to reconstruct the structure
	of your document.

That's SYNTAX.

A markup language without syntax is like a meal without food.



From trivmanish at gmail.com  Tue Sep 18 06:40:19 2012
From: trivmanish at gmail.com (Manish Trivedi)
Date: Mon, 17 Sep 2012 21:40:19 -0700
Subject: [Haskell-cafe] Choosing color of the track
Message-ID: 

Hi Folks,

I am trying to plot two tracks with different colors.
Following is my input file,

------
2012-09-18 00:10:48,166 @CurrentPerHour13057 Red
2012-09-18 00:10:48,166 =CurrentPerHour13057 0.0
2012-09-18 00:10:58,155 =CurrentPerHour13057 0.0
2012-09-18 00:11:08,203 =CurrentPerHour13057 0.0
2012-09-18 00:11:18,166 =CurrentPerHour13057 0.0
2012-09-18 00:11:28,159 =CurrentPerHour13057 0.0
2012-09-18 00:11:38,170 =CurrentPerHour13057 0.0
2012-09-18 00:11:48,175 =CurrentPerHour13057 0.0
2012-09-18 00:11:58,174 =CurrentPerHour13057 0.0
2012-09-18 00:12:08,216 =CurrentPerHour13057 0.0
2012-09-18 00:12:18,218 =CurrentPerHour13057 0.0
2012-09-18 03:58:28,159 @PacingReqPerHr13057 Blue
2012-09-18 03:58:28,159 =PacingReqPerHr13057 2375.0534412521242
2012-09-18 03:58:38,161 =PacingReqPerHr13057 2375.383005739316
2012-09-18 03:58:48,175 =PacingReqPerHr13057 2375.713057258422
2012-09-18 03:58:58,160 =PacingReqPerHr13057 2376.0422443063935
2012-09-18 03:59:08,192 =PacingReqPerHr13057 2376.3730727321126
2012-09-18 03:59:18,207 =PacingReqPerHr13057 2375.9038854561304
2012-09-18 03:59:28,168 =PacingReqPerHr13057 2376.2324444615497
2012-09-18 03:59:38,156 =PacingReqPerHr13057 2376.5619853019184
2012-09-18 03:59:48,160 =PacingReqPerHr13057 2376.892145685344
2012-09-18 03:59:58,160 =PacingReqPerHr13057 2377.222265743067
-----

tplot -o /root/color.png  -or 1024x768 -k 'CurrentPerHour' 'lines' -k
'PacingReqPerHr' 'lines' -if /root/color.input -tf 'date %Y-%m-%d %H:%M:%OS'

I cant get to print plots in different color. Could anyone point out what
am I doing wrong?

Thanks,
Manish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ivan.miljenovic at gmail.com  Tue Sep 18 07:05:38 2012
From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic)
Date: Tue, 18 Sep 2012 15:05:38 +1000
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: <5057F134.8040304@ist.utl.pt>
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
Message-ID: 

On 18 September 2012 13:57, Jos? Lopes  wrote:
> Hello Kris,
>
> Thank you for your email.
>
> At this moment, Fmark is not as powerful as Markdown, also because Fmark
> just started.
> Markdown offers things such as Blockquotes, Lists, Code blocks, links,
> emphasis, images, etc.
> Fmark does not offer as many features: for now, there are only paragraphs,
> headings,
> subsections (endless nesting) and footnotes. In the near future, I want to
> bolds/italics,
> ordered and unordered lists, links, and later on as many elements as
> possible :)
>
> The problem with Fmark is also its greatest feature. While other markup
> languages
> introduce special syntactic characters to give meaning to the document's
> elements,
> I would like to take a different approach: I want to use characters that
> people already
> use in document writing to achieve the same result. For example, in
> Mediawiki a
> heading is some text surrounded by equal signs. But in Fmark a heading is
> simply some
> text that does not end in a punctuation character, such as period or an
> exclamation mark.
> I argue that this is a more "natural" approach.

Is it possible to override this?  What happens if I want a heading of
"This is the greatest Heading Ever!!!!!" ?

"Natural" conventions seem to be to be rather hacky and with lots of
corner cases; I think it's better to define a specific syntax for
markup (e.g. what is the "natural" way of emphasising text?) and stick
to it (though I agree that Markdown has some odd choices; in
particular, the ability to use both _ and * for italics whilst
requiring ** for bold).

>
> I want to find a natural way of not burdening the user with the task of
> having to learn
> some special syntax in order to write a document. Instead I want to find
> "natural" ways
> of writing and use those ways to reconstruct the elements in a document. Of
> course,
> what is natural is subjective and that is why I want to find a good tradeoff
> between
> expressiveness and simplicity in the syntax. For example, in Fmark a
> footnote is some
> text surrounded by square brackets. Maybe you find this natural, maybe you
> don't. If a
> handful of people defend a more natural way of writing footnotes I want to
> implement
> the way they say. If there is a more natural way of doing this I want to
> find it. But for now
> I think square brackets are better than the equal signs or any other strange
> syntactic
> character such as exclamation marks and so on...
>
> Another thing about Fmark is styles. I want to use fmark personally to write
> papers, using
> Latex as backend. While experimenting with previous versions of Fmark I
> realized that I
> could not specify the title, the author, the date, and the abstract. which
> are essential in a
> paper. I came up with an idea which I think is quite interesting. I wrote
> another document
> also using Fmark which only had the words "Title", "Author", "Date", and
> "Abstract". And
> then I combined these two documents together, such that, Fmark associated
> title, author,
> date and abstract, with the corresponding content. I thought the idea was
> interesting
> because the content and style documents have both the same structure and are
> both
> written in Fmark. Of course, there is still a long way to go, in order to be
> able to fully
> customize a document.
>
> But styles are a good and simple approach, similar to document classes in
> Latex: the idea is
> to write one document (content) and then use multiple (predefined, user
> defined) styles, such
> as, article, report, etc, to stylize your document. Another interesting
> thing I have been thinking
> about (but not implemented yet) is recursion in document styling. In a way,
> weaving a style
> with content can be compared to matching a regular expression.
>
> Anyway, these are just some key ideas. I see Fmark as a work in progress and
> in a way as a
> research project, trying to find a natural way of writing documents while
> escaping as much
> as possible from the syntax of a programming language. I also have a
> metagoal with this
> project: if my father (the non programming guy) could use it to write his
> PhD dissertation,
> I would be quite happy :)
>
> If you have any more questions I would be happy to answer.
> But if you're interested in using markup languages for blogs perhaps a HTML
> backend
> in Fmark would be more interesting for you. Although, XML + JavaScript + CSS
> is also possible.
>
> Best regards,
> Jos?
>
>
> On 18-09-2012 04:25, Kristopher Micinski wrote:
>>
>> Jose,
>>
>> So I'm interested to hear you opinion on this as well...
>>
>> I use Pandoc with Markdown through Hakyll, which allows you to do a
>> fair amount of cute things that are just really helpful for
>> maintaining a blog (for example..).  But I didn't get this from
>> reading your github readme: what makes your markup language special?
>> Could you give an example of how the language is more expressive than
>> (say) markdown processed through Pandoc (I only mention because it
>> lets you process LaTeX, very helpful, right...) or something
>> comparable?
>>
>> kris
>>
>> On Mon, Sep 17, 2012 at 11:09 PM, Jos? Lopes 
>> wrote:
>>>
>>> Hello everyone,
>>>
>>> I just wanted to share a package I created called Fmark, now available
>>> on HackageDB.
>>>
>>> Feedback both on the project and on the code is greatly appreciated :)
>>>
>>> Fmark (Friendly Markup) is a very simple markup language without
>>> syntax and simple but sophisticated document styling, capable of
>>> producing PDF and XML files.
>>>
>>> The key philosophy behind this markup language is to eliminate the
>>> strange syntactic characters seen in most markup languages, but
>>> at the same time try to maintain a high level of expressiveness, using
>>> only document reconstruction.
>>>
>>> Check it out
>>> http://hackage.haskell.org/package/fmark
>>> https://github.com/jabolopes/fmark
>>>
>>> Best regards,
>>> Jos?
>>>
>>> --
>>> Jos? Ant?nio Branquinho de Oliveira Lopes
>>> 58612 - MEIC-A
>>> Instituto Superior T?cnico (IST), Universidade T?cnica de Lisboa (UTL)
>>> jose.lopes at ist.utl.pt
>>>
>>>
>>> _______________________________________________
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
>>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
> --
> Jos? Ant?nio Branquinho de Oliveira Lopes
> Instituto Superior T?cnico
> Technical University of Lisbon
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com


From ok at cs.otago.ac.nz  Tue Sep 18 07:19:42 2012
From: ok at cs.otago.ac.nz (Richard O'Keefe)
Date: Tue, 18 Sep 2012 17:19:42 +1200
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: <5057F134.8040304@ist.utl.pt>
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
Message-ID: 


On 18/09/2012, at 3:57 PM, Jos? Lopes wrote:
> The problem with Fmark is also its greatest feature. While other markup languages
> introduce special syntactic characters to give meaning to the document's elements,
> I would like to take a different approach: I want to use characters that people already
> use in document writing to achieve the same result. For example, in Mediawiki a
> heading is some text surrounded by equal signs. But in Fmark a heading is simply some
> text that does not end in a punctuation character, such as period or an exclamation mark.
> I argue that this is a more "natural" approach.

The problem with that is that some people DO end some headings with
a full stop; for them your special syntax is not natural.
> 
> I want to find a natural way of not burdening the user with the task of having to learn
> some special syntax in order to write a document.

You haven't found it.  What you *have* is very special syntax expressed using
several methods, AND IT IS NOT DOCUMENTED.  I have read the examples, and I can
find nothing explaining what the syntax is.

For example, I find indenting subsections rather unnatural and error-prone.
(For example, moving a paragraph from a deep location to a shallow one would
create a new subsection unintentionally.)
Is the amount of indentation fixed?  How many levels of subsections are
supported?  What if I want to use indentation to express quotation instead?
How do I embed source code?  How can you get an example of Fmark in an
Fmark document without having it acted on?  I could go on and on with
questions about syntax.




From ekirpichov at gmail.com  Tue Sep 18 07:48:54 2012
From: ekirpichov at gmail.com (Eugene Kirpichov)
Date: Mon, 17 Sep 2012 22:48:54 -0700
Subject: [Haskell-cafe] Choosing color of the track
In-Reply-To: 
References: 
Message-ID: <6EC4F113-47A4-4C21-BB66-D4FB7C989D66@gmail.com>

Hi,

I'm the author and I'll reply tomorrow, sorry, going to sleep now :) thanks for the interest in the tools anyway!



17.09.2012, ? 21:40, Manish Trivedi  ???????(?):

> Hi Folks,
> 
> I am trying to plot two tracks with different colors.
> Following is my input file,
> 
> ------
> 2012-09-18 00:10:48,166 @CurrentPerHour13057 Red
> 2012-09-18 00:10:48,166 =CurrentPerHour13057 0.0
> 2012-09-18 00:10:58,155 =CurrentPerHour13057 0.0
> 2012-09-18 00:11:08,203 =CurrentPerHour13057 0.0
> 2012-09-18 00:11:18,166 =CurrentPerHour13057 0.0
> 2012-09-18 00:11:28,159 =CurrentPerHour13057 0.0
> 2012-09-18 00:11:38,170 =CurrentPerHour13057 0.0
> 2012-09-18 00:11:48,175 =CurrentPerHour13057 0.0
> 2012-09-18 00:11:58,174 =CurrentPerHour13057 0.0
> 2012-09-18 00:12:08,216 =CurrentPerHour13057 0.0
> 2012-09-18 00:12:18,218 =CurrentPerHour13057 0.0
> 2012-09-18 03:58:28,159 @PacingReqPerHr13057 Blue
> 2012-09-18 03:58:28,159 =PacingReqPerHr13057 2375.0534412521242
> 2012-09-18 03:58:38,161 =PacingReqPerHr13057 2375.383005739316
> 2012-09-18 03:58:48,175 =PacingReqPerHr13057 2375.713057258422
> 2012-09-18 03:58:58,160 =PacingReqPerHr13057 2376.0422443063935
> 2012-09-18 03:59:08,192 =PacingReqPerHr13057 2376.3730727321126
> 2012-09-18 03:59:18,207 =PacingReqPerHr13057 2375.9038854561304
> 2012-09-18 03:59:28,168 =PacingReqPerHr13057 2376.2324444615497
> 2012-09-18 03:59:38,156 =PacingReqPerHr13057 2376.5619853019184
> 2012-09-18 03:59:48,160 =PacingReqPerHr13057 2376.892145685344
> 2012-09-18 03:59:58,160 =PacingReqPerHr13057 2377.222265743067
> -----
> 
> tplot -o /root/color.png  -or 1024x768 -k 'CurrentPerHour' 'lines' -k 'PacingReqPerHr' 'lines' -if /root/color.input -tf 'date %Y-%m-%d %H:%M:%OS'
> 
> I cant get to print plots in different color. Could anyone point out what am I doing wrong?
> 
> Thanks,
> Manish
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


From rl at cse.unsw.edu.au  Tue Sep 18 09:36:06 2012
From: rl at cse.unsw.edu.au (Roman Leshchinskiy)
Date: Tue, 18 Sep 2012 08:36:06 +0100
Subject: [Haskell-cafe] Dynamic Programming with Data.Vector
In-Reply-To: 
References: 
	
	
Message-ID: 

Myles C. Maxfield wrote:
> Aha there it is! Thanks so much. I didn't see it because it's under the
> "Unfolding" section instead of the "Construction" section.

You're quite right, having a separate "Unfolding" section isn't the best
idea. I'll fix this.

Roman

> On Mon, Sep 17, 2012 at 6:07 AM, Roman Leshchinskiy
> wrote:
>
>> Myles C. Maxfield wrote:
>> >
>> > Overall, I'm looking for a function, similar to Data.Vector's
>> 'generate'
>> > function, but instead of the generation function taking the
>> destination
>> > index, I'd like it to take the elements that have previously been
>> > constructed. Is there such a function? If there isn't one, is this
>> kind
>> of
>> > function feasible to write? If such a function doesn't exist and is
>> > feasible to write, I'd be happy to try to write and contribute it.
>>
>> Indeed there is, it's called constructN (or constructrN if you want to
>> construct it right to left).
>>
>> Roman
>>
>>
>>
>>
>




From oleg at okmij.org  Tue Sep 18 10:27:36 2012
From: oleg at okmij.org (oleg at okmij.org)
Date: 18 Sep 2012 08:27:36 -0000
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
Message-ID: <20120918082736.61798.qmail@www1.g3.pair.com>


There has been a recent discussion of ``Church encoding'' of lists and
the comparison with Scott encoding.

I'd like to point out that what is often called Church encoding is
actually Boehm-Berarducci encoding. That is, often seen

> newtype ChurchList a =
>     CL { cataCL :: forall r. (a -> r -> r) -> r -> r }

(in http://community.haskell.org/%7Ewren/list-extras/Data/List/Church.hs )

is _not_ Church encoding. First of all, Church encoding is not typed
and it is not tight. The following article explains the other
difference between the encodings

	http://okmij.org/ftp/tagless-final/course/Boehm-Berarducci.html

Boehm-Berarducci encoding is very insightful and influential. The
authors truly deserve credit.

P.S. It is actually possible to write zip function using Boehm-Berarducci
encoding:
	http://okmij.org/ftp/ftp/Algorithms.html#zip-folds





From ivan.miljenovic at gmail.com  Tue Sep 18 11:07:30 2012
From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic)
Date: Tue, 18 Sep 2012 19:07:30 +1000
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
In-Reply-To: <20120918082736.61798.qmail@www1.g3.pair.com>
References: <20120918082736.61798.qmail@www1.g3.pair.com>
Message-ID: 

On 18 September 2012 18:27,   wrote:
>
> There has been a recent discussion of ``Church encoding'' of lists and
> the comparison with Scott encoding.
>
> I'd like to point out that what is often called Church encoding is
> actually Boehm-Berarducci encoding. That is, often seen
>
>> newtype ChurchList a =
>>     CL { cataCL :: forall r. (a -> r -> r) -> r -> r }
>
> (in http://community.haskell.org/%7Ewren/list-extras/Data/List/Church.hs )
>
> is _not_ Church encoding. First of all, Church encoding is not typed
> and it is not tight. The following article explains the other
> difference between the encodings
>
>         http://okmij.org/ftp/tagless-final/course/Boehm-Berarducci.html
>
> Boehm-Berarducci encoding is very insightful and influential. The
> authors truly deserve credit.
>
> P.S. It is actually possible to write zip function using Boehm-Berarducci
> encoding:
>         http://okmij.org/ftp/ftp/Algorithms.html#zip-folds

You have one too many "ftp/" in there (in case others get confused
about why the link fails).

>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com


From ky3 at atamo.com  Tue Sep 18 11:15:52 2012
From: ky3 at atamo.com (Kim-Ee Yeoh)
Date: Tue, 18 Sep 2012 16:15:52 +0700
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
In-Reply-To: <20120918082736.61798.qmail@www1.g3.pair.com>
References: <20120918082736.61798.qmail@www1.g3.pair.com>
Message-ID: 

Oleg,

Let me try to understand what you're saying here:

(1) Church encoding was discovered and investigated in an untyped setting.
I understand your tightness criterion to mean surjectivity, the absence of
which means having to deal with junk.

(2) Church didn't give an encoding for pattern-matching to match with
construction. Boehm and Berarducci did. So properly speaking, tail and pred
for Church-encoded lists and nats are trial-and-error affairs. But the
point is they need not be if we use B-B encoding, which looks _exactly_ the
same, except one gets a citation link to a systematic procedure.

So it looks like you're trying to set the record straight on who actually
did what.


-- Kim-Ee


On Tue, Sep 18, 2012 at 3:27 PM,  wrote:

>
> There has been a recent discussion of ``Church encoding'' of lists and
> the comparison with Scott encoding.
>
> I'd like to point out that what is often called Church encoding is
> actually Boehm-Berarducci encoding. That is, often seen
>
> > newtype ChurchList a =
> >     CL { cataCL :: forall r. (a -> r -> r) -> r -> r }
>
> (in http://community.haskell.org/%7Ewren/list-extras/Data/List/Church.hs
>  )
>
> is _not_ Church encoding. First of all, Church encoding is not typed
> and it is not tight. The following article explains the other
> difference between the encodings
>
>         http://okmij.org/ftp/tagless-final/course/Boehm-Berarducci.html
>
> Boehm-Berarducci encoding is very insightful and influential. The
> authors truly deserve credit.
>
> P.S. It is actually possible to write zip function using Boehm-Berarducci
> encoding:
>         http://okmij.org/ftp/ftp/Algorithms.html#zip-folds
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From malcolm.wallace at me.com  Tue Sep 18 13:22:35 2012
From: malcolm.wallace at me.com (Malcolm Wallace)
Date: Tue, 18 Sep 2012 12:22:35 +0100
Subject: [Haskell-cafe] Either Monad and Laziness
In-Reply-To: 
References: <20120912060330.83793.qmail@www1.g3.pair.com>
	
	
Message-ID: <5C58E78D-85BF-40C5-A84A-2A30B0794647@me.com>


On 12 Sep 2012, at 16:04, Eric Velten de Melo wrote:

>>>> The behaviour I want to achieve is like this: I want the program when
>>>> compiled to read from a file, parsing the PGM and at the same time
>>>> apply transformations to the entries as they are read and write them
>>>> back to another PGM file.
>>> 
>>> Such problems are the main motivation for iteratees, conduits, pipes,
>>> etc. Every such library contains procedures for doing exactly what you
>>> want.
>>> 
> 
> It would be really awesome, though, if it were possible to use a
> parser written in Parsec with this, in the spirit of avoiding code
> rewriting and enhancing expressivity and abstraction.

The polyparse library on Hackage is another parser combinator framework that allows lazy incremental parsing.
http://hackage.haskell.org/package/polyparse

A PDF paper/tutorial is here:
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.118.1754&rep=rep1&type=pdf

Regards,
    Malcolm


From jose.lopes at ist.utl.pt  Tue Sep 18 13:53:08 2012
From: jose.lopes at ist.utl.pt (=?ISO-8859-1?Q?Jos=E9_Lopes?=)
Date: Tue, 18 Sep 2012 12:53:08 +0100
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: 
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
	
Message-ID: <505860A4.6020106@ist.utl.pt>

Hello Ivan,

I agree with your point: if you want a heading that ends with a punctuation
sign then you cannot do it in Fmark (for now). That gives me something to
think about. However, I will still look for a way that avoids (as much as
possible) special syntax. Do you have any suggestion?

I also agree with you on the "natural" conventions. I want to find a good
tradeoff between syntax and expressiveness. In other words, I want to
avoid as much those "odd choices" you mentioned. For example, I have
been thinking seriously about emphasis and what would be a good way
to do it. So far I could only come up with quotes (either " or '). What do
you think?

Cheers,
Jos?

On 18-09-2012 06:05, Ivan Lazar Miljenovic wrote:
> On 18 September 2012 13:57, Jos? Lopes  wrote:
>> Hello Kris,
>>
>> Thank you for your email.
>>
>> At this moment, Fmark is not as powerful as Markdown, also because Fmark
>> just started.
>> Markdown offers things such as Blockquotes, Lists, Code blocks, links,
>> emphasis, images, etc.
>> Fmark does not offer as many features: for now, there are only paragraphs,
>> headings,
>> subsections (endless nesting) and footnotes. In the near future, I want to
>> bolds/italics,
>> ordered and unordered lists, links, and later on as many elements as
>> possible :)
>>
>> The problem with Fmark is also its greatest feature. While other markup
>> languages
>> introduce special syntactic characters to give meaning to the document's
>> elements,
>> I would like to take a different approach: I want to use characters that
>> people already
>> use in document writing to achieve the same result. For example, in
>> Mediawiki a
>> heading is some text surrounded by equal signs. But in Fmark a heading is
>> simply some
>> text that does not end in a punctuation character, such as period or an
>> exclamation mark.
>> I argue that this is a more "natural" approach.
> Is it possible to override this?  What happens if I want a heading of
> "This is the greatest Heading Ever!!!!!" ?
>
> "Natural" conventions seem to be to be rather hacky and with lots of
> corner cases; I think it's better to define a specific syntax for
> markup (e.g. what is the "natural" way of emphasising text?) and stick
> to it (though I agree that Markdown has some odd choices; in
> particular, the ability to use both _ and * for italics whilst
> requiring ** for bold).
>
>> I want to find a natural way of not burdening the user with the task of
>> having to learn
>> some special syntax in order to write a document. Instead I want to find
>> "natural" ways
>> of writing and use those ways to reconstruct the elements in a document. Of
>> course,
>> what is natural is subjective and that is why I want to find a good tradeoff
>> between
>> expressiveness and simplicity in the syntax. For example, in Fmark a
>> footnote is some
>> text surrounded by square brackets. Maybe you find this natural, maybe you
>> don't. If a
>> handful of people defend a more natural way of writing footnotes I want to
>> implement
>> the way they say. If there is a more natural way of doing this I want to
>> find it. But for now
>> I think square brackets are better than the equal signs or any other strange
>> syntactic
>> character such as exclamation marks and so on...
>>
>> Another thing about Fmark is styles. I want to use fmark personally to write
>> papers, using
>> Latex as backend. While experimenting with previous versions of Fmark I
>> realized that I
>> could not specify the title, the author, the date, and the abstract. which
>> are essential in a
>> paper. I came up with an idea which I think is quite interesting. I wrote
>> another document
>> also using Fmark which only had the words "Title", "Author", "Date", and
>> "Abstract". And
>> then I combined these two documents together, such that, Fmark associated
>> title, author,
>> date and abstract, with the corresponding content. I thought the idea was
>> interesting
>> because the content and style documents have both the same structure and are
>> both
>> written in Fmark. Of course, there is still a long way to go, in order to be
>> able to fully
>> customize a document.
>>
>> But styles are a good and simple approach, similar to document classes in
>> Latex: the idea is
>> to write one document (content) and then use multiple (predefined, user
>> defined) styles, such
>> as, article, report, etc, to stylize your document. Another interesting
>> thing I have been thinking
>> about (but not implemented yet) is recursion in document styling. In a way,
>> weaving a style
>> with content can be compared to matching a regular expression.
>>
>> Anyway, these are just some key ideas. I see Fmark as a work in progress and
>> in a way as a
>> research project, trying to find a natural way of writing documents while
>> escaping as much
>> as possible from the syntax of a programming language. I also have a
>> metagoal with this
>> project: if my father (the non programming guy) could use it to write his
>> PhD dissertation,
>> I would be quite happy :)
>>
>> If you have any more questions I would be happy to answer.
>> But if you're interested in using markup languages for blogs perhaps a HTML
>> backend
>> in Fmark would be more interesting for you. Although, XML + JavaScript + CSS
>> is also possible.
>>
>> Best regards,
>> Jos?
>>
>>
>> On 18-09-2012 04:25, Kristopher Micinski wrote:
>>> Jose,
>>>
>>> So I'm interested to hear you opinion on this as well...
>>>
>>> I use Pandoc with Markdown through Hakyll, which allows you to do a
>>> fair amount of cute things that are just really helpful for
>>> maintaining a blog (for example..).  But I didn't get this from
>>> reading your github readme: what makes your markup language special?
>>> Could you give an example of how the language is more expressive than
>>> (say) markdown processed through Pandoc (I only mention because it
>>> lets you process LaTeX, very helpful, right...) or something
>>> comparable?
>>>
>>> kris
>>>
>>> On Mon, Sep 17, 2012 at 11:09 PM, Jos? Lopes 
>>> wrote:
>>>> Hello everyone,
>>>>
>>>> I just wanted to share a package I created called Fmark, now available
>>>> on HackageDB.
>>>>
>>>> Feedback both on the project and on the code is greatly appreciated :)
>>>>
>>>> Fmark (Friendly Markup) is a very simple markup language without
>>>> syntax and simple but sophisticated document styling, capable of
>>>> producing PDF and XML files.
>>>>
>>>> The key philosophy behind this markup language is to eliminate the
>>>> strange syntactic characters seen in most markup languages, but
>>>> at the same time try to maintain a high level of expressiveness, using
>>>> only document reconstruction.
>>>>
>>>> Check it out
>>>> http://hackage.haskell.org/package/fmark
>>>> https://github.com/jabolopes/fmark
>>>>
>>>> Best regards,
>>>> Jos?
>>>>
>>>> --
>>>> Jos? Ant?nio Branquinho de Oliveira Lopes
>>>> 58612 - MEIC-A
>>>> Instituto Superior T?cnico (IST), Universidade T?cnica de Lisboa (UTL)
>>>> jose.lopes at ist.utl.pt
>>>>
>>>>
>>>> _______________________________________________
>>>> Haskell-Cafe mailing list
>>>> Haskell-Cafe at haskell.org
>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>> --
>> Jos? Ant?nio Branquinho de Oliveira Lopes
>> Instituto Superior T?cnico
>> Technical University of Lisbon
>>
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>

-- 
Jos? Ant?nio Branquinho de Oliveira Lopes
Instituto Superior T?cnico
Technical University of Lisbon



From jose.lopes at ist.utl.pt  Tue Sep 18 14:04:37 2012
From: jose.lopes at ist.utl.pt (=?ISO-8859-1?Q?Jos=E9_Lopes?=)
Date: Tue, 18 Sep 2012 13:04:37 +0100
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: 
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
	
Message-ID: <50586355.3040100@ist.utl.pt>

Hello Richard,

When you say "(for) some people (...) you special syntax is not natural"
that's a good thing. I want these people involved in the project. I want
to understand what they find natural in order to weigh the options and
make a proper decision.

On the README file in the github page you will find a brief explanation
of the markup elements. I need to elaborate you that though because
I feel I explain it too fast.
https://github.com/jabolopes/fmark

Let me answer your questions about sections. The amount of indentation
is not fixed. You can use whatever you want. There is also no nesting limit
in Fmark, however, there is a nesting limit in the Latex backend. For now,
quotations, block quotes, source code embedding, etc, are not implemented.
Those will be added in the future.

About embedding a Fmark document in another document. That seems to
be a very cool feature. I will definitely think about it! Maybe you can come
up with a "natural" way of doing it?

Cheers,
Jos?


On 18-09-2012 06:19, Richard O'Keefe wrote:
> On 18/09/2012, at 3:57 PM, Jos? Lopes wrote:
>> The problem with Fmark is also its greatest feature. While other markup languages
>> introduce special syntactic characters to give meaning to the document's elements,
>> I would like to take a different approach: I want to use characters that people already
>> use in document writing to achieve the same result. For example, in Mediawiki a
>> heading is some text surrounded by equal signs. But in Fmark a heading is simply some
>> text that does not end in a punctuation character, such as period or an exclamation mark.
>> I argue that this is a more "natural" approach.
> The problem with that is that some people DO end some headings with
> a full stop; for them your special syntax is not natural.
>> I want to find a natural way of not burdening the user with the task of having to learn
>> some special syntax in order to write a document.
> You haven't found it.  What you *have* is very special syntax expressed using
> several methods, AND IT IS NOT DOCUMENTED.  I have read the examples, and I can
> find nothing explaining what the syntax is.
>
> For example, I find indenting subsections rather unnatural and error-prone.
> (For example, moving a paragraph from a deep location to a shallow one would
> create a new subsection unintentionally.)
> Is the amount of indentation fixed?  How many levels of subsections are
> supported?  What if I want to use indentation to express quotation instead?
> How do I embed source code?  How can you get an example of Fmark in an
> Fmark document without having it acted on?  I could go on and on with
> questions about syntax.
>
>

-- 
Jos? Ant?nio Branquinho de Oliveira Lopes
Instituto Superior T?cnico
Technical University of Lisbon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ivan.miljenovic at gmail.com  Tue Sep 18 14:18:34 2012
From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic)
Date: Tue, 18 Sep 2012 22:18:34 +1000
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: <505860A4.6020106@ist.utl.pt>
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
	
	<505860A4.6020106@ist.utl.pt>
Message-ID: 

On 18 September 2012 21:53, Jos? Lopes  wrote:
> Hello Ivan,
>
> I agree with your point: if you want a heading that ends with a punctuation
> sign then you cannot do it in Fmark (for now). That gives me something to
> think about. However, I will still look for a way that avoids (as much as
> possible) special syntax. Do you have any suggestion?
>
> I also agree with you on the "natural" conventions. I want to find a good
> tradeoff between syntax and expressiveness. In other words, I want to
> avoid as much those "odd choices" you mentioned. For example, I have
> been thinking seriously about emphasis and what would be a good way
> to do it. So far I could only come up with quotes (either " or '). What do
> you think?

I think that _emphasis_ is pretty "natural", as is *bold* and possibly
-strikethrough-.

But you _are_ adding in some aspects of markup now.

Using quotes is bad because what happens if you're actually quoting someone? ;-)

>
> Cheers,
> Jos?
>
>
> On 18-09-2012 06:05, Ivan Lazar Miljenovic wrote:
>>
>> On 18 September 2012 13:57, Jos? Lopes  wrote:
>>>
>>> Hello Kris,
>>>
>>> Thank you for your email.
>>>
>>> At this moment, Fmark is not as powerful as Markdown, also because Fmark
>>> just started.
>>> Markdown offers things such as Blockquotes, Lists, Code blocks, links,
>>> emphasis, images, etc.
>>> Fmark does not offer as many features: for now, there are only
>>> paragraphs,
>>> headings,
>>> subsections (endless nesting) and footnotes. In the near future, I want
>>> to
>>> bolds/italics,
>>> ordered and unordered lists, links, and later on as many elements as
>>> possible :)
>>>
>>> The problem with Fmark is also its greatest feature. While other markup
>>> languages
>>> introduce special syntactic characters to give meaning to the document's
>>> elements,
>>> I would like to take a different approach: I want to use characters that
>>> people already
>>> use in document writing to achieve the same result. For example, in
>>> Mediawiki a
>>> heading is some text surrounded by equal signs. But in Fmark a heading is
>>> simply some
>>> text that does not end in a punctuation character, such as period or an
>>> exclamation mark.
>>> I argue that this is a more "natural" approach.
>>
>> Is it possible to override this?  What happens if I want a heading of
>> "This is the greatest Heading Ever!!!!!" ?
>>
>> "Natural" conventions seem to be to be rather hacky and with lots of
>> corner cases; I think it's better to define a specific syntax for
>> markup (e.g. what is the "natural" way of emphasising text?) and stick
>> to it (though I agree that Markdown has some odd choices; in
>> particular, the ability to use both _ and * for italics whilst
>> requiring ** for bold).
>>
>>> I want to find a natural way of not burdening the user with the task of
>>> having to learn
>>> some special syntax in order to write a document. Instead I want to find
>>> "natural" ways
>>> of writing and use those ways to reconstruct the elements in a document.
>>> Of
>>> course,
>>> what is natural is subjective and that is why I want to find a good
>>> tradeoff
>>> between
>>> expressiveness and simplicity in the syntax. For example, in Fmark a
>>> footnote is some
>>> text surrounded by square brackets. Maybe you find this natural, maybe
>>> you
>>> don't. If a
>>> handful of people defend a more natural way of writing footnotes I want
>>> to
>>> implement
>>> the way they say. If there is a more natural way of doing this I want to
>>> find it. But for now
>>> I think square brackets are better than the equal signs or any other
>>> strange
>>> syntactic
>>> character such as exclamation marks and so on...
>>>
>>> Another thing about Fmark is styles. I want to use fmark personally to
>>> write
>>> papers, using
>>> Latex as backend. While experimenting with previous versions of Fmark I
>>> realized that I
>>> could not specify the title, the author, the date, and the abstract.
>>> which
>>> are essential in a
>>> paper. I came up with an idea which I think is quite interesting. I wrote
>>> another document
>>> also using Fmark which only had the words "Title", "Author", "Date", and
>>> "Abstract". And
>>> then I combined these two documents together, such that, Fmark associated
>>> title, author,
>>> date and abstract, with the corresponding content. I thought the idea was
>>> interesting
>>> because the content and style documents have both the same structure and
>>> are
>>> both
>>> written in Fmark. Of course, there is still a long way to go, in order to
>>> be
>>> able to fully
>>> customize a document.
>>>
>>> But styles are a good and simple approach, similar to document classes in
>>> Latex: the idea is
>>> to write one document (content) and then use multiple (predefined, user
>>> defined) styles, such
>>> as, article, report, etc, to stylize your document. Another interesting
>>> thing I have been thinking
>>> about (but not implemented yet) is recursion in document styling. In a
>>> way,
>>> weaving a style
>>> with content can be compared to matching a regular expression.
>>>
>>> Anyway, these are just some key ideas. I see Fmark as a work in progress
>>> and
>>> in a way as a
>>> research project, trying to find a natural way of writing documents while
>>> escaping as much
>>> as possible from the syntax of a programming language. I also have a
>>> metagoal with this
>>> project: if my father (the non programming guy) could use it to write his
>>> PhD dissertation,
>>> I would be quite happy :)
>>>
>>> If you have any more questions I would be happy to answer.
>>> But if you're interested in using markup languages for blogs perhaps a
>>> HTML
>>> backend
>>> in Fmark would be more interesting for you. Although, XML + JavaScript +
>>> CSS
>>> is also possible.
>>>
>>> Best regards,
>>> Jos?
>>>
>>>
>>> On 18-09-2012 04:25, Kristopher Micinski wrote:
>>>>
>>>> Jose,
>>>>
>>>> So I'm interested to hear you opinion on this as well...
>>>>
>>>> I use Pandoc with Markdown through Hakyll, which allows you to do a
>>>> fair amount of cute things that are just really helpful for
>>>> maintaining a blog (for example..).  But I didn't get this from
>>>> reading your github readme: what makes your markup language special?
>>>> Could you give an example of how the language is more expressive than
>>>> (say) markdown processed through Pandoc (I only mention because it
>>>> lets you process LaTeX, very helpful, right...) or something
>>>> comparable?
>>>>
>>>> kris
>>>>
>>>> On Mon, Sep 17, 2012 at 11:09 PM, Jos? Lopes 
>>>> wrote:
>>>>>
>>>>> Hello everyone,
>>>>>
>>>>> I just wanted to share a package I created called Fmark, now available
>>>>> on HackageDB.
>>>>>
>>>>> Feedback both on the project and on the code is greatly appreciated :)
>>>>>
>>>>> Fmark (Friendly Markup) is a very simple markup language without
>>>>> syntax and simple but sophisticated document styling, capable of
>>>>> producing PDF and XML files.
>>>>>
>>>>> The key philosophy behind this markup language is to eliminate the
>>>>> strange syntactic characters seen in most markup languages, but
>>>>> at the same time try to maintain a high level of expressiveness, using
>>>>> only document reconstruction.
>>>>>
>>>>> Check it out
>>>>> http://hackage.haskell.org/package/fmark
>>>>> https://github.com/jabolopes/fmark
>>>>>
>>>>> Best regards,
>>>>> Jos?
>>>>>
>>>>> --
>>>>> Jos? Ant?nio Branquinho de Oliveira Lopes
>>>>> 58612 - MEIC-A
>>>>> Instituto Superior T?cnico (IST), Universidade T?cnica de Lisboa (UTL)
>>>>> jose.lopes at ist.utl.pt
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Haskell-Cafe mailing list
>>>>> Haskell-Cafe at haskell.org
>>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>>
>>>
>>> --
>>> Jos? Ant?nio Branquinho de Oliveira Lopes
>>> Instituto Superior T?cnico
>>> Technical University of Lisbon
>>>
>>>
>>>
>>> _______________________________________________
>>> Haskell-Cafe mailing list
>>> Haskell-Cafe at haskell.org
>>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>>
>>
>
> --
> Jos? Ant?nio Branquinho de Oliveira Lopes
> Instituto Superior T?cnico
> Technical University of Lisbon
>



-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com


From jose.lopes at ist.utl.pt  Tue Sep 18 14:22:11 2012
From: jose.lopes at ist.utl.pt (=?ISO-8859-1?Q?Jos=E9_Lopes?=)
Date: Tue, 18 Sep 2012 13:22:11 +0100
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: 
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
	
	<505860A4.6020106@ist.utl.pt>
	
Message-ID: <50586773.1020902@ist.utl.pt>

Hi,

Like I said it's a tradeoff. I will try to use this philosophy as much as
possible. But it's also important not to be fundamentalist. We'll see
as it goes.

I like that strikethrough. You are right about the quotes, but we can
leave " for quoting and use the ' for something else.

Cheers,
Jos?

On 18-09-2012 13:18, Ivan Lazar Miljenovic wrote:
> On 18 September 2012 21:53, Jos? Lopes  wrote:
>> Hello Ivan,
>>
>> I agree with your point: if you want a heading that ends with a punctuation
>> sign then you cannot do it in Fmark (for now). That gives me something to
>> think about. However, I will still look for a way that avoids (as much as
>> possible) special syntax. Do you have any suggestion?
>>
>> I also agree with you on the "natural" conventions. I want to find a good
>> tradeoff between syntax and expressiveness. In other words, I want to
>> avoid as much those "odd choices" you mentioned. For example, I have
>> been thinking seriously about emphasis and what would be a good way
>> to do it. So far I could only come up with quotes (either " or '). What do
>> you think?
> I think that _emphasis_ is pretty "natural", as is *bold* and possibly
> -strikethrough-.
>
> But you _are_ adding in some aspects of markup now.
>
> Using quotes is bad because what happens if you're actually quoting someone? ;-)
>
>> Cheers,
>> Jos?
>>
>>
>> On 18-09-2012 06:05, Ivan Lazar Miljenovic wrote:
>>> On 18 September 2012 13:57, Jos? Lopes  wrote:
>>>> Hello Kris,
>>>>
>>>> Thank you for your email.
>>>>
>>>> At this moment, Fmark is not as powerful as Markdown, also because Fmark
>>>> just started.
>>>> Markdown offers things such as Blockquotes, Lists, Code blocks, links,
>>>> emphasis, images, etc.
>>>> Fmark does not offer as many features: for now, there are only
>>>> paragraphs,
>>>> headings,
>>>> subsections (endless nesting) and footnotes. In the near future, I want
>>>> to
>>>> bolds/italics,
>>>> ordered and unordered lists, links, and later on as many elements as
>>>> possible :)
>>>>
>>>> The problem with Fmark is also its greatest feature. While other markup
>>>> languages
>>>> introduce special syntactic characters to give meaning to the document's
>>>> elements,
>>>> I would like to take a different approach: I want to use characters that
>>>> people already
>>>> use in document writing to achieve the same result. For example, in
>>>> Mediawiki a
>>>> heading is some text surrounded by equal signs. But in Fmark a heading is
>>>> simply some
>>>> text that does not end in a punctuation character, such as period or an
>>>> exclamation mark.
>>>> I argue that this is a more "natural" approach.
>>> Is it possible to override this?  What happens if I want a heading of
>>> "This is the greatest Heading Ever!!!!!" ?
>>>
>>> "Natural" conventions seem to be to be rather hacky and with lots of
>>> corner cases; I think it's better to define a specific syntax for
>>> markup (e.g. what is the "natural" way of emphasising text?) and stick
>>> to it (though I agree that Markdown has some odd choices; in
>>> particular, the ability to use both _ and * for italics whilst
>>> requiring ** for bold).
>>>
>>>> I want to find a natural way of not burdening the user with the task of
>>>> having to learn
>>>> some special syntax in order to write a document. Instead I want to find
>>>> "natural" ways
>>>> of writing and use those ways to reconstruct the elements in a document.
>>>> Of
>>>> course,
>>>> what is natural is subjective and that is why I want to find a good
>>>> tradeoff
>>>> between
>>>> expressiveness and simplicity in the syntax. For example, in Fmark a
>>>> footnote is some
>>>> text surrounded by square brackets. Maybe you find this natural, maybe
>>>> you
>>>> don't. If a
>>>> handful of people defend a more natural way of writing footnotes I want
>>>> to
>>>> implement
>>>> the way they say. If there is a more natural way of doing this I want to
>>>> find it. But for now
>>>> I think square brackets are better than the equal signs or any other
>>>> strange
>>>> syntactic
>>>> character such as exclamation marks and so on...
>>>>
>>>> Another thing about Fmark is styles. I want to use fmark personally to
>>>> write
>>>> papers, using
>>>> Latex as backend. While experimenting with previous versions of Fmark I
>>>> realized that I
>>>> could not specify the title, the author, the date, and the abstract.
>>>> which
>>>> are essential in a
>>>> paper. I came up with an idea which I think is quite interesting. I wrote
>>>> another document
>>>> also using Fmark which only had the words "Title", "Author", "Date", and
>>>> "Abstract". And
>>>> then I combined these two documents together, such that, Fmark associated
>>>> title, author,
>>>> date and abstract, with the corresponding content. I thought the idea was
>>>> interesting
>>>> because the content and style documents have both the same structure and
>>>> are
>>>> both
>>>> written in Fmark. Of course, there is still a long way to go, in order to
>>>> be
>>>> able to fully
>>>> customize a document.
>>>>
>>>> But styles are a good and simple approach, similar to document classes in
>>>> Latex: the idea is
>>>> to write one document (content) and then use multiple (predefined, user
>>>> defined) styles, such
>>>> as, article, report, etc, to stylize your document. Another interesting
>>>> thing I have been thinking
>>>> about (but not implemented yet) is recursion in document styling. In a
>>>> way,
>>>> weaving a style
>>>> with content can be compared to matching a regular expression.
>>>>
>>>> Anyway, these are just some key ideas. I see Fmark as a work in progress
>>>> and
>>>> in a way as a
>>>> research project, trying to find a natural way of writing documents while
>>>> escaping as much
>>>> as possible from the syntax of a programming language. I also have a
>>>> metagoal with this
>>>> project: if my father (the non programming guy) could use it to write his
>>>> PhD dissertation,
>>>> I would be quite happy :)
>>>>
>>>> If you have any more questions I would be happy to answer.
>>>> But if you're interested in using markup languages for blogs perhaps a
>>>> HTML
>>>> backend
>>>> in Fmark would be more interesting for you. Although, XML + JavaScript +
>>>> CSS
>>>> is also possible.
>>>>
>>>> Best regards,
>>>> Jos?
>>>>
>>>>
>>>> On 18-09-2012 04:25, Kristopher Micinski wrote:
>>>>> Jose,
>>>>>
>>>>> So I'm interested to hear you opinion on this as well...
>>>>>
>>>>> I use Pandoc with Markdown through Hakyll, which allows you to do a
>>>>> fair amount of cute things that are just really helpful for
>>>>> maintaining a blog (for example..).  But I didn't get this from
>>>>> reading your github readme: what makes your markup language special?
>>>>> Could you give an example of how the language is more expressive than
>>>>> (say) markdown processed through Pandoc (I only mention because it
>>>>> lets you process LaTeX, very helpful, right...) or something
>>>>> comparable?
>>>>>
>>>>> kris
>>>>>
>>>>> On Mon, Sep 17, 2012 at 11:09 PM, Jos? Lopes 
>>>>> wrote:
>>>>>> Hello everyone,
>>>>>>
>>>>>> I just wanted to share a package I created called Fmark, now available
>>>>>> on HackageDB.
>>>>>>
>>>>>> Feedback both on the project and on the code is greatly appreciated :)
>>>>>>
>>>>>> Fmark (Friendly Markup) is a very simple markup language without
>>>>>> syntax and simple but sophisticated document styling, capable of
>>>>>> producing PDF and XML files.
>>>>>>
>>>>>> The key philosophy behind this markup language is to eliminate the
>>>>>> strange syntactic characters seen in most markup languages, but
>>>>>> at the same time try to maintain a high level of expressiveness, using
>>>>>> only document reconstruction.
>>>>>>
>>>>>> Check it out
>>>>>> http://hackage.haskell.org/package/fmark
>>>>>> https://github.com/jabolopes/fmark
>>>>>>
>>>>>> Best regards,
>>>>>> Jos?
>>>>>>
>>>>>> --
>>>>>> Jos? Ant?nio Branquinho de Oliveira Lopes
>>>>>> 58612 - MEIC-A
>>>>>> Instituto Superior T?cnico (IST), Universidade T?cnica de Lisboa (UTL)
>>>>>> jose.lopes at ist.utl.pt
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Haskell-Cafe mailing list
>>>>>> Haskell-Cafe at haskell.org
>>>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>>>
>>>> --
>>>> Jos? Ant?nio Branquinho de Oliveira Lopes
>>>> Instituto Superior T?cnico
>>>> Technical University of Lisbon
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Haskell-Cafe mailing list
>>>> Haskell-Cafe at haskell.org
>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>>
>>>
>> --
>> Jos? Ant?nio Branquinho de Oliveira Lopes
>> Instituto Superior T?cnico
>> Technical University of Lisbon
>>
>
>

-- 
Jos? Ant?nio Branquinho de Oliveira Lopes
Instituto Superior T?cnico
Technical University of Lisbon



From jan.stolarek at p.lodz.pl  Tue Sep 18 14:32:30 2012
From: jan.stolarek at p.lodz.pl (Jan Stolarek)
Date: Tue, 18 Sep 2012 14:32:30 +0200
Subject: [Haskell-cafe] foldl vs. foldr
Message-ID: <201209181432.30668.jan.stolarek@p.lodz.pl>

Hi list,

I have yet another question about folds. Reading here and there I encountered statements that 
foldr is more important than foldl, e.g. in this post on the list: 
http://www.haskell.org/pipermail/haskell-cafe/2012-May/101338.html
I want to know are such statements correct and, if so, why? I am aware that foldl' can in some 
circumstances operate in constant space, while foldr can operate on infinite lists if the folding 
function is lazy in the second parameter. Is there more to this subject? Properties that I 
mentioned are more of technical nature, not theoretical ones. Are there any significant 
theoretical advantages of foldr? I read Bird's and Wadler's "Introduction to functional 
programming" and it seems to me that foldl and foldr have the same properties and in many cases 
are interchangeable.

Greets,
Janek


From marcotmarcot at gmail.com  Tue Sep 18 14:56:33 2012
From: marcotmarcot at gmail.com (=?UTF-8?Q?Marco_T=C3=BAlio_Pimenta_Gontijo?=)
Date: Tue, 18 Sep 2012 09:56:33 -0300
Subject: [Haskell-cafe] cost-centre names
In-Reply-To: 
References: 
	
Message-ID: 

Hi Felipe.

On Sun, Sep 16, 2012 at 1:57 PM, Felipe Almeida Lessa
 wrote:
> On Sun, Sep 16, 2012 at 7:57 AM, Marco T?lio Pimenta Gontijo
>  wrote:
>> I have a question about cost-centre names, as shown on .hp files
>> produced by +RTS -hc.  They have the form A/B/C/D/E/F/G/...  Usually,
>> it seems that it means A, called by B, called by C, etc, but that's
>> not the case sometimes.  I have a case here (called with -L200):
>> replaceOneOf?/clean/tagsText/anyTag/dropTagClose/parseObservations/specificTagText/tagText/parseOab/dropTagText/dropTill/tag/tagOpen...
>>
>> tagsText calls clean which calls replaceOneOf', but anyTag does not
>> call tagsText.  parseObservations calls dropTagClose which calss
>> anyTag, but specificTagText does not call parseObservations.  They
>> seem to be grouped by three.
>>
>> Is this correct?  How should I interpret it?
>
> That's probably because anyTag took a closure as argument, and that
> closure called tagsText when forced.  Does that make sense?

That makes sense, thanks.

Greetings.
(...)
-- 
marcot
http://marcot.eti.br/


From marcotmarcot at gmail.com  Tue Sep 18 14:57:13 2012
From: marcotmarcot at gmail.com (=?UTF-8?Q?Marco_T=C3=BAlio_Pimenta_Gontijo?=)
Date: Tue, 18 Sep 2012 09:57:13 -0300
Subject: [Haskell-cafe] Type error with Type families
In-Reply-To: 
References: 
	
	
Message-ID: 

On Mon, Sep 17, 2012 at 6:27 PM, Alexander Solla  wrote:
>
>
> On Mon, Sep 17, 2012 at 10:59 AM, Ryan Ingram  wrote:
>>
>> The problem is that the function 'element' is ambiguous, for the reasons
>> MigMit pointed out.
>>
>> The standard solution to this problem is to add a dummy argument to fix
>> the type argument to the type function:
>>
>> data Proxy a = Proxy
>>
>> class ... => ReplaceOneOf full where
>>     type Item full ::  *
>>
>>     -- implementations can just ignore the first argument
>>     element :: Proxy full -> Item full -> [Item full] -> Bool
>>
>>     replaceOneOf :: ...
>>         ...
>>         | element (Proxy :: Proxy full) x from = ...
>>
>> Now the choice of which 'element' to use can be determined by the type of
>> the proxy.
>
>
> It might be best if we point users to a "standard" Proxy type so we don't
> end up lots of packages defining distinct/incompatible types for the same
> code.
>
> Edward Kmett's "tagged" package has a Proxy type.

Thank you for your answers.

Greetings.
(...)
-- 
marcot
http://marcot.eti.br/


From miguelimo38 at yandex.ru  Tue Sep 18 15:35:39 2012
From: miguelimo38 at yandex.ru (Miguel Mitrofanov)
Date: Tue, 18 Sep 2012 17:35:39 +0400
Subject: [Haskell-cafe] foldl vs. foldr
In-Reply-To: <201209181432.30668.jan.stolarek@p.lodz.pl>
References: <201209181432.30668.jan.stolarek@p.lodz.pl>
Message-ID: <30191347975339@web16f.yandex.ru>

Hi Jan!

foldl always traverses the list to the end; in particular, if there is no end, it would hang forever (unless the compiler is smart enough to detect an infinite loop, in which case it can throw an error). On the other hand, if the first argument is lazy enough, foldr would stop before processing the complete list. So, for example

foldr (\_ _ -> ()) () [1..]

would give an answer, while

foldl (\_ _ -> ()) () [1..]

would hang.

In particular, you can reimplement foldl in terms of foldr, like that:

foldl op i ls = foldr (flip op) i (reverse ls)

but if you attempt to do the same with foldr:

foldr op i ls = foldl (flip op) i (reverse ls)

you would end up with a function which is more strict than the real foldr.

18.09.2012, 16:32, "Jan Stolarek" :
> Hi list,
>
> I have yet another question about folds. Reading here and there I encountered statements that
> foldr is more important than foldl, e.g. in this post on the list:
> http://www.haskell.org/pipermail/haskell-cafe/2012-May/101338.html
> I want to know are such statements correct and, if so, why? I am aware that foldl' can in some
> circumstances operate in constant space, while foldr can operate on infinite lists if the folding
> function is lazy in the second parameter. Is there more to this subject? Properties that I
> mentioned are more of technical nature, not theoretical ones. Are there any significant
> theoretical advantages of foldr? I read Bird's and Wadler's "Introduction to functional
> programming" and it seems to me that foldl and foldr have the same properties and in many cases
> are interchangeable.
>
> Greets,
> Janek
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


From monnier at iro.umontreal.ca  Tue Sep 18 15:43:42 2012
From: monnier at iro.umontreal.ca (Stefan Monnier)
Date: Tue, 18 Sep 2012 09:43:42 -0400
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
	
Message-ID: 

> The problem with that is that some people DO end some headings with
> a full stop; for them your special syntax is not natural.

Markdown/ReST is already using the "no syntax" idea (e.g. compared to
pre-wiki markup such a LaTeX or Texinfo), so he's simply trying to push
this idea further.

I suspect it'll be difficult.

> What if I want to use indentation to express quotation instead?

I think this one is solvable: a paragraph that's more indented than the
previous heading can be considered a quote.


        Stefan



From jose.lopes at ist.utl.pt  Tue Sep 18 15:48:54 2012
From: jose.lopes at ist.utl.pt (=?ISO-8859-1?Q?Jos=E9_Lopes?=)
Date: Tue, 18 Sep 2012 14:48:54 +0100
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: 
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
	
	
Message-ID: <50587BC6.30503@ist.utl.pt>

Hello Stefan,

Thank you for the input.

Cheers,
Jos?

On 18-09-2012 14:43, Stefan Monnier wrote:
>> The problem with that is that some people DO end some headings with
>> a full stop; for them your special syntax is not natural.
> Markdown/ReST is already using the "no syntax" idea (e.g. compared to
> pre-wiki markup such a LaTeX or Texinfo), so he's simply trying to push
> this idea further.
>
> I suspect it'll be difficult.
>
>> What if I want to use indentation to express quotation instead?
> I think this one is solvable: a paragraph that's more indented than the
> previous heading can be considered a quote.
>
>
>          Stefan
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

-- 
Jos? Ant?nio Branquinho de Oliveira Lopes
Instituto Superior T?cnico
Technical University of Lisbon



From chaddai.fouche at gmail.com  Tue Sep 18 16:26:05 2012
From: chaddai.fouche at gmail.com (=?UTF-8?B?Q2hhZGRhw68gRm91Y2jDqQ==?=)
Date: Tue, 18 Sep 2012 16:26:05 +0200
Subject: [Haskell-cafe] foldl vs. foldr
In-Reply-To: <30191347975339@web16f.yandex.ru>
References: <201209181432.30668.jan.stolarek@p.lodz.pl>
	<30191347975339@web16f.yandex.ru>
Message-ID: 

>
> 18.09.2012, 16:32, "Jan Stolarek" :
> > Hi list,
> >
> > I have yet another question about folds. Reading here and there I
> encountered statements that
> > foldr is more important than foldl, e.g. in this post on the list:
> > http://www.haskell.org/pipermail/haskell-cafe/2012-May/101338.html
> > I want to know are such statements correct and, if so, why? I am aware
> that foldl' can in some
> > circumstances operate in constant space, while foldr can operate on
> infinite lists if the folding
> > function is lazy in the second parameter. Is there more to this subject?
>

Basically the difference is that foldr is really the natural catamorphism
for the list type, that is for a type like :

data MyType = Zero | One A | Two B C | Recurse MyType

the natural catamorphism is a function that takes four arguments by which
it will replace the four constructor so as to deconstruct a value of MyType
:

myTypeCata :: r -> (A -> r) -> (B -> C -> r) -> (r -> r)   ->    (MyType ->
r)
myTypeCata z o t re Zero = z
myTypeCata z o t re (One a) = o a
myTypeCata z o t re (Two b c) = t b c
myTypeCata z o t re (Recurse myType) = re (myTypeCata z o t re myType)

So foldr is the natural catamorphism for the list type and foldl is not.

-- 
Jeda?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From allbery.b at gmail.com  Tue Sep 18 16:30:27 2012
From: allbery.b at gmail.com (Brandon Allbery)
Date: Tue, 18 Sep 2012 10:30:27 -0400
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: 
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
	
Message-ID: 

On Tue, Sep 18, 2012 at 1:05 AM, Ivan Lazar Miljenovic <
ivan.miljenovic at gmail.com> wrote:

> to it (though I agree that Markdown has some odd choices; in
> particular, the ability to use both _ and * for italics whilst
> requiring ** for bold).
>

The odd thing is, I've found that I use those constructs "naturally" (i.e.
when simply writing text in a text-only medium) in pretty much exactly the
way Markdown uses them.  _italics_ and *italics* are semantically different
(I tend to use the former for titles and such) but are both usually italics
in my normal usage.  (There's also /italics/ but that is not very
widespread.)  I do tend to use # instead of = for headings but that's kinda
stolen (and mutated) from a different variety of non-natural markup.

I suspect that when the dust has settled, it'll turn out that Markdown is
pretty much right.  Maybe with some tweaking, but largely it represents
(and IIRC was derived from) actual in-the-wild textual usage.

-- 
brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From jose.lopes at ist.utl.pt  Tue Sep 18 16:34:25 2012
From: jose.lopes at ist.utl.pt (=?UTF-8?B?Sm9zw6kgTG9wZXM=?=)
Date: Tue, 18 Sep 2012 15:34:25 +0100
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: 
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
	
	
Message-ID: <50588671.8000502@ist.utl.pt>

Hey,

Why do you say that _italics_ and *italics* are semantically different?
What do you mean?

Cheers,
Jos?

On 18-09-2012 15:30, Brandon Allbery wrote:
> On Tue, Sep 18, 2012 at 1:05 AM, Ivan Lazar Miljenovic 
> > wrote:
>
>     to it (though I agree that Markdown has some odd choices; in
>     particular, the ability to use both _ and * for italics whilst
>     requiring ** for bold).
>
>
> The odd thing is, I've found that I use those constructs "naturally" 
> (i.e. when simply writing text in a text-only medium) in pretty much 
> exactly the way Markdown uses them.  _italics_ and *italics* are 
> semantically different (I tend to use the former for titles and such) 
> but are both usually italics in my normal usage.  (There's also 
> /italics/ but that is not very widespread.)  I do tend to use # 
> instead of = for headings but that's kinda stolen (and mutated) from a 
> different variety of non-natural markup.
>
> I suspect that when the dust has settled, it'll turn out that Markdown 
> is pretty much right.  Maybe with some tweaking, but largely it 
> represents (and IIRC was derived from) actual in-the-wild textual usage.
>
> -- 
> brandon s allbery allbery.b at gmail.com 
> wandering unix systems administrator (available)     (412) 475-9364 vm/sms
>

-- 
Jos? Ant?nio Branquinho de Oliveira Lopes
Instituto Superior T?cnico
Technical University of Lisbon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From agocorona at gmail.com  Tue Sep 18 17:26:32 2012
From: agocorona at gmail.com (Alberto G. Corona )
Date: Tue, 18 Sep 2012 17:26:32 +0200
Subject: [Haskell-cafe] ANNOUNCE: MFlow-0.1.5
Message-ID: 

Hi haskellers and specially the web developers.

http://hackage.haskell.org/package/MFlow-0.1.5.3

MFlow is a is a Web framework with some unique, and I mean unique,
characteristics that I find exciting:

- It is a Web application server that start and restart on-demand
stateful web server processes (not request.-response)
  This means that all the page navigation can be coded in a single
procedure. This increases readability of the programmer code. I woul
call it
a anti-node.js.  Buit usual request-response (stateless) server
processes are also allowed

- When the process is invoqued as result of an URL request, the Web
app server not only restart the process but also recover its execution
state. The enclosing Workflow monad provides the thread state
persistence. There are state timeouts and process timeouts defined by
the programmer. Processes with no persistent state (transient) are
possible.

-The user interface is made of widgets. They are  formlets with added
formatting,   attributes, validations, modifiers and callbacks, that
are composable, so the pieces are reusable and return type safe
responses to the calling process. Even the links are part of widgets
and return back type safe inputs at compile time to the calling server
process. Tho glue these components, ordinary applicative combinators
and other extra combinators are used.

- The widgets and the communication don?t make assumptions about the
architecture, so it can be adapted to non-web environments. This
versions has interface for WAI-warp, Hack, Text.XHtml (xhtml) , and
Haskell Server Pages.

-The widget rendering can be converted to ByteStrings automatically
with special combinators. A mix of widgets with different formats can
be combined in the same source file. For example Text.Html and HSP
(Haskell server pages)

-These widgets can be cached, to avoid widget rendering on every interaction.

-To handle the back button, and because the processes are stateful,
they can run backwards until the response match. This is transparent
for the programmer, thanks to the embedded FlowM monad.

-All the code is in pure Haskell. No deployment, special scripts,
formats etc are necessary.

-Besides automatic state persistence, TCache provides transactions and
user data persistence, that can be configured for SQL databases.
Default persistence in files permit very rapid prototyping. Just code
and run it with runghc.

-Has AJAX support

All of this sounds very complicated, but really it is simple!. Most of
these things are transparent. The resulting code is quite readable and
has very little plumbing!

There is a non trivial example that some of these functionalities
embedded here that you can run:

 http://hackage.haskell.org/packages/archive/MFlow/0.1.5.3/doc/html/MFlow-Forms.html

Take a look and tell me your opinion.  I hope that you find it as
exciting as me.

 I?m looking for people  to collaborate in the development of MFlow.

Although still it is experimental, it is being used in at least one
future commercial project. So I have te commitment to continue its
development. There are many examples in the documentation and in the
package.

Alberto


From allbery.b at gmail.com  Tue Sep 18 17:29:19 2012
From: allbery.b at gmail.com (Brandon Allbery)
Date: Tue, 18 Sep 2012 11:29:19 -0400
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: <50588671.8000502@ist.utl.pt>
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
	
	
	<50588671.8000502@ist.utl.pt>
Message-ID: 

On Tue, Sep 18, 2012 at 10:34 AM, Jos? Lopes  wrote:

> Why do you say that _italics_ and *italics* are semantically different?
> What do you mean?
>

The parenthetical hinted at it:

(I tend to use the former for titles and such)
>
> There's a convention at work here, namely that italicized book titles and
similar are often underlined in plain text ? and in plain text without
backspaces this is represented as leading and trailing _.  So there's a
semantic (i.e. content) difference even though the generated markup is the
same.

-- 
brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From agocorona at gmail.com  Tue Sep 18 18:33:56 2012
From: agocorona at gmail.com (Alberto G. Corona )
Date: Tue, 18 Sep 2012 18:33:56 +0200
Subject: [Haskell-cafe] Fwd: [Haskell] ANNOUNCE: MFlow-0.1.5
In-Reply-To: 
References: 
	
	
	
Message-ID: 

Oh,  I?m stupid. You mean web pages with multiple tabs....

 I have not tested it. but each tab can be handled easily by a different
server process.. or it can be handled in a single server process, like in a
menu. For example, this code present different options, and the process
renders different things depending on the response.

The last option is a link to a different process, while the others( wlinks)
are links that return back to the same process.
The operator <|> is the applicative operator.  a breakline is prepended to
each link:

data Ops= Ints | Strings | Actions | Ajax | Opt deriving(Typeable,Read,
Show)

 mainf=   do
        r <- ask $   wlink Ints (bold << "increase an Int")
                <|>  br ++> wlink Strings (bold << "increase a String")
                <|>  br ++> wlink Actions (bold << "Example of a string
widget with an action")
                <|>  br ++> wlink Ajax (bold << "Simple AJAX example")
                <|>  br ++> wlink Opt (bold << "select options")
                <++ (br +++ linkShop) -- this is an ordinary XHtml link

        case r of
          Ints    ->  clickn 0
          Strings ->  clicks "1"
          Actions ->  actions 1
          Ajax    ->  ajaxsample
          Opt     ->  options
        mainf
     where
     linkShop= toHtml $ hotlink  "shop" << "shopping"

.
Alberto

2012/9/18 Alberto G. Corona :

> Hi Jake
>
> I don?t know what you mean with multiple tabs. The user management is
> simple, anonymous clients are identified with  a cookie. if the user
> is logged (MFlow has widgets for logging-validation) the user is the
> identifier.
>
> The state of a process is associated to the client identifier and to
> the path invoked in the url requested.
>
> I don?t know if this answer your question....
>
> Alberto
>
> 2012/9/18 Jake McArthur :
>> This sounds really cool.
>>
>> How do you handle users having multiple tabs?
>>
>> On Tue, Sep 18, 2012 at 11:26 AM, Alberto G. Corona 
wrote:
>>> Hi haskellers and specially the web developers.
>>>
>>> http://hackage.haskell.org/package/MFlow-0.1.5.3
>>>
>>> MFlow is a is a Web framework with some unique, and I mean unique,
>>> characteristics that I find exciting:
>>>
>>> - It is a Web application server that start and restart on-demand
>>> stateful web server processes (not request.-response)
>>>   This means that all the page navigation can be coded in a single
>>> procedure. This increases readability of the programmer code. I woul
>>> call it
>>> a anti-node.js.  Buit usual request-response (stateless) server
>>> processes are also allowed
>>>
>>> - When the process is invoqued as result of an URL request, the Web
>>> app server not only restart the process but also recover its execution
>>> state. The enclosing Workflow monad provides the thread state
>>> persistence. There are state timeouts and process timeouts defined by
>>> the programmer. Processes with no persistent state (transient) are
>>> possible.
>>>
>>> -The user interface is made of widgets. They are  formlets with added
>>> formatting,   attributes, validations, modifiers and callbacks, that
>>> are composable, so the pieces are reusable and return type safe
>>> responses to the calling process. Even the links are part of widgets
>>> and return back type safe inputs at compile time to the calling server
>>> process. Tho glue these components, ordinary applicative combinators
>>> and other extra combinators are used.
>>>
>>> - The widgets and the communication don?t make assumptions about the
>>> architecture, so it can be adapted to non-web environments. This
>>> versions has interface for WAI-warp, Hack, Text.XHtml (xhtml) , and
>>> Haskell Server Pages.
>>>
>>> -The widget rendering can be converted to ByteStrings automatically
>>> with special combinators. A mix of widgets with different formats can
>>> be combined in the same source file. For example Text.Html and HSP
>>> (Haskell server pages)
>>>
>>> -These widgets can be cached, to avoid widget rendering on every
interaction.
>>>
>>> -To handle the back button, and because the processes are stateful,
>>> they can run backwards until the response match. This is transparent
>>> for the programmer, thanks to the embedded FlowM monad.
>>>
>>> -All the code is in pure Haskell. No deployment, special scripts,
>>> formats etc are necessary.
>>>
>>> -Besides automatic state persistence, TCache provides transactions and
>>> user data persistence, that can be configured for SQL databases.
>>> Default persistence in files permit very rapid prototyping. Just code
>>> and run it with runghc.
>>>
>>> -Has AJAX support
>>>
>>> All of this sounds very complicated, but really it is simple!. Most of
>>> these things are transparent. The resulting code is quite readable and
>>> has very little plumbing!
>>>
>>> There is a non trivial example that some of these functionalities
>>> embedded here that you can run:
>>>
>>>
http://hackage.haskell.org/packages/archive/MFlow/0.1.5.3/doc/html/MFlow-Forms.html
>>>
>>> Take a look and tell me your opinion.  I hope that you find it as
>>> exciting as me.
>>>
>>>  I?m looking for people  to collaborate in the development of MFlow.
>>>
>>> Although still it is experimental, it is being used in at least one
>>> future commercial project. So I have te commitment to continue its
>>> development. There are many examples in the documentation and in the
>>> package.
>>>
>>> Alberto
>>>
>>> _______________________________________________
>>> Haskell mailing list
>>> Haskell at haskell.org
>>> http://www.haskell.org/mailman/listinfo/haskell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ekirpichov at gmail.com  Tue Sep 18 19:48:47 2012
From: ekirpichov at gmail.com (Eugene Kirpichov)
Date: Tue, 18 Sep 2012 10:48:47 -0700
Subject: [Haskell-cafe] Choosing color of the track
In-Reply-To: 
References: 
Message-ID: 

Hi Manish,

The meaning of "@" is not what you think it is. It merely draws
colored bars, it does NOT control the color of other kinds of charts.

Here's how what you want can be achieved:
* Remove the "@" lines
* Append a common prefix to the input tracks you want to be displayed
on the same output track, e.g. "t.":
2012-09-18 00:10:48,166 =t.CurrentPerHour13057 0.0
2012-09-18 00:10:58,155 =t.CurrentPerHour13057 0.0
..
2012-09-18 03:58:28,159 =t.PacingReqPerHr13057 2375.0534412521242
2012-09-18 03:58:38,161 =t.PacingReqPerHr13057 2375.383005739316

* Use the "within" diagram kind: tplot .... -dk ''within[.] lines"

Then you'll have a single output track where data from these input
tracks is displayed with different color. However, you don't control
the precise color (I just never really needed to control it, I only
needed it to be different for different tracks).

On Mon, Sep 17, 2012 at 9:40 PM, Manish Trivedi  wrote:
> Hi Folks,
>
> I am trying to plot two tracks with different colors.
> Following is my input file,
>
> ------
> 2012-09-18 00:10:48,166 @CurrentPerHour13057 Red
> 2012-09-18 00:10:48,166 =CurrentPerHour13057 0.0
> 2012-09-18 00:10:58,155 =CurrentPerHour13057 0.0
> 2012-09-18 00:11:08,203 =CurrentPerHour13057 0.0
> 2012-09-18 00:11:18,166 =CurrentPerHour13057 0.0
> 2012-09-18 00:11:28,159 =CurrentPerHour13057 0.0
> 2012-09-18 00:11:38,170 =CurrentPerHour13057 0.0
> 2012-09-18 00:11:48,175 =CurrentPerHour13057 0.0
> 2012-09-18 00:11:58,174 =CurrentPerHour13057 0.0
> 2012-09-18 00:12:08,216 =CurrentPerHour13057 0.0
> 2012-09-18 00:12:18,218 =CurrentPerHour13057 0.0
> 2012-09-18 03:58:28,159 @PacingReqPerHr13057 Blue
> 2012-09-18 03:58:28,159 =PacingReqPerHr13057 2375.0534412521242
> 2012-09-18 03:58:38,161 =PacingReqPerHr13057 2375.383005739316
> 2012-09-18 03:58:48,175 =PacingReqPerHr13057 2375.713057258422
> 2012-09-18 03:58:58,160 =PacingReqPerHr13057 2376.0422443063935
> 2012-09-18 03:59:08,192 =PacingReqPerHr13057 2376.3730727321126
> 2012-09-18 03:59:18,207 =PacingReqPerHr13057 2375.9038854561304
> 2012-09-18 03:59:28,168 =PacingReqPerHr13057 2376.2324444615497
> 2012-09-18 03:59:38,156 =PacingReqPerHr13057 2376.5619853019184
> 2012-09-18 03:59:48,160 =PacingReqPerHr13057 2376.892145685344
> 2012-09-18 03:59:58,160 =PacingReqPerHr13057 2377.222265743067
> -----
>
> tplot -o /root/color.png  -or 1024x768 -k 'CurrentPerHour' 'lines' -k
> 'PacingReqPerHr' 'lines' -if /root/color.input -tf 'date %Y-%m-%d %H:%M:%OS'
>
> I cant get to print plots in different color. Could anyone point out what am
> I doing wrong?
>
> Thanks,
> Manish
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Eugene Kirpichov
http://www.linkedin.com/in/eugenekirpichov
We're hiring! http://tinyurl.com/mirantis-openstack-engineer


From trivmanish at gmail.com  Tue Sep 18 20:44:47 2012
From: trivmanish at gmail.com (Manish Trivedi)
Date: Tue, 18 Sep 2012 11:44:47 -0700
Subject: [Haskell-cafe] Choosing color of the track
In-Reply-To: 
References: 
	
Message-ID: 

Thanks a ton Eugene. that worked like a charm :) Appreciate you looking
into this and suggesting me the correct approach.
I have another question that if I had single track storing response time of
each request, how could I get 95th percentile of the response time. I know
TimePlot wiki has quantile example but I havent been able to successfully
use it.

Regards,
-Manish

On Tue, Sep 18, 2012 at 10:48 AM, Eugene Kirpichov wrote:

> Hi Manish,
>
> The meaning of "@" is not what you think it is. It merely draws
> colored bars, it does NOT control the color of other kinds of charts.
>
> Here's how what you want can be achieved:
> * Remove the "@" lines
> * Append a common prefix to the input tracks you want to be displayed
> on the same output track, e.g. "t.":
> 2012-09-18 00:10:48,166 =t.CurrentPerHour13057 0.0
> 2012-09-18 00:10:58,155 =t.CurrentPerHour13057 0.0
> ..
> 2012-09-18 03:58:28,159 =t.PacingReqPerHr13057 2375.0534412521242
> 2012-09-18 03:58:38,161 =t.PacingReqPerHr13057 2375.383005739316
>
> * Use the "within" diagram kind: tplot .... -dk ''within[.] lines"
>
> Then you'll have a single output track where data from these input
> tracks is displayed with different color. However, you don't control
> the precise color (I just never really needed to control it, I only
> needed it to be different for different tracks).
>
> On Mon, Sep 17, 2012 at 9:40 PM, Manish Trivedi 
> wrote:
> > Hi Folks,
> >
> > I am trying to plot two tracks with different colors.
> > Following is my input file,
> >
> > ------
> > 2012-09-18 00:10:48,166 @CurrentPerHour13057 Red
> > 2012-09-18 00:10:48,166 =CurrentPerHour13057 0.0
> > 2012-09-18 00:10:58,155 =CurrentPerHour13057 0.0
> > 2012-09-18 00:11:08,203 =CurrentPerHour13057 0.0
> > 2012-09-18 00:11:18,166 =CurrentPerHour13057 0.0
> > 2012-09-18 00:11:28,159 =CurrentPerHour13057 0.0
> > 2012-09-18 00:11:38,170 =CurrentPerHour13057 0.0
> > 2012-09-18 00:11:48,175 =CurrentPerHour13057 0.0
> > 2012-09-18 00:11:58,174 =CurrentPerHour13057 0.0
> > 2012-09-18 00:12:08,216 =CurrentPerHour13057 0.0
> > 2012-09-18 00:12:18,218 =CurrentPerHour13057 0.0
> > 2012-09-18 03:58:28,159 @PacingReqPerHr13057 Blue
> > 2012-09-18 03:58:28,159 =PacingReqPerHr13057 2375.0534412521242
> > 2012-09-18 03:58:38,161 =PacingReqPerHr13057 2375.383005739316
> > 2012-09-18 03:58:48,175 =PacingReqPerHr13057 2375.713057258422
> > 2012-09-18 03:58:58,160 =PacingReqPerHr13057 2376.0422443063935
> > 2012-09-18 03:59:08,192 =PacingReqPerHr13057 2376.3730727321126
> > 2012-09-18 03:59:18,207 =PacingReqPerHr13057 2375.9038854561304
> > 2012-09-18 03:59:28,168 =PacingReqPerHr13057 2376.2324444615497
> > 2012-09-18 03:59:38,156 =PacingReqPerHr13057 2376.5619853019184
> > 2012-09-18 03:59:48,160 =PacingReqPerHr13057 2376.892145685344
> > 2012-09-18 03:59:58,160 =PacingReqPerHr13057 2377.222265743067
> > -----
> >
> > tplot -o /root/color.png  -or 1024x768 -k 'CurrentPerHour' 'lines' -k
> > 'PacingReqPerHr' 'lines' -if /root/color.input -tf 'date %Y-%m-%d
> %H:%M:%OS'
> >
> > I cant get to print plots in different color. Could anyone point out
> what am
> > I doing wrong?
> >
> > Thanks,
> > Manish
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
>
>
>
> --
> Eugene Kirpichov
> http://www.linkedin.com/in/eugenekirpichov
> We're hiring! http://tinyurl.com/mirantis-openstack-engineer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From jake.mcarthur at gmail.com  Tue Sep 18 20:48:43 2012
From: jake.mcarthur at gmail.com (Jake McArthur)
Date: Tue, 18 Sep 2012 14:48:43 -0400
Subject: [Haskell-cafe] Fwd: [Haskell] ANNOUNCE: MFlow-0.1.5
In-Reply-To: 
References: 
	
	
	
	
Message-ID: 

Actually, I meant users that spawn multiple tabs from a single root
session. You mentioned that you have some special support for the back
button. What happens if I open a couple new tabs in which I may or may
not go forward and backward. Do they all share the same state?
Different states (how?)? Partially shared states?

On Tue, Sep 18, 2012 at 12:33 PM, Alberto G. Corona  wrote:
> Oh,  I?m stupid. You mean web pages with multiple tabs....
>
>  I have not tested it. but each tab can be handled easily by a different
> server process.. or it can be handled in a single server process, like in a
> menu. For example, this code present different options, and the process
> renders different things depending on the response.
>
> The last option is a link to a different process, while the others( wlinks)
> are links that return back to the same process.
> The operator <|> is the applicative operator.  a breakline is prepended to
> each link:
>
> data Ops= Ints | Strings | Actions | Ajax | Opt deriving(Typeable,Read,
> Show)
>
>  mainf=   do
>         r <- ask $   wlink Ints (bold << "increase an Int")
>                 <|>  br ++> wlink Strings (bold << "increase a String")
>                 <|>  br ++> wlink Actions (bold << "Example of a string
> widget with an action")
>                 <|>  br ++> wlink Ajax (bold << "Simple AJAX example")
>                 <|>  br ++> wlink Opt (bold << "select options")
>                 <++ (br +++ linkShop) -- this is an ordinary XHtml link
>
>         case r of
>           Ints    ->  clickn 0
>           Strings ->  clicks "1"
>           Actions ->  actions 1
>           Ajax    ->  ajaxsample
>           Opt     ->  options
>         mainf
>      where
>      linkShop= toHtml $ hotlink  "shop" << "shopping"
>
> .
> Alberto
>
> 2012/9/18 Alberto G. Corona :
>
>> Hi Jake
>>
>> I don?t know what you mean with multiple tabs. The user management is
>> simple, anonymous clients are identified with  a cookie. if the user
>> is logged (MFlow has widgets for logging-validation) the user is the
>> identifier.
>>
>> The state of a process is associated to the client identifier and to
>> the path invoked in the url requested.
>>
>> I don?t know if this answer your question....
>>
>> Alberto
>>
>> 2012/9/18 Jake McArthur :
>>> This sounds really cool.
>>>
>>> How do you handle users having multiple tabs?
>>>
>>> On Tue, Sep 18, 2012 at 11:26 AM, Alberto G. Corona 
>>> wrote:
>>>> Hi haskellers and specially the web developers.
>>>>
>>>> http://hackage.haskell.org/package/MFlow-0.1.5.3
>>>>
>>>> MFlow is a is a Web framework with some unique, and I mean unique,
>>>> characteristics that I find exciting:
>>>>
>>>> - It is a Web application server that start and restart on-demand
>>>> stateful web server processes (not request.-response)
>>>>   This means that all the page navigation can be coded in a single
>>>> procedure. This increases readability of the programmer code. I woul
>>>> call it
>>>> a anti-node.js.  Buit usual request-response (stateless) server
>>>> processes are also allowed
>>>>
>>>> - When the process is invoqued as result of an URL request, the Web
>>>> app server not only restart the process but also recover its execution
>>>> state. The enclosing Workflow monad provides the thread state
>>>> persistence. There are state timeouts and process timeouts defined by
>>>> the programmer. Processes with no persistent state (transient) are
>>>> possible.
>>>>
>>>> -The user interface is made of widgets. They are  formlets with added
>>>> formatting,   attributes, validations, modifiers and callbacks, that
>>>> are composable, so the pieces are reusable and return type safe
>>>> responses to the calling process. Even the links are part of widgets
>>>> and return back type safe inputs at compile time to the calling server
>>>> process. Tho glue these components, ordinary applicative combinators
>>>> and other extra combinators are used.
>>>>
>>>> - The widgets and the communication don?t make assumptions about the
>>>> architecture, so it can be adapted to non-web environments. This
>>>> versions has interface for WAI-warp, Hack, Text.XHtml (xhtml) , and
>>>> Haskell Server Pages.
>>>>
>>>> -The widget rendering can be converted to ByteStrings automatically
>>>> with special combinators. A mix of widgets with different formats can
>>>> be combined in the same source file. For example Text.Html and HSP
>>>> (Haskell server pages)
>>>>
>>>> -These widgets can be cached, to avoid widget rendering on every
>>>> interaction.
>>>>
>>>> -To handle the back button, and because the processes are stateful,
>>>> they can run backwards until the response match. This is transparent
>>>> for the programmer, thanks to the embedded FlowM monad.
>>>>
>>>> -All the code is in pure Haskell. No deployment, special scripts,
>>>> formats etc are necessary.
>>>>
>>>> -Besides automatic state persistence, TCache provides transactions and
>>>> user data persistence, that can be configured for SQL databases.
>>>> Default persistence in files permit very rapid prototyping. Just code
>>>> and run it with runghc.
>>>>
>>>> -Has AJAX support
>>>>
>>>> All of this sounds very complicated, but really it is simple!. Most of
>>>> these things are transparent. The resulting code is quite readable and
>>>> has very little plumbing!
>>>>
>>>> There is a non trivial example that some of these functionalities
>>>> embedded here that you can run:
>>>>
>>>>
>>>> http://hackage.haskell.org/packages/archive/MFlow/0.1.5.3/doc/html/MFlow-Forms.html
>>>>
>>>> Take a look and tell me your opinion.  I hope that you find it as
>>>> exciting as me.
>>>>
>>>>  I?m looking for people  to collaborate in the development of MFlow.
>>>>
>>>> Although still it is experimental, it is being used in at least one
>>>> future commercial project. So I have te commitment to continue its
>>>> development. There are many examples in the documentation and in the
>>>> package.
>>>>
>>>> Alberto
>>>>
>>>> _______________________________________________
>>>> Haskell mailing list
>>>> Haskell at haskell.org
>>>> http://www.haskell.org/mailman/listinfo/haskell
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


From ekirpichov at gmail.com  Tue Sep 18 20:51:23 2012
From: ekirpichov at gmail.com (Eugene Kirpichov)
Date: Tue, 18 Sep 2012 11:51:23 -0700
Subject: [Haskell-cafe] Choosing color of the track
In-Reply-To: 
References: 
	
	
Message-ID: 

Hi,

Suppose you have data like this:

2012-09-18 00:10:48,166 =responseTime 53
...

Then you should just use -dk 'quantile 0.95' and you'll see a graph of
stacked bars like [XXXX][YYYYY] (but vertical) where XXX is min..95%
and YYY is 95%..max.

On Tue, Sep 18, 2012 at 11:44 AM, Manish Trivedi  wrote:
> Thanks a ton Eugene. that worked like a charm :) Appreciate you looking into
> this and suggesting me the correct approach.
> I have another question that if I had single track storing response time of
> each request, how could I get 95th percentile of the response time. I know
> TimePlot wiki has quantile example but I havent been able to successfully
> use it.
>
> Regards,
> -Manish
>
>
> On Tue, Sep 18, 2012 at 10:48 AM, Eugene Kirpichov 
> wrote:
>>
>> Hi Manish,
>>
>> The meaning of "@" is not what you think it is. It merely draws
>> colored bars, it does NOT control the color of other kinds of charts.
>>
>> Here's how what you want can be achieved:
>> * Remove the "@" lines
>> * Append a common prefix to the input tracks you want to be displayed
>> on the same output track, e.g. "t.":
>> 2012-09-18 00:10:48,166 =t.CurrentPerHour13057 0.0
>> 2012-09-18 00:10:58,155 =t.CurrentPerHour13057 0.0
>> ..
>> 2012-09-18 03:58:28,159 =t.PacingReqPerHr13057 2375.0534412521242
>> 2012-09-18 03:58:38,161 =t.PacingReqPerHr13057 2375.383005739316
>>
>> * Use the "within" diagram kind: tplot .... -dk ''within[.] lines"
>>
>> Then you'll have a single output track where data from these input
>> tracks is displayed with different color. However, you don't control
>> the precise color (I just never really needed to control it, I only
>> needed it to be different for different tracks).
>>
>> On Mon, Sep 17, 2012 at 9:40 PM, Manish Trivedi 
>> wrote:
>> > Hi Folks,
>> >
>> > I am trying to plot two tracks with different colors.
>> > Following is my input file,
>> >
>> > ------
>> > 2012-09-18 00:10:48,166 @CurrentPerHour13057 Red
>> > 2012-09-18 00:10:48,166 =CurrentPerHour13057 0.0
>> > 2012-09-18 00:10:58,155 =CurrentPerHour13057 0.0
>> > 2012-09-18 00:11:08,203 =CurrentPerHour13057 0.0
>> > 2012-09-18 00:11:18,166 =CurrentPerHour13057 0.0
>> > 2012-09-18 00:11:28,159 =CurrentPerHour13057 0.0
>> > 2012-09-18 00:11:38,170 =CurrentPerHour13057 0.0
>> > 2012-09-18 00:11:48,175 =CurrentPerHour13057 0.0
>> > 2012-09-18 00:11:58,174 =CurrentPerHour13057 0.0
>> > 2012-09-18 00:12:08,216 =CurrentPerHour13057 0.0
>> > 2012-09-18 00:12:18,218 =CurrentPerHour13057 0.0
>> > 2012-09-18 03:58:28,159 @PacingReqPerHr13057 Blue
>> > 2012-09-18 03:58:28,159 =PacingReqPerHr13057 2375.0534412521242
>> > 2012-09-18 03:58:38,161 =PacingReqPerHr13057 2375.383005739316
>> > 2012-09-18 03:58:48,175 =PacingReqPerHr13057 2375.713057258422
>> > 2012-09-18 03:58:58,160 =PacingReqPerHr13057 2376.0422443063935
>> > 2012-09-18 03:59:08,192 =PacingReqPerHr13057 2376.3730727321126
>> > 2012-09-18 03:59:18,207 =PacingReqPerHr13057 2375.9038854561304
>> > 2012-09-18 03:59:28,168 =PacingReqPerHr13057 2376.2324444615497
>> > 2012-09-18 03:59:38,156 =PacingReqPerHr13057 2376.5619853019184
>> > 2012-09-18 03:59:48,160 =PacingReqPerHr13057 2376.892145685344
>> > 2012-09-18 03:59:58,160 =PacingReqPerHr13057 2377.222265743067
>> > -----
>> >
>> > tplot -o /root/color.png  -or 1024x768 -k 'CurrentPerHour' 'lines' -k
>> > 'PacingReqPerHr' 'lines' -if /root/color.input -tf 'date %Y-%m-%d
>> > %H:%M:%OS'
>> >
>> > I cant get to print plots in different color. Could anyone point out
>> > what am
>> > I doing wrong?
>> >
>> > Thanks,
>> > Manish
>> >
>> > _______________________________________________
>> > Haskell-Cafe mailing list
>> > Haskell-Cafe at haskell.org
>> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>> >
>>
>>
>>
>> --
>> Eugene Kirpichov
>> http://www.linkedin.com/in/eugenekirpichov
>> We're hiring! http://tinyurl.com/mirantis-openstack-engineer
>
>



-- 
Eugene Kirpichov
http://www.linkedin.com/in/eugenekirpichov
We're hiring! http://tinyurl.com/mirantis-openstack-engineer


From agocorona at gmail.com  Tue Sep 18 21:51:03 2012
From: agocorona at gmail.com (Alberto G. Corona )
Date: Tue, 18 Sep 2012 21:51:03 +0200
Subject: [Haskell-cafe] Fwd: [Haskell] ANNOUNCE: MFlow-0.1.5
In-Reply-To: 
References: 
	
	
	
	
	
Message-ID: 

Hi Jake,
right, it depends on the identification of the session:

iAll the tabs share the same state because they share the same cookies. so
if in one tab the use continue the interaction then the other tabs are out
of sync. If the user goes to these other tabs and press any widget, the
application will  synchronize back to this page.


This happens also if the user is logged in different computers.

Alberto.

2012/9/18 Jake McArthur 

> Actually, I meant users that spawn multiple tabs from a single root
> session. You mentioned that you have some special support for the back
> button. What happens if I open a couple new tabs in which I may or may
> not go forward and backward. Do they all share the same state?
> Different states (how?)? Partially shared states?
>
> On Tue, Sep 18, 2012 at 12:33 PM, Alberto G. Corona 
> wrote:
> > Oh,  I?m stupid. You mean web pages with multiple tabs....
> >
> >  I have not tested it. but each tab can be handled easily by a different
> > server process.. or it can be handled in a single server process, like
> in a
> > menu. For example, this code present different options, and the process
> > renders different things depending on the response.
> >
> > The last option is a link to a different process, while the others(
> wlinks)
> > are links that return back to the same process.
> > The operator <|> is the applicative operator.  a breakline is prepended
> to
> > each link:
> >
> > data Ops= Ints | Strings | Actions | Ajax | Opt deriving(Typeable,Read,
> > Show)
> >
> >  mainf=   do
> >         r <- ask $   wlink Ints (bold << "increase an Int")
> >                 <|>  br ++> wlink Strings (bold << "increase a String")
> >                 <|>  br ++> wlink Actions (bold << "Example of a string
> > widget with an action")
> >                 <|>  br ++> wlink Ajax (bold << "Simple AJAX example")
> >                 <|>  br ++> wlink Opt (bold << "select options")
> >                 <++ (br +++ linkShop) -- this is an ordinary XHtml link
> >
> >         case r of
> >           Ints    ->  clickn 0
> >           Strings ->  clicks "1"
> >           Actions ->  actions 1
> >           Ajax    ->  ajaxsample
> >           Opt     ->  options
> >         mainf
> >      where
> >      linkShop= toHtml $ hotlink  "shop" << "shopping"
> >
> > .
> > Alberto
> >
> > 2012/9/18 Alberto G. Corona :
> >
> >> Hi Jake
> >>
> >> I don?t know what you mean with multiple tabs. The user management is
> >> simple, anonymous clients are identified with  a cookie. if the user
> >> is logged (MFlow has widgets for logging-validation) the user is the
> >> identifier.
> >>
> >> The state of a process is associated to the client identifier and to
> >> the path invoked in the url requested.
> >>
> >> I don?t know if this answer your question....
> >>
> >> Alberto
> >>
> >> 2012/9/18 Jake McArthur :
> >>> This sounds really cool.
> >>>
> >>> How do you handle users having multiple tabs?
> >>>
> >>> On Tue, Sep 18, 2012 at 11:26 AM, Alberto G. Corona <
> agocorona at gmail.com>
> >>> wrote:
> >>>> Hi haskellers and specially the web developers.
> >>>>
> >>>> http://hackage.haskell.org/package/MFlow-0.1.5.3
> >>>>
> >>>> MFlow is a is a Web framework with some unique, and I mean unique,
> >>>> characteristics that I find exciting:
> >>>>
> >>>> - It is a Web application server that start and restart on-demand
> >>>> stateful web server processes (not request.-response)
> >>>>   This means that all the page navigation can be coded in a single
> >>>> procedure. This increases readability of the programmer code. I woul
> >>>> call it
> >>>> a anti-node.js.  Buit usual request-response (stateless) server
> >>>> processes are also allowed
> >>>>
> >>>> - When the process is invoqued as result of an URL request, the Web
> >>>> app server not only restart the process but also recover its execution
> >>>> state. The enclosing Workflow monad provides the thread state
> >>>> persistence. There are state timeouts and process timeouts defined by
> >>>> the programmer. Processes with no persistent state (transient) are
> >>>> possible.
> >>>>
> >>>> -The user interface is made of widgets. They are  formlets with added
> >>>> formatting,   attributes, validations, modifiers and callbacks, that
> >>>> are composable, so the pieces are reusable and return type safe
> >>>> responses to the calling process. Even the links are part of widgets
> >>>> and return back type safe inputs at compile time to the calling server
> >>>> process. Tho glue these components, ordinary applicative combinators
> >>>> and other extra combinators are used.
> >>>>
> >>>> - The widgets and the communication don?t make assumptions about the
> >>>> architecture, so it can be adapted to non-web environments. This
> >>>> versions has interface for WAI-warp, Hack, Text.XHtml (xhtml) , and
> >>>> Haskell Server Pages.
> >>>>
> >>>> -The widget rendering can be converted to ByteStrings automatically
> >>>> with special combinators. A mix of widgets with different formats can
> >>>> be combined in the same source file. For example Text.Html and HSP
> >>>> (Haskell server pages)
> >>>>
> >>>> -These widgets can be cached, to avoid widget rendering on every
> >>>> interaction.
> >>>>
> >>>> -To handle the back button, and because the processes are stateful,
> >>>> they can run backwards until the response match. This is transparent
> >>>> for the programmer, thanks to the embedded FlowM monad.
> >>>>
> >>>> -All the code is in pure Haskell. No deployment, special scripts,
> >>>> formats etc are necessary.
> >>>>
> >>>> -Besides automatic state persistence, TCache provides transactions and
> >>>> user data persistence, that can be configured for SQL databases.
> >>>> Default persistence in files permit very rapid prototyping. Just code
> >>>> and run it with runghc.
> >>>>
> >>>> -Has AJAX support
> >>>>
> >>>> All of this sounds very complicated, but really it is simple!. Most of
> >>>> these things are transparent. The resulting code is quite readable and
> >>>> has very little plumbing!
> >>>>
> >>>> There is a non trivial example that some of these functionalities
> >>>> embedded here that you can run:
> >>>>
> >>>>
> >>>>
> http://hackage.haskell.org/packages/archive/MFlow/0.1.5.3/doc/html/MFlow-Forms.html
> >>>>
> >>>> Take a look and tell me your opinion.  I hope that you find it as
> >>>> exciting as me.
> >>>>
> >>>>  I?m looking for people  to collaborate in the development of MFlow.
> >>>>
> >>>> Although still it is experimental, it is being used in at least one
> >>>> future commercial project. So I have te commitment to continue its
> >>>> development. There are many examples in the documentation and in the
> >>>> package.
> >>>>
> >>>> Alberto
> >>>>
> >>>> _______________________________________________
> >>>> Haskell mailing list
> >>>> Haskell at haskell.org
> >>>> http://www.haskell.org/mailman/listinfo/haskell
> >
> >
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From rendel at informatik.uni-marburg.de  Tue Sep 18 22:00:33 2012
From: rendel at informatik.uni-marburg.de (Tillmann Rendel)
Date: Tue, 18 Sep 2012 22:00:33 +0200
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: <50586773.1020902@ist.utl.pt>
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
	
	<505860A4.6020106@ist.utl.pt>
	
	<50586773.1020902@ist.utl.pt>
Message-ID: <5058D2E1.2080905@informatik.uni-marburg.de>

Hi,

Jos? Lopes wrote in an earlier email:
> I want to find a natural way of not burdening the user with the task of having to learn
> some special syntax in order to write a document.

And then:
> [...] we can leave " for quoting and use the ' for something else.

That sounds like 'some special syntax' to me. Or should it be "some 
special syntax"? I can't remember which was for quoting and which was 
for something else. Maybe I need to look that up in the Fmark 
documentation, again.

   Tillmann


From jose.lopes at ist.utl.pt  Tue Sep 18 22:06:56 2012
From: jose.lopes at ist.utl.pt (=?ISO-8859-1?Q?Jos=E9_Lopes?=)
Date: Tue, 18 Sep 2012 21:06:56 +0100
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: <5058D2E1.2080905@informatik.uni-marburg.de>
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
	
	<505860A4.6020106@ist.utl.pt>
	
	<50586773.1020902@ist.utl.pt>
	<5058D2E1.2080905@informatik.uni-marburg.de>
Message-ID: <5058D460.90605@ist.utl.pt>

Hey Tillmann,

That is a good point. What would you suggest for emphasis ?

Cheers,
Jos?

On 18-09-2012 21:00, Tillmann Rendel wrote:
> Hi,
>
> Jos? Lopes wrote in an earlier email:
>> I want to find a natural way of not burdening the user with the task 
>> of having to learn
>> some special syntax in order to write a document.
>
> And then:
>> [...] we can leave " for quoting and use the ' for something else.
>
> That sounds like 'some special syntax' to me. Or should it be "some 
> special syntax"? I can't remember which was for quoting and which was 
> for something else. Maybe I need to look that up in the Fmark 
> documentation, again.
>
>   Tillmann

-- 
Jos? Ant?nio Branquinho de Oliveira Lopes
Instituto Superior T?cnico
Technical University of Lisbon



From agocorona at gmail.com  Tue Sep 18 22:39:13 2012
From: agocorona at gmail.com (Alberto G. Corona )
Date: Tue, 18 Sep 2012 22:39:13 +0200
Subject: [Haskell-cafe] Fwd: [Haskell] ANNOUNCE: MFlow-0.1.5
In-Reply-To: 
References: 
	
	
	
	
	
	
Message-ID: 

However if in a tab out of sync the user press refresh, the tab will
refresh to the current state.
I took care not to try to synchronize back as a consequence of a page that
is in a  forward state in one tab, as a consequence of navigating back in
other tab.  However I may have not considered all the edge extreme cases.

There is a back detection primitive
"goingBack"
that allow the programmer to control the back behaviour in some special
cases.

For example if i want to step over  a menu and present a default page, But
if when the user go back i want to present the menu, I can detect this
condition and present this menu, that did not appeared in a normal
navigation:

This code sets and get a default option  in the menu, so the menu is not
shown again in the navigation, except in the case that the user press the
back button. Otherwise, the menu would be never accessible.

However this is very specialized. normally the back button detection is not
necessary. In a persistent flow even this default entry option would be
completely automatic, since the process would restar at the last page
visited. No setting is necessary.


menu= do
       mop <- getGoStraighTo
       back <- goingBack

       case (mop,back) of
        (Just goop,False) -> goop
        _ -> do
               r <- ask

option1 <|> option2
               case r of
                op1 -> setGoStraighTo (Just goop1) >> goop1
                op2 -> setGoStraighTo (Just goop2) >> goop2





2012/9/18 Alberto G. Corona 

> Hi Jake,
> right, it depends on the identification of the session:
>
> iAll the tabs share the same state because they share the same cookies. so
> if in one tab the use continue the interaction then the other tabs are out
> of sync. If the user goes to these other tabs and press any widget, the
> application will  synchronize back to this page.
>
>
> This happens also if the user is logged in different computers.
>
> Alberto.
>
> 2012/9/18 Jake McArthur 
>
>> Actually, I meant users that spawn multiple tabs from a single root
>> session. You mentioned that you have some special support for the back
>> button. What happens if I open a couple new tabs in which I may or may
>> not go forward and backward. Do they all share the same state?
>> Different states (how?)? Partially shared states?
>>
>> On Tue, Sep 18, 2012 at 12:33 PM, Alberto G. Corona 
>> wrote:
>> > Oh,  I?m stupid. You mean web pages with multiple tabs....
>> >
>> >  I have not tested it. but each tab can be handled easily by a different
>> > server process.. or it can be handled in a single server process, like
>> in a
>> > menu. For example, this code present different options, and the process
>> > renders different things depending on the response.
>> >
>> > The last option is a link to a different process, while the others(
>> wlinks)
>> > are links that return back to the same process.
>> > The operator <|> is the applicative operator.  a breakline is prepended
>> to
>> > each link:
>> >
>> > data Ops= Ints | Strings | Actions | Ajax | Opt deriving(Typeable,Read,
>> > Show)
>> >
>> >  mainf=   do
>> >         r <- ask $   wlink Ints (bold << "increase an Int")
>> >                 <|>  br ++> wlink Strings (bold << "increase a String")
>> >                 <|>  br ++> wlink Actions (bold << "Example of a string
>> > widget with an action")
>> >                 <|>  br ++> wlink Ajax (bold << "Simple AJAX example")
>> >                 <|>  br ++> wlink Opt (bold << "select options")
>> >                 <++ (br +++ linkShop) -- this is an ordinary XHtml link
>> >
>> >         case r of
>> >           Ints    ->  clickn 0
>> >           Strings ->  clicks "1"
>> >           Actions ->  actions 1
>> >           Ajax    ->  ajaxsample
>> >           Opt     ->  options
>> >         mainf
>> >      where
>> >      linkShop= toHtml $ hotlink  "shop" << "shopping"
>> >
>> > .
>> > Alberto
>> >
>> > 2012/9/18 Alberto G. Corona :
>> >
>> >> Hi Jake
>> >>
>> >> I don?t know what you mean with multiple tabs. The user management is
>> >> simple, anonymous clients are identified with  a cookie. if the user
>> >> is logged (MFlow has widgets for logging-validation) the user is the
>> >> identifier.
>> >>
>> >> The state of a process is associated to the client identifier and to
>> >> the path invoked in the url requested.
>> >>
>> >> I don?t know if this answer your question....
>> >>
>> >> Alberto
>> >>
>> >> 2012/9/18 Jake McArthur :
>> >>> This sounds really cool.
>> >>>
>> >>> How do you handle users having multiple tabs?
>> >>>
>> >>> On Tue, Sep 18, 2012 at 11:26 AM, Alberto G. Corona <
>> agocorona at gmail.com>
>> >>> wrote:
>> >>>> Hi haskellers and specially the web developers.
>> >>>>
>> >>>> http://hackage.haskell.org/package/MFlow-0.1.5.3
>> >>>>
>> >>>> MFlow is a is a Web framework with some unique, and I mean unique,
>> >>>> characteristics that I find exciting:
>> >>>>
>> >>>> - It is a Web application server that start and restart on-demand
>> >>>> stateful web server processes (not request.-response)
>> >>>>   This means that all the page navigation can be coded in a single
>> >>>> procedure. This increases readability of the programmer code. I woul
>> >>>> call it
>> >>>> a anti-node.js.  Buit usual request-response (stateless) server
>> >>>> processes are also allowed
>> >>>>
>> >>>> - When the process is invoqued as result of an URL request, the Web
>> >>>> app server not only restart the process but also recover its
>> execution
>> >>>> state. The enclosing Workflow monad provides the thread state
>> >>>> persistence. There are state timeouts and process timeouts defined by
>> >>>> the programmer. Processes with no persistent state (transient) are
>> >>>> possible.
>> >>>>
>> >>>> -The user interface is made of widgets. They are  formlets with added
>> >>>> formatting,   attributes, validations, modifiers and callbacks, that
>> >>>> are composable, so the pieces are reusable and return type safe
>> >>>> responses to the calling process. Even the links are part of widgets
>> >>>> and return back type safe inputs at compile time to the calling
>> server
>> >>>> process. Tho glue these components, ordinary applicative combinators
>> >>>> and other extra combinators are used.
>> >>>>
>> >>>> - The widgets and the communication don?t make assumptions about the
>> >>>> architecture, so it can be adapted to non-web environments. This
>> >>>> versions has interface for WAI-warp, Hack, Text.XHtml (xhtml) , and
>> >>>> Haskell Server Pages.
>> >>>>
>> >>>> -The widget rendering can be converted to ByteStrings automatically
>> >>>> with special combinators. A mix of widgets with different formats can
>> >>>> be combined in the same source file. For example Text.Html and HSP
>> >>>> (Haskell server pages)
>> >>>>
>> >>>> -These widgets can be cached, to avoid widget rendering on every
>> >>>> interaction.
>> >>>>
>> >>>> -To handle the back button, and because the processes are stateful,
>> >>>> they can run backwards until the response match. This is transparent
>> >>>> for the programmer, thanks to the embedded FlowM monad.
>> >>>>
>> >>>> -All the code is in pure Haskell. No deployment, special scripts,
>> >>>> formats etc are necessary.
>> >>>>
>> >>>> -Besides automatic state persistence, TCache provides transactions
>> and
>> >>>> user data persistence, that can be configured for SQL databases.
>> >>>> Default persistence in files permit very rapid prototyping. Just code
>> >>>> and run it with runghc.
>> >>>>
>> >>>> -Has AJAX support
>> >>>>
>> >>>> All of this sounds very complicated, but really it is simple!. Most
>> of
>> >>>> these things are transparent. The resulting code is quite readable
>> and
>> >>>> has very little plumbing!
>> >>>>
>> >>>> There is a non trivial example that some of these functionalities
>> >>>> embedded here that you can run:
>> >>>>
>> >>>>
>> >>>>
>> http://hackage.haskell.org/packages/archive/MFlow/0.1.5.3/doc/html/MFlow-Forms.html
>> >>>>
>> >>>> Take a look and tell me your opinion.  I hope that you find it as
>> >>>> exciting as me.
>> >>>>
>> >>>>  I?m looking for people  to collaborate in the development of MFlow.
>> >>>>
>> >>>> Although still it is experimental, it is being used in at least one
>> >>>> future commercial project. So I have te commitment to continue its
>> >>>> development. There are many examples in the documentation and in the
>> >>>> package.
>> >>>>
>> >>>> Alberto
>> >>>>
>> >>>> _______________________________________________
>> >>>> Haskell mailing list
>> >>>> Haskell at haskell.org
>> >>>> http://www.haskell.org/mailman/listinfo/haskell
>> >
>> >
>> >
>> > _______________________________________________
>> > Haskell-Cafe mailing list
>> > Haskell-Cafe at haskell.org
>> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>> >
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From ryani.spam at gmail.com  Tue Sep 18 23:41:41 2012
From: ryani.spam at gmail.com (Ryan Ingram)
Date: Tue, 18 Sep 2012 14:41:41 -0700
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
In-Reply-To: <20120918082736.61798.qmail@www1.g3.pair.com>
References: <20120918082736.61798.qmail@www1.g3.pair.com>
Message-ID: 

Oleg, do you have any references for the extension of lambda-encoding of
data into dependently typed systems?

In particular, consider Nat:

    nat_elim :: forall P:(Nat -> *). P 0 -> (forall n:Nat. P n -> P (succ
n)) -> (n:Nat) -> P n

The naive lambda-encoding of 'nat' in the untyped lambda-calculus has
exactly the correct form for passing to nat_elim:

    nat_elim pZero pSucc n = n pZero pSucc

with

    zero :: Nat
    zero pZero pSucc = pZero

    succ :: Nat -> Nat
    succ n pZero pSucc = pSucc (n pZero pSucc)

But trying to encode the numerals this way leads to "Nat" referring to its
value in its type!

   type Nat = forall P:(Nat  -> *). P 0 -> (forall n:Nat. P n -> P (succ
n)) -> P ???

Is there a way out of this quagmire?  Or are we stuck defining actual
datatypes if we want dependent types?

  -- ryan


On Tue, Sep 18, 2012 at 1:27 AM,  wrote:

>
> There has been a recent discussion of ``Church encoding'' of lists and
> the comparison with Scott encoding.
>
> I'd like to point out that what is often called Church encoding is
> actually Boehm-Berarducci encoding. That is, often seen
>
> > newtype ChurchList a =
> >     CL { cataCL :: forall r. (a -> r -> r) -> r -> r }
>
> (in http://community.haskell.org/%7Ewren/list-extras/Data/List/Church.hs )
>
> is _not_ Church encoding. First of all, Church encoding is not typed
> and it is not tight. The following article explains the other
> difference between the encodings
>
>         http://okmij.org/ftp/tagless-final/course/Boehm-Berarducci.html
>
> Boehm-Berarducci encoding is very insightful and influential. The
> authors truly deserve credit.
>
> P.S. It is actually possible to write zip function using Boehm-Berarducci
> encoding:
>         http://okmij.org/ftp/ftp/Algorithms.html#zip-folds
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From dan.doel at gmail.com  Wed Sep 19 01:09:11 2012
From: dan.doel at gmail.com (Dan Doel)
Date: Tue, 18 Sep 2012 19:09:11 -0400
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
In-Reply-To: 
References: <20120918082736.61798.qmail@www1.g3.pair.com>
	
Message-ID: 

This paper:

    http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.26.957

Induction is Not Derivable in Second Order Dependent Type Theory,
shows, well, that you can't encode naturals with a strong induction
principle in said theory. At all, no matter what tricks you try.

However, A Logic for Parametric Polymorphism,

    http://www.era.lib.ed.ac.uk/bitstream/1842/205/1/Par_Poly.pdf

Indicates that in a type theory incorporating relational parametricity
of its own types,  the induction principle for the ordinary
Church-like encoding of natural numbers can be derived. I've done some
work here:

    http://code.haskell.org/~dolio/agda-share/html/ParamInduction.html

for some simpler types (although, I've been informed that sigma was
novel, it not being a Simple Type), but haven't figured out natural
numbers yet (I haven't actually studied the second paper above, which
I was pointed to recently).

-- Dan

On Tue, Sep 18, 2012 at 5:41 PM, Ryan Ingram  wrote:
> Oleg, do you have any references for the extension of lambda-encoding of
> data into dependently typed systems?
>
> In particular, consider Nat:
>
>     nat_elim :: forall P:(Nat -> *). P 0 -> (forall n:Nat. P n -> P (succ
> n)) -> (n:Nat) -> P n
>
> The naive lambda-encoding of 'nat' in the untyped lambda-calculus has
> exactly the correct form for passing to nat_elim:
>
>     nat_elim pZero pSucc n = n pZero pSucc
>
> with
>
>     zero :: Nat
>     zero pZero pSucc = pZero
>
>     succ :: Nat -> Nat
>     succ n pZero pSucc = pSucc (n pZero pSucc)
>
> But trying to encode the numerals this way leads to "Nat" referring to its
> value in its type!
>
>    type Nat = forall P:(Nat  -> *). P 0 -> (forall n:Nat. P n -> P (succ n))
> -> P ???
>
> Is there a way out of this quagmire?  Or are we stuck defining actual
> datatypes if we want dependent types?
>
>   -- ryan
>
>
>
> On Tue, Sep 18, 2012 at 1:27 AM,  wrote:
>>
>>
>> There has been a recent discussion of ``Church encoding'' of lists and
>> the comparison with Scott encoding.
>>
>> I'd like to point out that what is often called Church encoding is
>> actually Boehm-Berarducci encoding. That is, often seen
>>
>> > newtype ChurchList a =
>> >     CL { cataCL :: forall r. (a -> r -> r) -> r -> r }
>>
>> (in http://community.haskell.org/%7Ewren/list-extras/Data/List/Church.hs )
>>
>> is _not_ Church encoding. First of all, Church encoding is not typed
>> and it is not tight. The following article explains the other
>> difference between the encodings
>>
>>         http://okmij.org/ftp/tagless-final/course/Boehm-Berarducci.html
>>
>> Boehm-Berarducci encoding is very insightful and influential. The
>> authors truly deserve credit.
>>
>> P.S. It is actually possible to write zip function using Boehm-Berarducci
>> encoding:
>>         http://okmij.org/ftp/ftp/Algorithms.html#zip-folds
>>
>>
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


From ok at cs.otago.ac.nz  Wed Sep 19 01:24:48 2012
From: ok at cs.otago.ac.nz (Richard O'Keefe)
Date: Wed, 19 Sep 2012 11:24:48 +1200
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: <50586355.3040100@ist.utl.pt>
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
	
	<50586355.3040100@ist.utl.pt>
Message-ID: 


On 19/09/2012, at 12:04 AM, Jos? Lopes wrote:

> Hello Richard,
> 
> When you say "(for) some people (...) you special syntax is not natural"
> that's a good thing. I want these people involved in the project. I want
> to understand what they find natural in order to weigh the options and
> make a proper decision.

One important question is how many *scripts* you want to support.
Do you, for example, want to support Greek?  There is a Unicode
character for Greek question mark U+037E, some documentation I've
seen says that the preferred character is U+003F.  So does ";"
terminate a sentence or not?
How many *languages* do you want to support?
Are you going to support Armenian, where the question mark that
ends a sentence goes not _after the last letter_ of the last
word but _over the last vowel_?

(As someone who only writes in English, I have no trouble with the
answer "only the Latin script, only the English language".)

I don't actually believe that there _is_ a natural convention for
italics, boldface, superscripts, etc.  Even _this_ is an artificial
convention going back to mechanical typewriters that could underline
but not change font.
> 
> On the README file in the github page you will find a brief explanation
> of the markup elements. I need to elaborate you that though because
> I feel I explain it too fast.
> https://github.com/jabolopes/fmark

I did read the README.md.  I disagree that there exists any problem
of manual removal of special characters.  If I want to remove XML markup,
I just do unxml foobar.xml >foobar.txt.  If I want to convert from one
kind of markup to another, there is pandoc, which is admittedly a touch
buggy, ...

The problem is that the README.md does not in fact explain what any
of the 'markup elements' are.

Let's take one little example, a letter of the kind I used to write
by hand.

			123 Copper Road,
			   Gemstone,
			      Dunedin,
			         New Zealand 9999.
			31 February 2016.

Dear Schnorer,
   I am writing to you because I am tired of frobulating.

			Yours without wax,
			   Dr Strabismus of Utrecht
			      (whom God preserve!)

How do I tell Fmark about this structure?
How do I get this layout?  (The '1' and 'Y' should be in the centre.)

> Let me answer your questions about sections. The amount of indentation
> is not fixed. You can use whatever you want. There is also no nesting limit
> in Fmark, however, there is a nesting limit in the Latex backend. For now,
> quotations, block quotes, source code embedding, etc, are not implemented.
> Those will be added in the future.

These answers belong in the README.me.
> 
> About embedding a Fmark document in another document. That seems to
> be a very cool feature. I will definitely think about it! Maybe you can come
> up with a "natural" way of doing it?

The last time I thought I had a natural way to do anything like that
I found that the SGML design was worse broken than I would have believed possible.


From ok at cs.otago.ac.nz  Wed Sep 19 01:37:46 2012
From: ok at cs.otago.ac.nz (Richard O'Keefe)
Date: Wed, 19 Sep 2012 11:37:46 +1200
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: 
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
	
	
Message-ID: <0D4FD146-FA8E-4E29-806A-F9D7E7CF22CB@cs.otago.ac.nz>


On 19/09/2012, at 1:43 AM, Stefan Monnier wrote:

>> The problem with that is that some people DO end some headings with
>> a full stop; for them your special syntax is not natural.
> 
> Markdown/ReST is already using the "no syntax" idea (e.g. compared to
> pre-wiki markup such a LaTeX or Texinfo), so he's simply trying to push
> this idea further.

Markdown is very heavy on syntax,
what it is *light* on is specification of what the
syntax actually is.  As a result,
I'm aware of three different dialects,
and someone told me about having to reverse
engineer the syntax from a Perl implementation.
As a further result, I cannot write a program to
reliably *generate* Markdown.
> 
> I suspect it'll be difficult.

Oh, more power to him for trying.
I just don't think it can be pushed very far.

Oh, there is a really *filthy* hack that could be pulled
for italics, bold face, and so on.  Contrary to its original
principles, Unicode includes several copies of ASCII
(see http://unicode.org/charts/PDF/U1D400.pdf):
Mathematical bold,
Mathematical italic,
Mathematical bold italic,
Mathematical script,
Mathematical bold script,
Mathematical fraktur,
Mathematical double struck (blackboard-bold),
Mathematical bold fraktur,
Mathematical sans-serif,
Mathematical sans-serif bold,
Mathematical sans-serif italic,
Mathematical sans-serif bold italic,
Mathematical monospace,
and some similar sets of Greek.
So as long as you don't want strike-through or underlying,
and as long as you don't want italic Cyrillic &c, ...
Too bad if you want a bold italic capital Thorn...

> 
>> What if I want to use indentation to express quotation instead?
> 
> I think this one is solvable: a paragraph that's more indented than the
> previous heading can be considered a quote.

Ah, but the quotation might not end with a sentence terminator,
so that would be considered a new heading.



From jose.lopes at ist.utl.pt  Wed Sep 19 02:21:01 2012
From: jose.lopes at ist.utl.pt (=?ISO-8859-1?Q?Jos=E9_Lopes?=)
Date: Wed, 19 Sep 2012 01:21:01 +0100
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: <0D4FD146-FA8E-4E29-806A-F9D7E7CF22CB@cs.otago.ac.nz>
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
	
	
	<0D4FD146-FA8E-4E29-806A-F9D7E7CF22CB@cs.otago.ac.nz>
Message-ID: <50590FED.7070809@ist.utl.pt>

Hey Richard,

Regarding the languages, I think it is better to start with English
and see how successful Fmark is. There's no point in trying to tackle
lots of languages if we cannot solve the problem for one of them.
But then again, keeping everything Unicode.

In fact, in this matter, I think with Haskell we have an advantage
because things like 'isSpace' and 'isPuncuation' work with Unicode.

I now understand that the README.md is rather incomplete. I will
add some more information about the markup. Although, things
like bold, italics and so on are not implemented yet.

I will also take a look at your letter example. I think the real
challenge here is center alignment. I will think about a
way to solve it in Fmark so we can discuss it later on.

Thank you for the feedback.

Cheers,
Jos?

On 19-09-2012 00:37, Richard O'Keefe wrote:
> On 19/09/2012, at 1:43 AM, Stefan Monnier wrote:
>
>>> The problem with that is that some people DO end some headings with
>>> a full stop; for them your special syntax is not natural.
>> Markdown/ReST is already using the "no syntax" idea (e.g. compared to
>> pre-wiki markup such a LaTeX or Texinfo), so he's simply trying to push
>> this idea further.
> Markdown is very heavy on syntax,
> what it is *light* on is specification of what the
> syntax actually is.  As a result,
> I'm aware of three different dialects,
> and someone told me about having to reverse
> engineer the syntax from a Perl implementation.
> As a further result, I cannot write a program to
> reliably *generate* Markdown.
>> I suspect it'll be difficult.
> Oh, more power to him for trying.
> I just don't think it can be pushed very far.
>
> Oh, there is a really *filthy* hack that could be pulled
> for italics, bold face, and so on.  Contrary to its original
> principles, Unicode includes several copies of ASCII
> (see http://unicode.org/charts/PDF/U1D400.pdf):
> Mathematical bold,
> Mathematical italic,
> Mathematical bold italic,
> Mathematical script,
> Mathematical bold script,
> Mathematical fraktur,
> Mathematical double struck (blackboard-bold),
> Mathematical bold fraktur,
> Mathematical sans-serif,
> Mathematical sans-serif bold,
> Mathematical sans-serif italic,
> Mathematical sans-serif bold italic,
> Mathematical monospace,
> and some similar sets of Greek.
> So as long as you don't want strike-through or underlying,
> and as long as you don't want italic Cyrillic &c, ...
> Too bad if you want a bold italic capital Thorn...
>
>>> What if I want to use indentation to express quotation instead?
>> I think this one is solvable: a paragraph that's more indented than the
>> previous heading can be considered a quote.
> Ah, but the quotation might not end with a sentence terminator,
> so that would be considered a new heading.
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

-- 
Jos? Ant?nio Branquinho de Oliveira Lopes
Instituto Superior T?cnico
Technical University of Lisbon



From jose.lopes at ist.utl.pt  Wed Sep 19 04:29:31 2012
From: jose.lopes at ist.utl.pt (=?ISO-8859-1?Q?Jos=E9_Lopes?=)
Date: Wed, 19 Sep 2012 03:29:31 +0100
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: <50590FED.7070809@ist.utl.pt>
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
	
	
	<0D4FD146-FA8E-4E29-806A-F9D7E7CF22CB@cs.otago.ac.nz>
	<50590FED.7070809@ist.utl.pt>
Message-ID: <50592E0B.5080001@ist.utl.pt>

Hello Richard,

I made a first draft of your letter example.
It is not exactly as you had written but I think you might like it.
It is the combination of a content document (letter) and a style
document (letter.style). You can see the results in the PDF, which
was created using the Latex backend and the letter document
class.

Cheers,
Jos?

On 19-09-2012 01:21, Jos? Lopes wrote:
> Hey Richard,
>
> Regarding the languages, I think it is better to start with English
> and see how successful Fmark is. There's no point in trying to tackle
> lots of languages if we cannot solve the problem for one of them.
> But then again, keeping everything Unicode.
>
> In fact, in this matter, I think with Haskell we have an advantage
> because things like 'isSpace' and 'isPuncuation' work with Unicode.
>
> I now understand that the README.md is rather incomplete. I will
> add some more information about the markup. Although, things
> like bold, italics and so on are not implemented yet.
>
> I will also take a look at your letter example. I think the real
> challenge here is center alignment. I will think about a
> way to solve it in Fmark so we can discuss it later on.
>
> Thank you for the feedback.
>
> Cheers,
> Jos?
>
> On 19-09-2012 00:37, Richard O'Keefe wrote:
>> On 19/09/2012, at 1:43 AM, Stefan Monnier wrote:
>>
>>>> The problem with that is that some people DO end some headings with
>>>> a full stop; for them your special syntax is not natural.
>>> Markdown/ReST is already using the "no syntax" idea (e.g. compared to
>>> pre-wiki markup such a LaTeX or Texinfo), so he's simply trying to push
>>> this idea further.
>> Markdown is very heavy on syntax,
>> what it is *light* on is specification of what the
>> syntax actually is.  As a result,
>> I'm aware of three different dialects,
>> and someone told me about having to reverse
>> engineer the syntax from a Perl implementation.
>> As a further result, I cannot write a program to
>> reliably *generate* Markdown.
>>> I suspect it'll be difficult.
>> Oh, more power to him for trying.
>> I just don't think it can be pushed very far.
>>
>> Oh, there is a really *filthy* hack that could be pulled
>> for italics, bold face, and so on.  Contrary to its original
>> principles, Unicode includes several copies of ASCII
>> (see http://unicode.org/charts/PDF/U1D400.pdf):
>> Mathematical bold,
>> Mathematical italic,
>> Mathematical bold italic,
>> Mathematical script,
>> Mathematical bold script,
>> Mathematical fraktur,
>> Mathematical double struck (blackboard-bold),
>> Mathematical bold fraktur,
>> Mathematical sans-serif,
>> Mathematical sans-serif bold,
>> Mathematical sans-serif italic,
>> Mathematical sans-serif bold italic,
>> Mathematical monospace,
>> and some similar sets of Greek.
>> So as long as you don't want strike-through or underlying,
>> and as long as you don't want italic Cyrillic &c, ...
>> Too bad if you want a bold italic capital Thorn...
>>
>>>> What if I want to use indentation to express quotation instead?
>>> I think this one is solvable: a paragraph that's more indented than the
>>> previous heading can be considered a quote.
>> Ah, but the quotation might not end with a sentence terminator,
>> so that would be considered a new heading.
>>
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>

-- 
Jos? Ant?nio Branquinho de Oliveira Lopes
Instituto Superior T?cnico
Technical University of Lisbon

-------------- next part --------------
123 Copper Road,
Gemstone,
Dunedin,
New Zealand 9999

31 February 2016

Dear Schnorer,
   I am writing to you because I am tired of frobulating.
   I am also tired of this and that.

Yours without wax,

Dr Strabismus of Utrecht
(whom God preserve!)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: letter.pdf
Type: application/pdf
Size: 19459 bytes
Desc: not available
URL: 
-------------- next part --------------
Address

Date

Opening,
  Letter.

Closing,

Signature

From ryani.spam at gmail.com  Wed Sep 19 05:19:22 2012
From: ryani.spam at gmail.com (Ryan Ingram)
Date: Tue, 18 Sep 2012 20:19:22 -0700
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
In-Reply-To: 
References: <20120918082736.61798.qmail@www1.g3.pair.com>
	
	
Message-ID: 

Fascinating!

But it looks like you still 'cheat' in your induction principles...

?-induction : ?{A B} {P : A ? B ? Set}
            ? ((x : A) ? (y : B) ? P (x , y))
            ? (p : A ? B) ? P p
?-induction {A} {B} {P} f p rewrite sym (?-? p) = f (fst p) (snd p)

Can you somehow define

x-induction {A} {B} {P} f p = p (P p) f


On Tue, Sep 18, 2012 at 4:09 PM, Dan Doel  wrote:

> This paper:
>
>     http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.26.957
>
> Induction is Not Derivable in Second Order Dependent Type Theory,
> shows, well, that you can't encode naturals with a strong induction
> principle in said theory. At all, no matter what tricks you try.
>
> However, A Logic for Parametric Polymorphism,
>
>     http://www.era.lib.ed.ac.uk/bitstream/1842/205/1/Par_Poly.pdf
>
> Indicates that in a type theory incorporating relational parametricity
> of its own types,  the induction principle for the ordinary
> Church-like encoding of natural numbers can be derived. I've done some
> work here:
>
>     http://code.haskell.org/~dolio/agda-share/html/ParamInduction.html
>
> for some simpler types (although, I've been informed that sigma was
> novel, it not being a Simple Type), but haven't figured out natural
> numbers yet (I haven't actually studied the second paper above, which
> I was pointed to recently).
>
> -- Dan
>
> On Tue, Sep 18, 2012 at 5:41 PM, Ryan Ingram  wrote:
> > Oleg, do you have any references for the extension of lambda-encoding of
> > data into dependently typed systems?
> >
> > In particular, consider Nat:
> >
> >     nat_elim :: forall P:(Nat -> *). P 0 -> (forall n:Nat. P n -> P (succ
> > n)) -> (n:Nat) -> P n
> >
> > The naive lambda-encoding of 'nat' in the untyped lambda-calculus has
> > exactly the correct form for passing to nat_elim:
> >
> >     nat_elim pZero pSucc n = n pZero pSucc
> >
> > with
> >
> >     zero :: Nat
> >     zero pZero pSucc = pZero
> >
> >     succ :: Nat -> Nat
> >     succ n pZero pSucc = pSucc (n pZero pSucc)
> >
> > But trying to encode the numerals this way leads to "Nat" referring to
> its
> > value in its type!
> >
> >    type Nat = forall P:(Nat  -> *). P 0 -> (forall n:Nat. P n -> P (succ
> n))
> > -> P ???
> >
> > Is there a way out of this quagmire?  Or are we stuck defining actual
> > datatypes if we want dependent types?
> >
> >   -- ryan
> >
> >
> >
> > On Tue, Sep 18, 2012 at 1:27 AM,  wrote:
> >>
> >>
> >> There has been a recent discussion of ``Church encoding'' of lists and
> >> the comparison with Scott encoding.
> >>
> >> I'd like to point out that what is often called Church encoding is
> >> actually Boehm-Berarducci encoding. That is, often seen
> >>
> >> > newtype ChurchList a =
> >> >     CL { cataCL :: forall r. (a -> r -> r) -> r -> r }
> >>
> >> (in
> http://community.haskell.org/%7Ewren/list-extras/Data/List/Church.hs )
> >>
> >> is _not_ Church encoding. First of all, Church encoding is not typed
> >> and it is not tight. The following article explains the other
> >> difference between the encodings
> >>
> >>         http://okmij.org/ftp/tagless-final/course/Boehm-Berarducci.html
> >>
> >> Boehm-Berarducci encoding is very insightful and influential. The
> >> authors truly deserve credit.
> >>
> >> P.S. It is actually possible to write zip function using
> Boehm-Berarducci
> >> encoding:
> >>         http://okmij.org/ftp/ftp/Algorithms.html#zip-folds
> >>
> >>
> >>
> >>
> >> _______________________________________________
> >> Haskell-Cafe mailing list
> >> Haskell-Cafe at haskell.org
> >> http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
> >
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From dan.doel at gmail.com  Wed Sep 19 05:39:51 2012
From: dan.doel at gmail.com (Dan Doel)
Date: Tue, 18 Sep 2012 23:39:51 -0400
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
In-Reply-To: 
References: <20120918082736.61798.qmail@www1.g3.pair.com>
	
	
	
Message-ID: 

On Tue, Sep 18, 2012 at 11:19 PM, Ryan Ingram  wrote:
> Fascinating!
>
> But it looks like you still 'cheat' in your induction principles...
>
> ?-induction : ?{A B} {P : A ? B ? Set}
>             ? ((x : A) ? (y : B) ? P (x , y))
>             ? (p : A ? B) ? P p
> ?-induction {A} {B} {P} f p rewrite sym (?-? p) = f (fst p) (snd p)
>
> Can you somehow define
>
> x-induction {A} {B} {P} f p = p (P p) f

No, or at least I don't know how.

The point is that with parametricity, I can prove that if p : A ? B,
then p = (fst p , snd p). Then when I need to prove P p, I change the
obligation to P (fst p , snd p). But i have (forall x y. P (x , y))
given.

I don't know why you think that's cheating. If you thought it was
going to be a straight-forward application of the Church (or some
other) encoding, that was the point of the first paper (that's
impossible). But parametricity can be used to prove statements _about_
the encodings that imply the induction principle.

> On Tue, Sep 18, 2012 at 4:09 PM, Dan Doel  wrote:
>>
>> This paper:
>>
>>     http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.26.957
>>
>> Induction is Not Derivable in Second Order Dependent Type Theory,
>> shows, well, that you can't encode naturals with a strong induction
>> principle in said theory. At all, no matter what tricks you try.
>>
>> However, A Logic for Parametric Polymorphism,
>>
>>     http://www.era.lib.ed.ac.uk/bitstream/1842/205/1/Par_Poly.pdf
>>
>> Indicates that in a type theory incorporating relational parametricity
>> of its own types,  the induction principle for the ordinary
>> Church-like encoding of natural numbers can be derived. I've done some
>> work here:
>>
>>     http://code.haskell.org/~dolio/agda-share/html/ParamInduction.html
>>
>> for some simpler types (although, I've been informed that sigma was
>> novel, it not being a Simple Type), but haven't figured out natural
>> numbers yet (I haven't actually studied the second paper above, which
>> I was pointed to recently).
>>
>> -- Dan
>>
>> On Tue, Sep 18, 2012 at 5:41 PM, Ryan Ingram  wrote:
>> > Oleg, do you have any references for the extension of lambda-encoding of
>> > data into dependently typed systems?
>> >
>> > In particular, consider Nat:
>> >
>> >     nat_elim :: forall P:(Nat -> *). P 0 -> (forall n:Nat. P n -> P
>> > (succ
>> > n)) -> (n:Nat) -> P n
>> >
>> > The naive lambda-encoding of 'nat' in the untyped lambda-calculus has
>> > exactly the correct form for passing to nat_elim:
>> >
>> >     nat_elim pZero pSucc n = n pZero pSucc
>> >
>> > with
>> >
>> >     zero :: Nat
>> >     zero pZero pSucc = pZero
>> >
>> >     succ :: Nat -> Nat
>> >     succ n pZero pSucc = pSucc (n pZero pSucc)
>> >
>> > But trying to encode the numerals this way leads to "Nat" referring to
>> > its
>> > value in its type!
>> >
>> >    type Nat = forall P:(Nat  -> *). P 0 -> (forall n:Nat. P n -> P (succ
>> > n))
>> > -> P ???
>> >
>> > Is there a way out of this quagmire?  Or are we stuck defining actual
>> > datatypes if we want dependent types?
>> >
>> >   -- ryan
>> >
>> >
>> >
>> > On Tue, Sep 18, 2012 at 1:27 AM,  wrote:
>> >>
>> >>
>> >> There has been a recent discussion of ``Church encoding'' of lists and
>> >> the comparison with Scott encoding.
>> >>
>> >> I'd like to point out that what is often called Church encoding is
>> >> actually Boehm-Berarducci encoding. That is, often seen
>> >>
>> >> > newtype ChurchList a =
>> >> >     CL { cataCL :: forall r. (a -> r -> r) -> r -> r }
>> >>
>> >> (in
>> >> http://community.haskell.org/%7Ewren/list-extras/Data/List/Church.hs )
>> >>
>> >> is _not_ Church encoding. First of all, Church encoding is not typed
>> >> and it is not tight. The following article explains the other
>> >> difference between the encodings
>> >>
>> >>         http://okmij.org/ftp/tagless-final/course/Boehm-Berarducci.html
>> >>
>> >> Boehm-Berarducci encoding is very insightful and influential. The
>> >> authors truly deserve credit.
>> >>
>> >> P.S. It is actually possible to write zip function using
>> >> Boehm-Berarducci
>> >> encoding:
>> >>         http://okmij.org/ftp/ftp/Algorithms.html#zip-folds
>> >>
>> >>
>> >>
>> >>
>> >> _______________________________________________
>> >> Haskell-Cafe mailing list
>> >> Haskell-Cafe at haskell.org
>> >> http://www.haskell.org/mailman/listinfo/haskell-cafe
>> >
>> >
>> >
>> > _______________________________________________
>> > Haskell-Cafe mailing list
>> > Haskell-Cafe at haskell.org
>> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>> >
>
>


From ryani.spam at gmail.com  Wed Sep 19 05:58:06 2012
From: ryani.spam at gmail.com (Ryan Ingram)
Date: Tue, 18 Sep 2012 20:58:06 -0700
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
In-Reply-To: 
References: <20120918082736.61798.qmail@www1.g3.pair.com>
	
	
	
	
Message-ID: 

On Tue, Sep 18, 2012 at 8:39 PM, Dan Doel  wrote:

> On Tue, Sep 18, 2012 at 11:19 PM, Ryan Ingram 
> wrote:
> > Fascinating!
> >
> > But it looks like you still 'cheat' in your induction principles...
> >
> > ?-induction : ?{A B} {P : A ? B ? Set}
> >             ? ((x : A) ? (y : B) ? P (x , y))
> >             ? (p : A ? B) ? P p
> > ?-induction {A} {B} {P} f p rewrite sym (?-? p) = f (fst p) (snd p)
> >
> > Can you somehow define
> >
> > x-induction {A} {B} {P} f p = p (P p) f
>
> No, or at least I don't know how.
>
> The point is that with parametricity, I can prove that if p : A ? B,
> then p = (fst p , snd p). Then when I need to prove P p, I change the
> obligation to P (fst p , snd p). But i have (forall x y. P (x , y))
> given.
>
> I don't know why you think that's cheating. If you thought it was
> going to be a straight-forward application of the Church (or some
> other) encoding, that was the point of the first paper (that's
> impossible). But parametricity can be used to prove statements _about_
> the encodings that imply the induction principle.
>

The line of logic I was thinking is that you could lift the parametricity
proof to the (proof-irrelevant) typelevel; that is, you rewrite the type of
f from

f :: (x : A) -> (y : B) -> P (x,y)

to

f :: A -> B -> P p

given that p = (x,y), to make f 'compatible' with p.  But I see the
trickiness, because if you allow yourself to do that, you no longer are
constrained to pass (fst p) and (snd p) to f, you could pass any objects of
type A and B.

Wait, can't you just use x-lemma1 to rewrite the rhs of x-induction?

?-lemma? : ?{A B R} ? (p : A ? B) (k : A ? B ? R)
         ? k (fst p) (snd p) ? p R k


x-lemma1 {A} {B} {P p} p f :: f (fst p) (snd p) = p (P p) f

Or is the problem that the "k" parameter to x-lemma1 isn't 'dependently
typed' enough?

  -- ryan



>
> > On Tue, Sep 18, 2012 at 4:09 PM, Dan Doel  wrote:
> >>
> >> This paper:
> >>
> >>     http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.26.957
> >>
> >> Induction is Not Derivable in Second Order Dependent Type Theory,
> >> shows, well, that you can't encode naturals with a strong induction
> >> principle in said theory. At all, no matter what tricks you try.
> >>
> >> However, A Logic for Parametric Polymorphism,
> >>
> >>     http://www.era.lib.ed.ac.uk/bitstream/1842/205/1/Par_Poly.pdf
> >>
> >> Indicates that in a type theory incorporating relational parametricity
> >> of its own types,  the induction principle for the ordinary
> >> Church-like encoding of natural numbers can be derived. I've done some
> >> work here:
> >>
> >>     http://code.haskell.org/~dolio/agda-share/html/ParamInduction.html
> >>
> >> for some simpler types (although, I've been informed that sigma was
> >> novel, it not being a Simple Type), but haven't figured out natural
> >> numbers yet (I haven't actually studied the second paper above, which
> >> I was pointed to recently).
> >>
> >> -- Dan
> >>
> >> On Tue, Sep 18, 2012 at 5:41 PM, Ryan Ingram 
> wrote:
> >> > Oleg, do you have any references for the extension of lambda-encoding
> of
> >> > data into dependently typed systems?
> >> >
> >> > In particular, consider Nat:
> >> >
> >> >     nat_elim :: forall P:(Nat -> *). P 0 -> (forall n:Nat. P n -> P
> >> > (succ
> >> > n)) -> (n:Nat) -> P n
> >> >
> >> > The naive lambda-encoding of 'nat' in the untyped lambda-calculus has
> >> > exactly the correct form for passing to nat_elim:
> >> >
> >> >     nat_elim pZero pSucc n = n pZero pSucc
> >> >
> >> > with
> >> >
> >> >     zero :: Nat
> >> >     zero pZero pSucc = pZero
> >> >
> >> >     succ :: Nat -> Nat
> >> >     succ n pZero pSucc = pSucc (n pZero pSucc)
> >> >
> >> > But trying to encode the numerals this way leads to "Nat" referring to
> >> > its
> >> > value in its type!
> >> >
> >> >    type Nat = forall P:(Nat  -> *). P 0 -> (forall n:Nat. P n -> P
> (succ
> >> > n))
> >> > -> P ???
> >> >
> >> > Is there a way out of this quagmire?  Or are we stuck defining actual
> >> > datatypes if we want dependent types?
> >> >
> >> >   -- ryan
> >> >
> >> >
> >> >
> >> > On Tue, Sep 18, 2012 at 1:27 AM,  wrote:
> >> >>
> >> >>
> >> >> There has been a recent discussion of ``Church encoding'' of lists
> and
> >> >> the comparison with Scott encoding.
> >> >>
> >> >> I'd like to point out that what is often called Church encoding is
> >> >> actually Boehm-Berarducci encoding. That is, often seen
> >> >>
> >> >> > newtype ChurchList a =
> >> >> >     CL { cataCL :: forall r. (a -> r -> r) -> r -> r }
> >> >>
> >> >> (in
> >> >> http://community.haskell.org/%7Ewren/list-extras/Data/List/Church.hs)
> >> >>
> >> >> is _not_ Church encoding. First of all, Church encoding is not typed
> >> >> and it is not tight. The following article explains the other
> >> >> difference between the encodings
> >> >>
> >> >>
> http://okmij.org/ftp/tagless-final/course/Boehm-Berarducci.html
> >> >>
> >> >> Boehm-Berarducci encoding is very insightful and influential. The
> >> >> authors truly deserve credit.
> >> >>
> >> >> P.S. It is actually possible to write zip function using
> >> >> Boehm-Berarducci
> >> >> encoding:
> >> >>         http://okmij.org/ftp/ftp/Algorithms.html#zip-folds
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> _______________________________________________
> >> >> Haskell-Cafe mailing list
> >> >> Haskell-Cafe at haskell.org
> >> >> http://www.haskell.org/mailman/listinfo/haskell-cafe
> >> >
> >> >
> >> >
> >> > _______________________________________________
> >> > Haskell-Cafe mailing list
> >> > Haskell-Cafe at haskell.org
> >> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From claude at mathr.co.uk  Wed Sep 19 10:14:44 2012
From: claude at mathr.co.uk (Claude Heiland-Allen)
Date: Wed, 19 Sep 2012 09:14:44 +0100
Subject: [Haskell-cafe] [Haskell] Well-Typed and Skills Matter offer
 Haskell courses in London in October
In-Reply-To: 
References: 
Message-ID: <50597EF4.3090904@mathr.co.uk>

On 19/09/12 08:52, Andres L?h wrote:
> Registration for all these events is open. I hope to see many
> of you there.

Is there an informal hangout without the ?225 price-tag

>
> Cheers,
>    Andres
>



From andres at well-typed.com  Wed Sep 19 10:20:58 2012
From: andres at well-typed.com (=?ISO-8859-1?Q?Andres_L=F6h?=)
Date: Wed, 19 Sep 2012 10:20:58 +0200
Subject: [Haskell-cafe] [Haskell] Well-Typed and Skills Matter offer
 Haskell courses in London in October
In-Reply-To: <50597EF4.3090904@mathr.co.uk>
References: 
	<50597EF4.3090904@mathr.co.uk>
Message-ID: 

> Is there an informal hangout without the ?225 price-tag

Certainly a great idea. I guess there's most likely some informal
meeting after the Haskell eXchange. Perhaps Neil Mitchell knows if
there are any concrete plans yet? He's been putting together the
program for the conference.

Cheers,
  Andres

-- 
Andres L?h, Haskell Consultant
Well-Typed LLP, http://www.well-typed.com


From claude at mathr.co.uk  Wed Sep 19 10:26:50 2012
From: claude at mathr.co.uk (Claude Heiland-Allen)
Date: Wed, 19 Sep 2012 09:26:50 +0100
Subject: [Haskell-cafe] [Haskell] Well-Typed and Skills Matter offer
 Haskell courses in London in October
In-Reply-To: <50597EF4.3090904@mathr.co.uk>
References: 
	<50597EF4.3090904@mathr.co.uk>
Message-ID: <505981CA.2010906@mathr.co.uk>

Hi list,

Oops, I hit send too prematurely, sorry for the seeming bluntness (but 
it is still a blunt message, can't apologize for that I suppose):

On 19/09/12 09:14, Claude Heiland-Allen wrote:
> On 19/09/12 08:52, Andres L?h wrote:
>> Registration for all these events is open. I hope to see many
>> of you there.

(Referring to the October 10th event:
http://skillsmatter.com/event/haskell/haskell-exchange-2012
)

> Is there an informal hangout without the ?225 price-tag
?

Perhaps a monthly informal gathering similarly (self-)organised to 
Dorkbot but focussed on Haskell (and other functional languages) is what 
I'm really after, but that still requires some organisation time and a 
venue, neither of which necessarily come cheap :(

So, I understand the need to charge, but it seems quite a high fee to me 
(especially as there don't seem to be concessions for unwaged / students 
/ etc).

>> Cheers,
>> Andres

Thanks, sorry if this caused offence.

Three cheers if it revives a democratic informal londonhug thing.


Claude


From andres at well-typed.com  Wed Sep 19 10:41:33 2012
From: andres at well-typed.com (=?ISO-8859-1?Q?Andres_L=F6h?=)
Date: Wed, 19 Sep 2012 10:41:33 +0200
Subject: [Haskell-cafe] [Haskell] Well-Typed and Skills Matter offer
 Haskell courses in London in October
In-Reply-To: <505981CA.2010906@mathr.co.uk>
References: 
	<50597EF4.3090904@mathr.co.uk> <505981CA.2010906@mathr.co.uk>
Message-ID: 

Hi.

> Oops, I hit send too prematurely, sorry for the seeming bluntness (but it is
> still a blunt message, can't apologize for that I suppose):

No need to apologize. There's a need for informal meetings as much (or
even more) as there is for courses and conferences.

> Perhaps a monthly informal gathering similarly (self-)organised to Dorkbot
> but focussed on Haskell (and other functional languages) is what I'm really
> after, but that still requires some organisation time and a venue, neither
> of which necessarily come cheap :(

There are several informal meetings on Haskell happening throughout
the world. I'm personally not living in the London area, but I
regularly attend the Munich Haskell meeting
(http://www.haskell-munich.de/). Regarding London, I know there's the
Haskell Hoodlums meetup (http://www.meetup.com/hoodlums/), and I think
there is or was a Haskell User Group as well, but it's currently
listed as "not active" on
http://www.haskell.org/haskellwiki/User_groups. Perhaps there's a
chance to bring it back to life?

Cheers,
  Andres

-- 
Andres L?h, Haskell Consultant
Well-Typed LLP, http://www.well-typed.com


From amy at nualeargais.ie  Wed Sep 19 11:15:22 2012
From: amy at nualeargais.ie (Amy de =?utf-8?b?QnVpdGzDqWly?=)
Date: Wed, 19 Sep 2012 09:15:22 +0000 (UTC)
Subject: [Haskell-cafe] ANNOUNCE: grid-2.0
Message-ID: 

I'm happy to announce a new major release of the grid package:

    http://hackage.haskell.org/package/grid
    https://github.com/mhwombat/grid/wiki (wiki)

WHAT'S NEW: 
The GridMap module provides ordered maps from tiles on a grid to values. This
module is a wrapper around Grid and Map, in order to combine the functionality
of grids and maps into a single type. This may be of interest to anyone
developing a game based on a grid.

ABOUT GRID:
Grid provides tools for working with regular arrangements of tiles, such as
might be used in a board game or self-organising map (SOM). Grid currently
supports triangular, square, and hexagonal tiles, with various 2D and toroidal
layouts. If you need a tile shape or layout that isn't currently provided,
please let me know. See Math.Geometry.Grid for an example of how to use the
package. Suggestions for improvement are welcome. 





From amy at nualeargais.ie  Wed Sep 19 11:26:30 2012
From: amy at nualeargais.ie (Amy de =?utf-8?b?QnVpdGzDqWly?=)
Date: Wed, 19 Sep 2012 09:26:30 +0000 (UTC)
Subject: [Haskell-cafe] ANNOUNCE: som-1.0
Message-ID: 

Do you have some data that you'd like to understand better? I'm happy to
announce a new package called som that may help:

    http://hackage.haskell.org/package/som
    https://github.com/mhwombat/som/wiki (wiki)

A Kohonen Self-organising Map (SOM) maps input patterns onto a regular grid
(usually two-dimensional) where each node in the grid is a model of the input
data, and does so using a method which ensures that any topological
relationships within the input data are also represented in the grid. This
implementation supports the use of non-numeric patterns.

In layman's terms, a SOM can be useful when you want to discover the underlying
structure of some data. I have a brief tutorial in the wiki, which I hope to
expand over the next few weeks.



From jason.dusek at gmail.com  Wed Sep 19 13:06:21 2012
From: jason.dusek at gmail.com (Jason Dusek)
Date: Wed, 19 Sep 2012 11:06:21 +0000
Subject: [Haskell-cafe] Partial statical linking
In-Reply-To: <0284E8E8-CEED-4E06-AAF0-788B8CA900D5@gmail.com>
References: 
	<1322726819-sup-1706@ezyang>
	<0284E8E8-CEED-4E06-AAF0-788B8CA900D5@gmail.com>
Message-ID: 

2011/12/1 Irene Knapp :
> The typical trick to force GHC to statically link a C library
> is to give the full path to the .a of it as one of the object
> files in the GHC invocation that does the final linking.  This
> means you don't need any -l or -L flags pertaining to that
> library.  Some libraries are very particular about the order
> you list them in when doing this, but I don't really
> understand the issues there.  You usually will also have to
> chase dependencies by hand and list them in the same fashion.

I recently tried using this method to create static binary; but
I was not able to get it to work. I thought I would revive this
old thread and see if anyone else has given it a shot.

What I attempted was building a binary with only some C libraries
statically linked, with this command line:

  # Build https://github.com/erudify/sssp on Ubunut 12.04
  ghc -outputdir ./tmp -v --make -O2 sssp.hs -o sssp.ubuntu \
    /usr/lib/x86_64-linux-gnu/libffi.a \
    /usr/lib/x86_64-linux-gnu/libgmp.a \
    /usr/lib/x86_64-linux-gnu/libz.a

However, this really made no difference. Running `ldd' on the
resulting binary reveals that libz and friends are still
dynamically linked:

  ldd sssp.ubuntu
          linux-vdso.so.1 =>  (0x00007fff94253000)
          libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f0ddfdbb000)
          libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007f0ddfb9e000)
          libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10
(0x00007f0ddf92f000)
          libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6
(0x00007f0ddf727000)
          libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0ddf42d000)
          librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f0ddf224000)
          libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0ddf020000)
          libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0ddec63000)
          /lib64/ld-linux-x86-64.so.2 (0x00007f0ddffdb000)

There is always -optl-static which, nowadays, results in a
truly static executable; but it leads to a lot of warnings, too.

--
Jason Dusek
pgp // solidsnack // C1EBC57DC55144F35460C8DF1FD4C6C1FED18A2B


From Christian.Maeder at dfki.de  Wed Sep 19 13:24:17 2012
From: Christian.Maeder at dfki.de (Christian Maeder)
Date: Wed, 19 Sep 2012 13:24:17 +0200
Subject: [Haskell-cafe] Partial statical linking
In-Reply-To: 
References: 
	<1322726819-sup-1706@ezyang>
	<0284E8E8-CEED-4E06-AAF0-788B8CA900D5@gmail.com>
	
Message-ID: <5059AB61.6010902@dfki.de>

Hi,

I usually just copy those .a files (that should be linked statically) 
into `ghc --print-libdir`.

HTH Christian

Am 19.09.2012 13:06, schrieb Jason Dusek:
> 2011/12/1 Irene Knapp :
>> The typical trick to force GHC to statically link a C library
>> is to give the full path to the .a of it as one of the object
>> files in the GHC invocation that does the final linking.  This
>> means you don't need any -l or -L flags pertaining to that
>> library.  Some libraries are very particular about the order
>> you list them in when doing this, but I don't really
>> understand the issues there.  You usually will also have to
>> chase dependencies by hand and list them in the same fashion.
>
> I recently tried using this method to create static binary; but
> I was not able to get it to work. I thought I would revive this
> old thread and see if anyone else has given it a shot.
>
> What I attempted was building a binary with only some C libraries
> statically linked, with this command line:
>
>    # Build https://github.com/erudify/sssp on Ubunut 12.04
>    ghc -outputdir ./tmp -v --make -O2 sssp.hs -o sssp.ubuntu \
>      /usr/lib/x86_64-linux-gnu/libffi.a \
>      /usr/lib/x86_64-linux-gnu/libgmp.a \
>      /usr/lib/x86_64-linux-gnu/libz.a
>
> However, this really made no difference. Running `ldd' on the
> resulting binary reveals that libz and friends are still
> dynamically linked:
>
>    ldd sssp.ubuntu
>            linux-vdso.so.1 =>  (0x00007fff94253000)
>            libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f0ddfdbb000)
>            libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
> (0x00007f0ddfb9e000)
>            libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10
> (0x00007f0ddf92f000)
>            libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6
> (0x00007f0ddf727000)
>            libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0ddf42d000)
>            librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f0ddf224000)
>            libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0ddf020000)
>            libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0ddec63000)
>            /lib64/ld-linux-x86-64.so.2 (0x00007f0ddffdb000)
>
> There is always -optl-static which, nowadays, results in a
> truly static executable; but it leads to a lot of warnings, too.
>
> --
> Jason Dusek
> pgp // solidsnack // C1EBC57DC55144F35460C8DF1FD4C6C1FED18A2B
>


From jason.dusek at gmail.com  Wed Sep 19 14:42:27 2012
From: jason.dusek at gmail.com (Jason Dusek)
Date: Wed, 19 Sep 2012 12:42:27 +0000
Subject: [Haskell-cafe] Partial statical linking
In-Reply-To: <5059AB61.6010902@dfki.de>
References: 
	<1322726819-sup-1706@ezyang>
	<0284E8E8-CEED-4E06-AAF0-788B8CA900D5@gmail.com>
	
	<5059AB61.6010902@dfki.de>
Message-ID: 

2012/9/19 Christian Maeder :
> I usually just copy those .a files (that should be linked statically) into
> `ghc --print-libdir`.

Wow, it worked! But this isn't the sort of change I'd to a user's
system that I'd like to encode in a Makefile...

--
Jason Dusek
pgp // solidsnack // C1EBC57DC55144F35460C8DF1FD4C6C1FED18A2B


From muranushi at gmail.com  Wed Sep 19 16:19:09 2012
From: muranushi at gmail.com (Takayuki Muranushi)
Date: Wed, 19 Sep 2012 23:19:09 +0900
Subject: [Haskell-cafe] An easy way to represent and modify graphs?
Message-ID: 

tl;dr: I would like to apply genetic algorithm to directed acyclic
graphs that represents arithmetic operations.

Thank you for hosts, speakers and all participants in ICFP2012. I had
chance to make a lot of questions (c.f. [prize.jpg]) and receive lots of
stimulating ideas.

I have been working on automated parallel code generation and
automated tuning for hydrodynamics
http://iopscience.iop.org/1749-4699/5/1/015003 ; one of my next target
is model acquisition in robotics:
http://creativemachines.cornell.edu/sites/default/files/moriguchi11.pdf
; both deal with computations represented in forms of directed acyclic
graphs c.f. [graph-1.png] [graph-2.png]. We would like to describe
them easily in Haskell, but also to mutate (add random changes) and
crossover (create a new graph by mixing other two graphs.) In my
previous work, I used Monad to generate graphs and used the Functional
Graph Library to explicitly modify the graphs. Now I have learned that
there are more elegant methods to describe the computations with
sharing. But are those method also enables easy editing of the graphs?
That's my question.

In [data-reify.hs] I tried Observed Sharing by Gill09. Apparently,
sharing is lost once we try to modify the graph.

$ runhaskell data-reify.hs
let [(1,GraphMul 2 2),(2,GraphAdd 3 3),(3,GraphMul 4 5),(5,GraphVar
"X"),(4,GraphVal 40)] in 1
let [(1,GraphMul 2 9),(9,GraphAdd 10 13),(13,GraphMul 14
15),(15,GraphVar "X"),...,(5,GraphVar "X"),(4,GraphVal 42)] in 1

In [GenericMain.hs] I tried PHOAS by Oliveria & Cook 2012.

$ runhaskell GenericMain.hs
Mu (
  a => Fork "Add"(Fork "Sub"(b) (Empty)) (c)
  b => Fork "Mul"(c) (c)
  c => Fork "40"(Empty) (Empty)
  d => Fork "X"(Empty) (Empty)
)
Mu (
  a => Fork "Add"(Fork "Sub"(b) (Empty)) (c)
  b => Fork "Mul"(c) (c)
  c => Fork "42"(Empty) (Empty)
  d => Fork "X"(Empty) (Empty)
)

This time, I can modify a node without loosing the sharing. How about
edges? Can you write operations such as "Choose one of the edges that
point to (c) and make it point to (d)" ?

Is there any good methods to describe and modify structures that has
sharing (if it helps, I don't need loops.)? Or, after all is the best way
explicit manipulation of the graph structure? Both information are
helpful to me.

Thanks in advance,
-- 
Takayuki MURANUSHI
The Hakubi Center for Advanced Research, Kyoto University
http://www.hakubi.kyoto-u.ac.jp/02_mem/h22/muranushi.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graph-1.png
Type: image/png
Size: 62878 bytes
Desc: not available
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graph-2.png
Type: image/png
Size: 22774 bytes
Desc: not available
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: prize.jpeg
Type: image/jpeg
Size: 53015 bytes
Desc: not available
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: data-reify.hs
Type: application/octet-stream
Size: 1388 bytes
Desc: not available
URL: 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GenericMain.hs
Type: application/octet-stream
Size: 7176 bytes
Desc: not available
URL: 

From allbery.b at gmail.com  Wed Sep 19 17:00:35 2012
From: allbery.b at gmail.com (Brandon Allbery)
Date: Wed, 19 Sep 2012 11:00:35 -0400
Subject: [Haskell-cafe] Partial statical linking
In-Reply-To: 
References: 
	<1322726819-sup-1706@ezyang>
	<0284E8E8-CEED-4E06-AAF0-788B8CA900D5@gmail.com>
	
Message-ID: 

On Wed, Sep 19, 2012 at 7:06 AM, Jason Dusek  wrote:

> What I attempted was building a binary with only some C libraries
> statically linked, with this command line:
>
>   # Build https://github.com/erudify/sssp on Ubunut 12.04
>   ghc -outputdir ./tmp -v --make -O2 sssp.hs -o sssp.ubuntu \
>     /usr/lib/x86_64-linux-gnu/libffi.a \
>     /usr/lib/x86_64-linux-gnu/libgmp.a \
>     /usr/lib/x86_64-linux-gnu/libz.a
>
> However, this really made no difference. Running `ldd' on the
> resulting binary reveals that libz and friends are still
> dynamically linked:
>

On Linux you probably need -optl--whole-archive for this to do anything;
alternately, you would need to get the final ld command line out of ghc and
insert the above libraries into it *after* the package .a files.

Putting them before the packages (including the GHC runtime) that need
them, as will happen by default, will cause them to be ignored because they
contain no required symbols *at that point* in the link.  --whole-archive
tells to blindly link the whole static archive in instead of ignoring it.

-- 
brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From sdiyazg at sjtu.edu.cn  Wed Sep 19 17:35:11 2012
From: sdiyazg at sjtu.edu.cn (sdiyazg at sjtu.edu.cn)
Date: Wed, 19 Sep 2012 23:35:11 +0800 (CST)
Subject: [Haskell-cafe] How to implement nested loops with tail recursion?
In-Reply-To: <1167387981.6327461.1348068388130.JavaMail.root@sjtu.edu.cn>
Message-ID: <2076988427.6331980.1348068911870.JavaMail.root@sjtu.edu.cn>

I need to implement fast two-level loops, and I am learning using seq to make calls tail-recursive.

I write programs to compute
  main = print $ sum [i*j|i::Int<-[1..20000],j::Int<-[1..20000]]
This program (compiled with -O2) runs twenty times slower than the unoptimized (otherwise the loop gets optimized out) C version.
But it seems to run in constant memory, so I assume that it has been turned into loops.

#include 
int main(){
	int s=0;
	for(int i=1;i<=20000;++i){
		for(int j=1;j<=20000;++j){
			s+=i*j;
		}
	}
	printf("%d\n",s);
	return 0;
}

Then I write

main = print $ f 1 where
	f i = let x = g 1 in x `seq` (x + if i<20000 then f (i+1) else 0) :: Int where
		g j = let x = i*j in x `seq` (x + if j<20000 then g (j+1) else 0) :: Int

This version runs out of memory. When I scale the numbers down to 10000, the program does run correctly, and takes lots of memory.
Even if I change the seqs into deepseqs, or use BangPatterns (f !i =... ; g !j = ...), the situation doesn't change.

A monadic version

import Control.Monad.ST.Strict
import Control.Monad
import Data.STRef.Strict

main = print $ runST $ do
	s <- newSTRef (0::Int)
	let g !i !j = 
		if (j<=10000) then modifySTRef s (+1)>>(g i (j+1)) else return ()
	let f !i = 
		if (i<=10000) then g i 1>>(f $ i+1) else return ()
	f 1 
	readSTRef s

also runs out of memory.

So how can I write a program that executes nested loops efficiently?


From clawsie at fastmail.fm  Wed Sep 19 18:06:57 2012
From: clawsie at fastmail.fm (brad clawsie)
Date: Wed, 19 Sep 2012 09:06:57 -0700
Subject: [Haskell-cafe] simple servers
Message-ID: 

Hi cafe

looking at

http://www.haskell.org/haskellwiki/Simple_Servers

The last two solutions compared are forkIO vs. explicit event support
(based on what was System.Event).

Further reading appears to indicate that event support has been
integrated into the runtime.

Is it true that writing a simple server using forkIO now integrates
native event loops implicitly? Or do I still need to create code that
explicitly uses (what is now) GHC.Event?

One last question. When writing C code, using epoll apis explicitly
can impose some blocking. Is the same to be said for GHC.Event?

I know all of the changes I am discussing seemed to happen in ghc more
than a year ago, sorry, I just can't find anything to explicitly guide
me here.

Thanks!
Brad


From sdiyazg at sjtu.edu.cn  Wed Sep 19 18:08:19 2012
From: sdiyazg at sjtu.edu.cn (sdiyazg at sjtu.edu.cn)
Date: Thu, 20 Sep 2012 00:08:19 +0800 (CST)
Subject: [Haskell-cafe] How to implement nested loops with tail
	recursion?
In-Reply-To: <2076988427.6331980.1348068911870.JavaMail.root@sjtu.edu.cn>
Message-ID: <986092442.6350786.1348070899407.JavaMail.root@sjtu.edu.cn>

Now I have discovered the right version...

main = print (f 1 0::Int) where
	f i s = (if i<=20000 then (f (i+1) (s + g 1 0)) else s) where
		g j s = (if j<=20000 then (g (j+1) (s + i*j)) else s)

----- ???? -----
???: sdiyazg at sjtu.edu.cn
???: haskell-cafe at haskell.org
????: ???, 2012? 9 ? 19? ?? 11:35:11
??: How to implement nested loops with tail recursion?

I need to implement fast two-level loops, and I am learning using seq to make calls tail-recursive.

I write programs to compute
  main = print $ sum [i*j|i::Int<-[1..20000],j::Int<-[1..20000]]
This program (compiled with -O2) runs twenty times slower than the unoptimized (otherwise the loop gets optimized out) C version.
But it seems to run in constant memory, so I assume that it has been turned into loops.

#include 
int main(){
	int s=0;
	for(int i=1;i<=20000;++i){
		for(int j=1;j<=20000;++j){
			s+=i*j;
		}
	}
	printf("%d\n",s);
	return 0;
}

Then I write

main = print $ f 1 where
	f i = let x = g 1 in x `seq` (x + if i<20000 then f (i+1) else 0) :: Int where
		g j = let x = i*j in x `seq` (x + if j<20000 then g (j+1) else 0) :: Int

This version runs out of memory. When I scale the numbers down to 10000, the program does run correctly, and takes lots of memory.
Even if I change the seqs into deepseqs, or use BangPatterns (f !i =... ; g !j = ...), the situation doesn't change.

A monadic version

import Control.Monad.ST.Strict
import Control.Monad
import Data.STRef.Strict

main = print $ runST $ do
	s <- newSTRef (0::Int)
	let g !i !j = 
		if (j<=10000) then modifySTRef s (+1)>>(g i (j+1)) else return ()
	let f !i = 
		if (i<=10000) then g i 1>>(f $ i+1) else return ()
	f 1 
	readSTRef s

also runs out of memory.

So how can I write a program that executes nested loops efficiently?


From sdiyazg at sjtu.edu.cn  Wed Sep 19 19:24:29 2012
From: sdiyazg at sjtu.edu.cn (sdiyazg at sjtu.edu.cn)
Date: Thu, 20 Sep 2012 01:24:29 +0800 (CST)
Subject: [Haskell-cafe] How to implement nested loops with tail
	recursion?
In-Reply-To: <986092442.6350786.1348070899407.JavaMail.root@sjtu.edu.cn>
Message-ID: <2036716484.6386405.1348075469951.JavaMail.root@sjtu.edu.cn>

A follow-up question.
I still haven't got the monadic version working, and the real use case involves IO actions.

I looked at http://www.haskell.org/haskellwiki/Recursion_in_a_monad and adapted the 'tail-recursive' snippet on the page into

main = do
	let 
		f 0 acc = return acc
		f n acc = do
		    v  <- return 1
		    f (n-1) (v+acc)
	f 1000000 100 >>= print

which still blows the memory. 

And so does this program

main = do
	s<-newIORef (0::Int)
	mapM_ (\i->modifyIORef s (+1)) [0..10000000]
	readIORef s>>=print

Why?

----- ???? -----
???: sdiyazg at sjtu.edu.cn
???: haskell-cafe at haskell.org
????: ???, 2012? 9 ? 20? ?? 12:08:19
??: Re: How to implement nested loops with tail recursion?

Now I have discovered the right version...

main = print (f 1 0::Int) where
	f i s = (if i<=20000 then (f (i+1) (s + g 1 0)) else s) where
		g j s = (if j<=20000 then (g (j+1) (s + i*j)) else s)

----- ???? -----
???: sdiyazg at sjtu.edu.cn
???: haskell-cafe at haskell.org
????: ???, 2012? 9 ? 19? ?? 11:35:11
??: How to implement nested loops with tail recursion?

I need to implement fast two-level loops, and I am learning using seq to make calls tail-recursive.

I write programs to compute
  main = print $ sum [i*j|i::Int<-[1..20000],j::Int<-[1..20000]]
This program (compiled with -O2) runs twenty times slower than the unoptimized (otherwise the loop gets optimized out) C version.
But it seems to run in constant memory, so I assume that it has been turned into loops.

#include 
int main(){
	int s=0;
	for(int i=1;i<=20000;++i){
		for(int j=1;j<=20000;++j){
			s+=i*j;
		}
	}
	printf("%d\n",s);
	return 0;
}

Then I write

main = print $ f 1 where
	f i = let x = g 1 in x `seq` (x + if i<20000 then f (i+1) else 0) :: Int where
		g j = let x = i*j in x `seq` (x + if j<20000 then g (j+1) else 0) :: Int

This version runs out of memory. When I scale the numbers down to 10000, the program does run correctly, and takes lots of memory.
Even if I change the seqs into deepseqs, or use BangPatterns (f !i =... ; g !j = ...), the situation doesn't change.

A monadic version

import Control.Monad.ST.Strict
import Control.Monad
import Data.STRef.Strict

main = print $ runST $ do
	s <- newSTRef (0::Int)
	let g !i !j = 
		if (j<=10000) then modifySTRef s (+1)>>(g i (j+1)) else return ()
	let f !i = 
		if (i<=10000) then g i 1>>(f $ i+1) else return ()
	f 1 
	readSTRef s

also runs out of memory.

So how can I write a program that executes nested loops efficiently?


From johan.tibell at gmail.com  Wed Sep 19 19:28:47 2012
From: johan.tibell at gmail.com (Johan Tibell)
Date: Wed, 19 Sep 2012 19:28:47 +0200
Subject: [Haskell-cafe] How to implement nested loops with tail
	recursion?
In-Reply-To: <2036716484.6386405.1348075469951.JavaMail.root@sjtu.edu.cn>
References: <986092442.6350786.1348070899407.JavaMail.root@sjtu.edu.cn>
	<2036716484.6386405.1348075469951.JavaMail.root@sjtu.edu.cn>
Message-ID: 

On Wed, Sep 19, 2012 at 7:24 PM,   wrote:
> main = do
>         let
>                 f 0 acc = return acc
>                 f n acc = do
>                     v  <- return 1
>                     f (n-1) (v+acc)
>         f 1000000 100 >>= print

Try this

main = do
        let
                f :: Int -> Int -> IO Int
                f 0 !acc = return acc  -- note strict accumulator
                f n acc = do
                    v  <- return 1
                    f (n-1) (v+acc)
        f 1000000 100 >>= print


From sdiyazg at sjtu.edu.cn  Wed Sep 19 20:00:44 2012
From: sdiyazg at sjtu.edu.cn (sdiyazg at sjtu.edu.cn)
Date: Thu, 20 Sep 2012 02:00:44 +0800 (CST)
Subject: [Haskell-cafe] How to implement nested loops with tail
 recursion?
In-Reply-To: 
Message-ID: <1842248288.6409226.1348077644754.JavaMail.root@sjtu.edu.cn>

So how do I force IO actions whose results are discarded (including IO ()) to be strict?

main = do
        s<-newIORef (1::Int)
        let
                f :: Int -> Int -> IO Int
                f 0 !acc = return acc  -- note strict accumulator
                f n !acc = do
                    v  <- modifyIORef s (+2) >>readIORef s -- reading immediately after writing
                    f (n-1) (v+acc)
        f 1000000 100 >>= print
        readIORef s>>=print

runs OK, while

main = do
        s<-newIORef (1::Int)
        let
                f :: Int -> Int -> IO Int
                f 0 !acc = return acc  -- note strict accumulator
                f n !acc = do
                    v  <- modifyIORef s (+2) >>return 1 
                    f (n-1) (v+acc)
        f 1000000 100 >>= print
        readIORef s>>=print

,

main = do
        s<-newIORef (1::Int)
        let
                f :: Int -> Int -> IO Int
                f 0 !acc = return acc  -- note strict accumulator
                f n !acc = do
                    v  <- modifyIORef s (+2) >>readIORef s>>return 1 
                    f (n-1) (v+acc)
        f 1000000 100 >>= print
        readIORef s>>=print

and

main = do
        s<-newIORef (1::Int)
        let
                f :: Int -> Int -> IO Int
                f 0 !acc = return acc  -- note strict accumulator
                f n !acc = do
                    v  <-  (>>return 1) $! (modifyIORef s (+2) >>readIORef s) 
                    f (n-1) (v+acc)
        f 1000000 100 >>= print
        readIORef s>>=print

all overflows after correctly printing the first number


----- ???? -----
???: "Johan Tibell" 
???: sdiyazg at sjtu.edu.cn
??: haskell-cafe at haskell.org
????: ???, 2012? 9 ? 20? ?? 1:28:47
??: Re: [Haskell-cafe] How to implement nested loops with tail recursion?

On Wed, Sep 19, 2012 at 7:24 PM,   wrote:
> main = do
>         let
>                 f 0 acc = return acc
>                 f n acc = do
>                     v  <- return 1
>                     f (n-1) (v+acc)
>         f 1000000 100 >>= print

Try this

main = do
        let
                f :: Int -> Int -> IO Int
                f 0 !acc = return acc  -- note strict accumulator
                f n acc = do
                    v  <- return 1
                    f (n-1) (v+acc)
        f 1000000 100 >>= print


From claude at mathr.co.uk  Wed Sep 19 20:13:42 2012
From: claude at mathr.co.uk (Claude Heiland-Allen)
Date: Wed, 19 Sep 2012 19:13:42 +0100
Subject: [Haskell-cafe] How to implement nested loops with tail
	recursion?
In-Reply-To: <1842248288.6409226.1348077644754.JavaMail.root@sjtu.edu.cn>
References: <1842248288.6409226.1348077644754.JavaMail.root@sjtu.edu.cn>
Message-ID: <505A0B56.9030901@mathr.co.uk>

Hi!

On 19/09/12 19:00, sdiyazg at sjtu.edu.cn wrote:
> So how do I force IO actions whose results are discarded (including IO ()) to be strict?

() <- foo :: IO () -- should work as it pattern matches, can wrap it in
a prettier combinator
!_ <- foo :: IO a -- could work with -XBangPatterns

I've not tested either (been away from Haskell for a while..), but see also:
http://markmail.org/message/i7eufihlhgq4jqt6
(regarding modifyIORef and leaky issues)

Claude
-- 
http://mathr.co.uk


From johan.tibell at gmail.com  Wed Sep 19 20:35:37 2012
From: johan.tibell at gmail.com (Johan Tibell)
Date: Wed, 19 Sep 2012 20:35:37 +0200
Subject: [Haskell-cafe] How to implement nested loops with tail
	recursion?
In-Reply-To: <1842248288.6409226.1348077644754.JavaMail.root@sjtu.edu.cn>
References: 
	<1842248288.6409226.1348077644754.JavaMail.root@sjtu.edu.cn>
Message-ID: 

On Wed, Sep 19, 2012 at 8:00 PM,   wrote:
> So how do I force IO actions whose results are discarded (including IO ()) to be strict?

In your particular case it looks like you want
Data.IORef.modifyIORef'. If your version of GHC doesn't include it you
can write it like so:

-- |Strict version of 'modifyIORef'
modifyIORef' :: IORef a -> (a -> a) -> IO ()
modifyIORef' ref f = do
    x <- readIORef ref
    let x' = f x
    x' `seq` writeIORef ref x'

-- Johan


From sjoerd at w3future.com  Wed Sep 19 23:19:25 2012
From: sjoerd at w3future.com (Sjoerd Visscher)
Date: Wed, 19 Sep 2012 23:19:25 +0200
Subject: [Haskell-cafe] ANNOUCE: one-liner-0,
	SYB-like generics with constraint kinds
Message-ID: <20B47B5C-A315-47F9-841A-02444C067888@w3future.com>

Hi all,

I am pleased to announce the first release of One-Liner, a package for writing short and concise generic instances of type classes. It works a bit like Scrap-Your-Boilerplate, but it uses the new constraint kinds instead of the Typeable class.

On hackage: http://hackage.haskell.org/package/one-liner-0
On github: https://github.com/sjoerdvisscher/one-liner

For example, this is how to write generic equality (using the All monoid):

  eqADT :: (ADT t, Constraints t Eq) => t -> t -> Bool
  eqADT s t = ctorIndex s == ctorIndex t &&
    getAll (mbuilds (For :: For Eq) (\fld -> All $ s ! fld == t ! fld) `at` s)

The code works like this: "Constraints t Eq" means it requires that all subcomponents of type t have an Eq instance, and then values s and t are equal if they are built by the same constructor and each subcomponent is equal.

The package is called One-Liner because the generic functions often end up as short as eqADT, especially if there's already an appropriate Monoid or Applicative functor available.

Here are two more examples, generic put and get for the Binary package (after adding the missing Monoid instance for Put)

  putADT :: (ADT t, Constraints t Binary) => t -> Put
  putADT t = putWord8 (toEnum (ctorIndex t)) >> gfoldMap (For :: For Binary) put

  getADT :: (ADT t, Constraints t Binary) => Get t
  getADT = do
    ix <- fromEnum <$> getWord8
    buildsA (For :: For Binary) (const get) !! ix

Finally, to give a complete sense of what's involved, here's an example data type and its ADT implementation:

  data T a = A Int a | B a (T a)
  
  instance ADT (T a) where

    ctorIndex A{} = 0
    ctorIndex B{} = 1

    type Constraints (T a) c = (c Int, c a, c (T a))

    buildsRecA For sub rec = 
      [ (ctor "A", A <$> sub (FieldInfo (\(A i _) -> i)) <*> sub (FieldInfo (\(A _ a) -> a)))
      , (ctor "B", B <$> sub (FieldInfo (\(B a _) -> a)) <*> rec (FieldInfo (\(B _ t) -> t)))
      ]

If you want to learn more, you can find an introductory blog post here:
https://github.com/sjoerdvisscher/blog/blob/master/2012/2012-09-06%20constraint-based%20generics.md

Some complete examples are here:
https://github.com/sjoerdvisscher/one-liner/tree/master/examples

Some more generic functions, including generic Show and Read:
https://github.com/sjoerdvisscher/one-liner/blob/master/src/Generics/OneLiner/Functions.hs

--
Sjoerd Visscher
https://github.com/sjoerdvisscher/blog







From mblazevic at stilo.com  Wed Sep 19 23:46:18 2012
From: mblazevic at stilo.com (=?UTF-8?B?TWFyaW8gQmxhxb5ldmnEhw==?=)
Date: Wed, 19 Sep 2012 17:46:18 -0400
Subject: [Haskell-cafe] [ANNOUNCE] Fmark markup language
In-Reply-To: <0D4FD146-FA8E-4E29-806A-F9D7E7CF22CB@cs.otago.ac.nz>
References: <5057E602.6040900@ist.utl.pt>
	
	<5057F134.8040304@ist.utl.pt>
	
	
	<0D4FD146-FA8E-4E29-806A-F9D7E7CF22CB@cs.otago.ac.nz>
Message-ID: <505A3D2A.4040107@stilo.com>

On 12-09-18 07:37 PM, Richard O'Keefe wrote:
>
> On 19/09/2012, at 1:43 AM, Stefan Monnier wrote:
>
>>> The problem with that is that some people DO end some headings with
>>> a full stop; for them your special syntax is not natural.
>>
>> Markdown/ReST is already using the "no syntax" idea (e.g. compared to
>> pre-wiki markup such a LaTeX or Texinfo), so he's simply trying to push
>> this idea further.
>
> Markdown is very heavy on syntax,
> what it is *light* on is specification of what the
> syntax actually is.  As a result,
> I'm aware of three different dialects,
> and someone told me about having to reverse
> engineer the syntax from a Perl implementation.
> As a further result, I cannot write a program to
> reliably *generate* Markdown.

	Very true. Sadly, this is the case with almost all other Wiki-like 
markup schemes out there. They are all implementation-specified. The 
only exception I'm aware of is Creole, for which an EBNF grammar exists, 
even if it's pretty nasty-looking. A look at that specification makes 
one appreciate how badly specified "natural" syntax is.

	In my opinion, there is no single natural syntax that can be imposed on 
ASCII strings and serve majority of uses. There are many different 
syntaxes that feel  natural for different uses and different users, and 
the best we can hope to achieve would be a way to provide a formal and 
readable specification for each of those syntaxes. I've been playing 
with one approach in this direction with the concrete-relaxng-parser 
package, but it's still early days.


>>
>> I suspect it'll be difficult.
>
> Oh, more power to him for trying.
> I just don't think it can be pushed very far.
>
> Oh, there is a really *filthy* hack that could be pulled
> for italics, bold face, and so on.  Contrary to its original
> principles, Unicode includes several copies of ASCII
> (see http://unicode.org/charts/PDF/U1D400.pdf):
> Mathematical bold,
> Mathematical italic,
> Mathematical bold italic,
> Mathematical script,
> Mathematical bold script,
> Mathematical fraktur,
> Mathematical double struck (blackboard-bold),
> Mathematical bold fraktur,
> Mathematical sans-serif,
> Mathematical sans-serif bold,
> Mathematical sans-serif italic,
> Mathematical sans-serif bold italic,
> Mathematical monospace,
> and some similar sets of Greek.

Thank you for sharing this hack. It's very amusing.




-- 
Mario Blazevic
mblazevic at stilo.com
Stilo International

This message, including any attachments, is for the sole use of the
intended recipient(s) and may contain confidential and privileged
information. Any unauthorized review, use, disclosure, copying, or
distribution is strictly prohibited. If you are not the intended
recipient(s) please contact the sender by reply email and destroy
all copies of the original message and any attachments.


From wren at freegeek.org  Thu Sep 20 01:32:25 2012
From: wren at freegeek.org (wren ng thornton)
Date: Wed, 19 Sep 2012 19:32:25 -0400
Subject: [Haskell-cafe] foldl vs. foldr
In-Reply-To: <201209181432.30668.jan.stolarek@p.lodz.pl>
References: <201209181432.30668.jan.stolarek@p.lodz.pl>
Message-ID: <505A5609.7040302@freegeek.org>

On 9/18/12 8:32 AM, Jan Stolarek wrote:
> Hi list,
>
> I have yet another question about folds. Reading here and there I encountered statements that
> foldr is more important than foldl, e.g. in this post on the list:
> http://www.haskell.org/pipermail/haskell-cafe/2012-May/101338.html
> I want to know are such statements correct and, if so, why? I am aware that foldl' can in some
> circumstances operate in constant space, while foldr can operate on infinite lists if the folding
> function is lazy in the second parameter. Is there more to this subject? Properties that I
> mentioned are more of technical nature, not theoretical ones. Are there any significant
> theoretical advantages of foldr? I read Bird's and Wadler's "Introduction to functional
> programming" and it seems to me that foldl and foldr have the same properties and in many cases
> are interchangeable.

The interchangeability typically arises from the (weak) isomorphism between:

     data CList a = CNil | Cons a (CList a)

     data SList a = SNil | Snoc (SList a) a

In particular, interchangeability will fail whenever the isomorphism 
fails--- namely, for infinite lists.


However, there is another issue at stake. The right fold is the natural 
catamorphism for CList, and we like catamorphisms because they capture 
the definability class of primitive recursive functions[1]. However, 
catamorphisms inherently capture a bottom-up style of recursion (even 
though they are evaluated top-down in a lazy language). There are times 
when we'd rather capture a top-down style of recursion--- which is 
exactly what left folds do[2]. Unfortunately, left folds have not been 
studied as extensively as right folds. So it's not entirely clear what 
their theoretical basis is, or how exactly their power relates to right 
folds.


[1] That is, every primitive recursive *function* can be defined with a 
catamorphism. However, do note that this may not be the most efficient 
*algorithm* for that function. Paramorphisms thus capture the class 
better, since they can capture more efficient algorithms than 
catamorphisms can. If you're familiar with the distinction between 
"iterators" (cata) and "recursors" (para), this is exactly the same thing.

[2] Just as paramorphisms capture algorithms that catamorphisms can't, 
left folds capture algorithms that right folds can't; e.g., some 
constant stack/space algorithms. Though, unlike cata vs para, left folds 
do not appear to be strictly more powerful. Right folds can capture 
algorithms that left folds (apparently) can't; e.g., folds over infinite 
structures. I say "apparently" because once you add scanl/r to the 
discussion instead of just foldl/r, things get a lot murkier.

-- 
Live well,
~wren


From wren at freegeek.org  Thu Sep 20 02:36:07 2012
From: wren at freegeek.org (wren ng thornton)
Date: Wed, 19 Sep 2012 20:36:07 -0400
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
In-Reply-To: <20120918082736.61798.qmail@www1.g3.pair.com>
References: <20120918082736.61798.qmail@www1.g3.pair.com>
Message-ID: <505A64F7.1000409@freegeek.org>

On 9/18/12 4:27 AM, oleg at okmij.org wrote:
> There has been a recent discussion of ``Church encoding'' of lists and
> the comparison with Scott encoding.
>
> I'd like to point out that what is often called Church encoding is
> actually Boehm-Berarducci encoding. That is, often seen
>
>> newtype ChurchList a =
>>      CL { cataCL :: forall r. (a -> r -> r) -> r -> r }
>
> (in http://community.haskell.org/%7Ewren/list-extras/Data/List/Church.hs )
>
> is _not_ Church encoding. First of all, Church encoding is not typed
> and it is not tight.

I know that Church encodings were explored in the untyped setting (and 
hence cannot be tight); but I was unaware of a citation for the typed 
version of the same encoding. I've since corrected the names of the 
above module.

N.B., for folks following along at home, the above module and the Scott 
version aren't actually in list-extras yet. I just dumped them there for 
lack of somewhere else to stash the code from last time this comparison 
came up.


> P.S. It is actually possible to write zip function using Boehm-Berarducci
> encoding:
> 	http://okmij.org/ftp/ftp/Algorithms.html#zip-folds

Of course it is; I just never got around to doing it :)

-- 
Live well,
~wren


From kazu at iij.ad.jp  Thu Sep 20 03:05:35 2012
From: kazu at iij.ad.jp (Kazu Yamamoto (=?iso-2022-jp?B?GyRCOzNLXE9CSScbKEI=?=))
Date: Thu, 20 Sep 2012 10:05:35 +0900 (JST)
Subject: [Haskell-cafe] simple servers
In-Reply-To: 
References: 
Message-ID: <20120920.100535.1077347467635688888.kazu@iij.ad.jp>

Hi,

> Is it true that writing a simple server using forkIO now integrates
> native event loops implicitly? 

Yes.

IO manager handles event driven stuff. Thanks to this, we can enjoy
(light) thread programming using forkIO.

> One last question. When writing C code, using epoll apis explicitly
> can impose some blocking. Is the same to be said for GHC.Event?

I don't understand your question.

All system calls issued from the network package use non-blocking.
You don't have to worry about blocking at all.

P.S.

This article would help:

	http://www.iij.ad.jp/en/company/development/tech/mighttpd/

--Kazu


From dan.doel at gmail.com  Thu Sep 20 03:24:37 2012
From: dan.doel at gmail.com (Dan Doel)
Date: Wed, 19 Sep 2012 21:24:37 -0400
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
In-Reply-To: <505A64F7.1000409@freegeek.org>
References: <20120918082736.61798.qmail@www1.g3.pair.com>
	<505A64F7.1000409@freegeek.org>
Message-ID: 

On Wed, Sep 19, 2012 at 8:36 PM, wren ng thornton  wrote:
>> P.S. It is actually possible to write zip function using Boehm-Berarducci
>> encoding:
>>         http://okmij.org/ftp/ftp/Algorithms.html#zip-folds
>
>
> Of course it is; I just never got around to doing it :)

If you do, you might want to consider not using the above method, as I
seem to recall it doing an undesirable amount of extra work (repeated
O(n) tail). One can do better with some controversial types (this is
not my idea originally; ski (don't know his real name) on freenode's
#haskell showed it to me a long time ago):

---- snip ----

{-# LANGUAGE PolymorphicComponents #-}

module ABC where

newtype L a = L { unL :: forall r. (a -> r -> r) -> r -> r }

nil :: L a
nil = L $ \_ z -> z

cons :: a -> L a -> L a
cons x (L xs) = L $ \f -> f x . xs f

newtype A a c = Roll { unroll :: (a -> A a c -> L c) -> L c }

type B a c = a -> A a c -> L c

zipWith :: (a -> b -> c) -> L a -> L b -> L c
zipWith f (L as) (L bs) = unroll (as consA nilA) (bs consB nilB)
 where
 -- nilA :: A a c
 nilA = Roll $ const nil

 -- consA :: a -> A a c -> A a c
 consA x xs = Roll $ \k -> k x xs

 -- nilB :: B a c
 nilB _ _ = nil

 -- consB :: b -> B a c -> B a c
 consB y ys x xs = f x y `cons` unroll xs ys

---- snip ----

This traverses each list only once.

-- Dan


From dstcruz at gmail.com  Thu Sep 20 03:36:14 2012
From: dstcruz at gmail.com (Daniel Santa Cruz)
Date: Wed, 19 Sep 2012 21:36:14 -0400
Subject: [Haskell-cafe] Haskell Weekly News: Issue 244
Message-ID: 

Welcome to issue 244 of the HWN, an issue covering crowd-sourced bits
of information about Haskell from around the web. This issue covers the
week of September 9 to September 15, 2012.

 Inbox

As you might have heard, GHC 7.6.1 is out for all platforms. I would
say "get it while it is still hot", but I guess I missed my opportunity
to do that last week.
[1] http://goo.gl/0fwDQ

Sonke Hahn wrote in to announce that on Monday "Story Episodes of
Nikki and the Robots" was was released.
[2] http://goo.gl/dBifT

Malcolm Wallace has uploaded videos from ICFP 2012, for those of us
that didn't have the opportunity to be there. Big thanks for sharing
these with the community!
[3] http://goo.gl/6ZhYV

 Quotes of the Week

   * copumpkin: when in doubt, blame ski

   * shachaf: You can call the greengrocer and place an order. That'll
     convert their unordered pears into ordered pears!

   * shachaf: Those who would give up essential type independence for a
     little temporary type safety deserve neither independence nor
     safety.

   * ddarius: edwardk: So your plan for Haskell adoption is to write
     Haskell in languages that aren't Haskell, say "Man, these languages
     suck, this would be super easy in Haskell", and then use the
     Haskell you started with reproducing functionality at an
     "unbelievable" rate.

   * cmccann: personally I'm just waiting for an extension that demotes
     types to the value level, so that we can finally have natural
     numbers.

 Top Reddit Stories

   * Yet another Haskell IDE in the works
     Domain: yesodweb.com, Score: 71, Comments: 94
     On Reddit: [4] http://goo.gl/N1nfs
     Original: [5] http://goo.gl/z47p8

   * The case of the mysterious explosion in space
     Domain: serpentine.com, Score: 65, Comments: 9
     On Reddit: [6] http://goo.gl/O782g
     Original: [7] http://goo.gl/eQxOc

   * Haskell vs. F# vs. Scala: A High-level Language Features and
Parallelism Support Comparison
     Domain: macs.hw.ac.uk, Score: 47, Comments: 30
     On Reddit: [8] http://goo.gl/XWdPX
     Original: [9] http://goo.gl/daRy2

   * The functor design pattern
     Domain: haskellforall.com, Score: 42, Comments: 45
     On Reddit: [10] http://goo.gl/FpJL4
     Original: [11] http://goo.gl/pZ4yu

   * How To Exclude Women From Your Technical Community: A Tutorial
     Domain: tim.dreamwidth.org, Score: 42, Comments: 309
     On Reddit: [12] http://goo.gl/iKN7H
     Original: [13] http://goo.gl/GKMjb

   * A simple library that allows logic programming in Haskell
     Domain: github.com, Score: 38, Comments: 10
     On Reddit: [14] http://goo.gl/J9Pbp
     Original: [15] http://goo.gl/1bRw5

   * Larry Wall: "You should probably know about it [Haskell] if only to be
able to say 'is this like Haskell?', and, if so, then you know you'll have
to hire some really smart people to program in it."
     Domain: youtube.com, Score: 34, Comments: 130
     On Reddit: [16] http://goo.gl/z1PTW
     Original: [17] http://goo.gl/5bCN9

   * Malcolm Wallace is broadcasting videos from ICFP
     Domain: m.youtube.com, Score: 33, Comments: 9
     On Reddit: [18] http://goo.gl/O6uuy
     Original: [19] http://goo.gl/Kyg5O

   * Darcs hub alpha: a darcsden fork to ?turn the dogfooding knobs up to
11?
     Domain: hub.darcs.net, Score: 30, Comments: 10
     On Reddit: [20] http://goo.gl/5D614
     Original: [21] http://goo.gl/pDHL9

   * The Architecture of the Mighttpd High-Speed Web Server
     Domain: iij.ad.jp, Score: 28, Comments: 4
     On Reddit: [22] http://goo.gl/7yRbw
     Original: [23] http://goo.gl/oCkBt

   * Tying the knot on a Rubik's cube
     Domain: self.haskell, Score: 25, Comments: 7
     On Reddit: [24] http://goo.gl/0XPiY
     Original: [25] http://goo.gl/0XPiY

   * Kazu Yamamoto: Improving the performance of Warp
     Domain: yesodweb.com, Score: 24, Comments: 1
     On Reddit: [26] http://goo.gl/yvRfR
     Original: [27] http://goo.gl/gEQlA

   * Taking advantage of "Theorems for Free"?
     Domain: self.haskell, Score: 20, Comments: 9
     On Reddit: [28] http://goo.gl/cqy6U
     Original: [29] http://goo.gl/cqy6U

 Top StackOverflow Questions

   * Is there a nice way to make function signatures more informative in
Haskell?
     votes: 37, answers: 6
     Read on SO: [30] http://goo.gl/vOY98

   * Purely functional data structures for text editors
     votes: 26, answers: 7
     Read on SO: [31] http://goo.gl/ciJQ3

   * Lazy Pattern matching in Data.List
     votes: 15, answers: 1
     Read on SO: [32] http://goo.gl/T2YPC

   * Can I provide the type-checker with proofs about inductive naturals in
GHC 7.6?
     votes: 14, answers: 1
     Read on SO: [33] http://goo.gl/zoMDr

   * Why does Haskell's ?flip id? has this type?
     votes: 12, answers: 1
     Read on SO: [34] http://goo.gl/HWuyZ

   * How long pauses can occur in a Haskell program due to garbage
collection?
     votes: 11, answers: 1
     Read on SO: [35] http://goo.gl/Stnq7

   * Good introduction to free theorems [closed]
     votes: 11, answers: 1
     Read on SO: [36] http://goo.gl/2OVYJ

   * Int vs Word in common use?
     votes: 10, answers: 3
     Read on SO: [37] http://goo.gl/JR9xK

   * Haskell collections with guaranteed worst-case bounds for every single
operation?
     votes: 9, answers: 1
     Read on SO: [38] http://goo.gl/Oc4L9

   * Zipper data structure for graphical model editor
     votes: 8, answers: 1
     Read on SO: [39] http://goo.gl/BF865

Until next time,
Daniel Santa Cruz

References

   1. http://comments.gmane.org/gmane.comp.lang.haskell.general/19477
   2. http://joyridelabs.de/blog/?p=1435
   3.
http://www.youtube.com/playlist?list=PL4UWOFngo5DV0sAM9qsfnPzNtRaDyZ7MD
   4. http://www.yesodweb.com/blog/2012/09/building-haskell-ide
   5.
http://www.reddit.com/r/haskell/comments/zrm9z/yet_another_haskell_ide_in_the_works/
   6.
http://www.serpentine.com/blog/2012/09/12/the-case-of-the-mysterious-explosion-in-space/
   7.
http://www.reddit.com/r/haskell/comments/zrxns/the_case_of_the_mysterious_explosion_in_space/
   8. http://www.macs.hw.ac.uk/~dsg/gph/papers/abstracts/fhpc12.html
   9.
http://www.reddit.com/r/haskell/comments/zxcks/haskell_vs_f_vs_scala_a_highlevel_language/
  10. http://www.haskellforall.com/2012/09/the-functor-design-pattern.html
  11.
http://www.reddit.com/r/haskell/comments/zxl49/the_functor_design_pattern/
  12. http://tim.dreamwidth.org/1762846.html
  13.
http://www.reddit.com/r/haskell/comments/zxmzv/how_to_exclude_women_from_your_technical/
  14. https://github.com/smichal/hs-logic
  15.
http://www.reddit.com/r/haskell/comments/zq1gb/a_simple_library_that_allows_logic_programming_in/
  16.
http://www.youtube.com/watch?v=LR8fQiskYII&feature=player_detailpage#t=169s
  17.
http://www.reddit.com/r/haskell/comments/zpff3/larry_wall_you_should_probably_know_about_it/
  18.
http://m.youtube.com/channel/UCP9g4dLR7xt6KzCYntNqYcw?&desktop_uri=%2Fchannel%2FUCP9g4dLR7xt6KzCYntNqYcw
  19.
http://www.reddit.com/r/haskell/comments/zsjag/malcolm_wallace_is_broadcasting_videos_from_icfp/
  20. http://hub.darcs.net/
  21.
http://www.reddit.com/r/haskell/comments/zx4th/darcs_hub_alpha_a_darcsden_fork_to_turn_the/
  22. http://www.iij.ad.jp/en/company/development/tech/mighttpd/
  23.
http://www.reddit.com/r/haskell/comments/zrydv/the_architecture_of_the_mighttpd_highspeed_web/
  24.
http://www.reddit.com/r/haskell/comments/znt85/tying_the_knot_on_a_rubiks_cube/
  25.
http://www.reddit.com/r/haskell/comments/znt85/tying_the_knot_on_a_rubiks_cube/
  26. http://www.yesodweb.com/blog/2012/09/improving-warp
  27.
http://www.reddit.com/r/haskell/comments/ztvu7/kazu_yamamoto_improving_the_performance_of_warp/
  28.
http://www.reddit.com/r/haskell/comments/zydcs/taking_advantage_of_theorems_for_free/
  29.
http://www.reddit.com/r/haskell/comments/zydcs/taking_advantage_of_theorems_for_free/
  30.
http://stackoverflow.com/questions/12416723/is-there-a-nice-way-to-make-function-signatures-more-informative-in-haskell
  31.
http://stackoverflow.com/questions/12358083/purely-functional-data-structures-for-text-editors
  32.
http://stackoverflow.com/questions/12429449/lazy-pattern-matching-in-data-list
  33.
http://stackoverflow.com/questions/12442858/can-i-provide-the-type-checker-with-proofs-about-inductive-naturals-in-ghc-7-6
  34.
http://stackoverflow.com/questions/12339822/why-does-haskells-flip-id-has-this-type
  35.
http://stackoverflow.com/questions/12404031/how-long-pauses-can-occur-in-a-haskell-program-due-to-garbage-collection
  36.
http://stackoverflow.com/questions/12421085/good-introduction-to-free-theorems
  37. http://stackoverflow.com/questions/12432154/int-vs-word-in-common-use
  38.
http://stackoverflow.com/questions/12393104/haskell-collections-with-guaranteed-worst-case-bounds-for-every-single-operation
  39.
http://stackoverflow.com/questions/12339805/zipper-data-structure-for-graphical-model-editor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From strake888 at gmail.com  Thu Sep 20 04:37:34 2012
From: strake888 at gmail.com (Strake)
Date: Wed, 19 Sep 2012 21:37:34 -0500
Subject: [Haskell-cafe] An easy way to represent and modify graphs?
In-Reply-To: 
References: 
Message-ID: 

Pointers.

Seriously.

In Haskell one could use STRef rather than the cumbersome Foreign.Ptr,
though STRef too can be kludgy.

I know not whether safe, pure, immutable pointers would be possible in
Haskell, but in my experience STRef can work well enough.

Cheers,
Strake


From es at ertes.de  Thu Sep 20 04:58:57 2012
From: es at ertes.de (Ertugrul =?UTF-8?B?U8O2eWxlbWV6?=)
Date: Thu, 20 Sep 2012 04:58:57 +0200
Subject: [Haskell-cafe] simple servers
References: 
	<20120920.100535.1077347467635688888.kazu@iij.ad.jp>
Message-ID: <20120920045857.12408752@tritium.streitmacht.eu>

Kazu Yamamoto (????)  wrote:

> > One last question. When writing C code, using epoll apis explicitly
> > can impose some blocking. Is the same to be said for GHC.Event?
>
> I don't understand your question.
>
> All system calls issued from the network package use non-blocking.
> You don't have to worry about blocking at all.

Almost.  Especially when interfacing with C code you should include the
"-threaded" option to GHC to link against the multi-threaded run-time
system.  Otherwise your Haskell code will block your C code and
vice-versa.  Also some concurrency features don't work properly in the
single-threaded run-time.


Greets,
Ertugrul

-- 
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: 

From kazu at iij.ad.jp  Thu Sep 20 05:24:10 2012
From: kazu at iij.ad.jp (Kazu Yamamoto (=?iso-2022-jp?B?GyRCOzNLXE9CSScbKEI=?=))
Date: Thu, 20 Sep 2012 12:24:10 +0900 (JST)
Subject: [Haskell-cafe] simple servers
In-Reply-To: <20120920045857.12408752@tritium.streitmacht.eu>
References: 
	<20120920.100535.1077347467635688888.kazu@iij.ad.jp>
	<20120920045857.12408752@tritium.streitmacht.eu>
Message-ID: <20120920.122410.1721442311047037312.kazu@iij.ad.jp>

>> All system calls issued from the network package use non-blocking.
>> You don't have to worry about blocking at all.
> 
> Almost.  Especially when interfacing with C code you should include the
> "-threaded" option to GHC to link against the multi-threaded run-time
> system.  Otherwise your Haskell code will block your C code and
> vice-versa.  Also some concurrency features don't work properly in the
> single-threaded run-time.

Non-threaded RTS would block FFI to C code. But it does not block file
descriptors and sockets because the scheduler uses select(). To my
experience, *simple* network programming with non-threaded RTS also
works well except the case where we reach the limit of file
descriptors for the process.

Anyway, I recommend to specify the "-threaded" option to GHC for
network programming if you don't have special reasons.

--Kazu


From oleg at okmij.org  Thu Sep 20 10:15:38 2012
From: oleg at okmij.org (oleg at okmij.org)
Date: 20 Sep 2012 08:15:38 -0000
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
Message-ID: <20120920081538.8054.qmail@www1.g3.pair.com>


Dan Doel wrote:
> >> P.S. It is actually possible to write zip function using Boehm-Berarducci
> >> encoding:
> >>         http://okmij.org/ftp/Algorithms.html#zip-folds
>
> If you do, you might want to consider not using the above method, as I
> seem to recall it doing an undesirable amount of extra work (repeated
> O(n) tail). 
It is correct. The Boehm-Berarducci web page discusses at some extent
the general inefficiency of the encoding, the need for repeated
reflections and reifications for some (but not all) operations. That
is why arithmetic on Church numerals is generally a bad idea.

A much better encoding of numerals is what I call P-numerals
	http://okmij.org/ftp/Computation/lambda-calc.html#p-numerals
It turns out, I have re-discovered them after Michel Parigot (so my
name P-numerals is actually meaningful). Not only they are faster; one
can _syntactically_ prove that PRED . SUCC is the identity.

The general idea of course is Goedel's recursor R.

   R b a 0 = a
   R b a (Succ n) = b n (R b a n)

which easily generalizes to lists. The enclosed code shows the list
encoding that has constant-time cons, head, tail and trivially
expressible fold and zip.


Kim-Ee Yeoh wrote:
> So properly speaking, tail and pred for Church-encoded lists and nats
> are trial-and-error affairs. But the point is they need not be if we
> use B-B encoding, which looks _exactly_ the same, except one gets a
> citation link to a systematic procedure.
>
> So it looks like you're trying to set the record straight on who actually
> did what.

Exactly. Incidentally, there is more than one way to build a
predecessor of Church numerals. Kleene's solution is not the only
one. Many years ago I was thinking on this problem and designed a
different predecessor:

excerpted from http://okmij.org/ftp/Haskell/LC_neg.lhs


    One ad hoc way of defining a predecessor of a positive numeral
		    predp cn+1 ==> cn
    is to represent "predp cn" as "cn f v"
    where f and v are so chosen that (f z) acts as
	    if z == v then c0 else (succ z)
    We know that z can be either a numeral cn or a special value v. All
    Church numerals have a property that (cn combI) is combI: the identity
    combinator is a fixpoint of every numeral. Therefore, ((cn combI) (succ
    cn)) reduces to (succ cn). We only need to choose the value v in such
    a way that ((v I) (succ v)) yields c0.

    > predp = eval $
    >   c ^ c 
    >        # (z ^ (z # combI # (succ # z)))       -- function f(z)
    >        # (a ^ x ^ c0)                         -- value v


{-# LANGUAGE Rank2Types #-}

-- List represented with R

newtype R x = R{unR :: forall w.
  -- b
  (x -> R x -> w -> w)
  -- a
  -> w
  -- result
  -> w}

nil :: R x
nil = R (\b a -> a)

-- constant type
cons :: x -> R x -> R x
cons x r = R(\b a -> b x r (unR r b a))

-- constant time
rhead :: R x -> x
rhead (R fr) = fr (\x _ _ -> x) (error "head of the empty list")

-- constant time
rtail :: R x -> R x
rtail (R fr) = fr (\_ r _ -> r) (error "tail of the empty list")

-- fold
rfold :: (x -> w -> w) -> w -> R x -> w
rfold f z (R fr) = fr (\x _ w -> f x w) z

-- zip is expressed via fold
rzipWith :: (x -> y -> z) -> R x -> R y -> R z
rzipWith f r1 r2 =  rfold f' z r1 r2
 where f' x tD = \r2 -> cons (f x (rhead r2)) (tD (rtail r2))
       z       = \_  -> nil

-- tests

toR :: [a] -> R a
toR = foldr cons nil

toL :: R a -> [a]
toL = rfold (:) []


l1 = toR [1..10]
l2 = toR "abcde"


t1 = toL $ rtail l2
-- "bcde"

t2 = toL $ rzipWith (,) l2 l1
-- [('a',1),('b',2),('c',3),('d',4),('e',5)]




From mail at sebfisch.de  Thu Sep 20 21:00:41 2012
From: mail at sebfisch.de (Sebastian Fischer)
Date: Thu, 20 Sep 2012 21:00:41 +0200
Subject: [Haskell-cafe] [Snap] Argument Substitution in Heist Templates with
	Splices
Message-ID: 

Hello,

the following program demonstrates that arguments in Heist templates
are sometimes not substituted in presence of splices:

{-# LANGUAGE OverloadedStrings #-}

import           Blaze.ByteString.Builder (toByteString)
import qualified Data.ByteString.Char8    as BS
import           Data.Functor             ((<$>))
import           Data.Maybe               (fromJust)
import           Text.Templating.Heist

-- just return input node unchanged
testSplice :: Splice IO
testSplice = (:[]) <$> getParamNode

main = do
    writeFile "test.tpl" ""
    state <- either error id <$> loadTemplates "." defaultHeistState

    (builder,_) <- fromJust <$> renderWithArgs [("arg","42")] state "test"
    BS.putStrLn $ toByteString builder
    -- 4242

    let state' = bindSplices [("test",testSplice)] state
    (builder',_) <- fromJust <$> renderWithArgs [("arg","42")] state' "test"
    BS.putStrLn $ toByteString builder'
    -- 42

Without using splices, all occurrences of 'arg' in the template are
substituted. When using a splice, 'arg' is not substituted underneath
the input node of the splice. It is substituted in an attribute of the
input node.

Is this intentional? How can I ensure substitution also underneath the
input node?

Best,
Sebastian


From jays at panix.com  Thu Sep 20 21:54:53 2012
From: jays at panix.com (Jay Sulzberger)
Date: Thu, 20 Sep 2012 15:54:53 -0400 (EDT)
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
In-Reply-To: <20120920081538.8054.qmail@www1.g3.pair.com>
References: <20120920081538.8054.qmail@www1.g3.pair.com>
Message-ID: 



On Thu, 20 Sep 2012, oleg at okmij.org wrote:

>
> Dan Doel wrote:
>>>> P.S. It is actually possible to write zip function using Boehm-Berarducci
>>>> encoding:
>>>>         http://okmij.org/ftp/Algorithms.html#zip-folds
>>
>> If you do, you might want to consider not using the above method, as I
>> seem to recall it doing an undesirable amount of extra work (repeated
>> O(n) tail).
> It is correct. The Boehm-Berarducci web page discusses at some extent
> the general inefficiency of the encoding, the need for repeated
> reflections and reifications for some (but not all) operations. That
> is why arithmetic on Church numerals is generally a bad idea.
>
> A much better encoding of numerals is what I call P-numerals
> 	http://okmij.org/ftp/Computation/lambda-calc.html#p-numerals
> It turns out, I have re-discovered them after Michel Parigot (so my
> name P-numerals is actually meaningful). Not only they are faster; one
> can _syntactically_ prove that PRED . SUCC is the identity.

What is the setup that, here, gives the distinction between a
syntactic proof and some other kind of proof?

oo--JS.


>
> The general idea of course is Goedel's recursor R.
>
>   R b a 0 = a
>   R b a (Succ n) = b n (R b a n)
>
> which easily generalizes to lists. The enclosed code shows the list
> encoding that has constant-time cons, head, tail and trivially
> expressible fold and zip.
>
>
> Kim-Ee Yeoh wrote:
>> So properly speaking, tail and pred for Church-encoded lists and nats
>> are trial-and-error affairs. But the point is they need not be if we
>> use B-B encoding, which looks _exactly_ the same, except one gets a
>> citation link to a systematic procedure.
>>
>> So it looks like you're trying to set the record straight on who actually
>> did what.
>
> Exactly. Incidentally, there is more than one way to build a
> predecessor of Church numerals. Kleene's solution is not the only
> one. Many years ago I was thinking on this problem and designed a
> different predecessor:
>
> excerpted from http://okmij.org/ftp/Haskell/LC_neg.lhs
>
>
>    One ad hoc way of defining a predecessor of a positive numeral
> 		    predp cn+1 ==> cn
>    is to represent "predp cn" as "cn f v"
>    where f and v are so chosen that (f z) acts as
> 	    if z == v then c0 else (succ z)
>    We know that z can be either a numeral cn or a special value v. All
>    Church numerals have a property that (cn combI) is combI: the identity
>    combinator is a fixpoint of every numeral. Therefore, ((cn combI) (succ
>    cn)) reduces to (succ cn). We only need to choose the value v in such
>    a way that ((v I) (succ v)) yields c0.
>
>    > predp = eval $
>    >   c ^ c
>    >        # (z ^ (z # combI # (succ # z)))       -- function f(z)
>    >        # (a ^ x ^ c0)                         -- value v
>
>
> {-# LANGUAGE Rank2Types #-}
>
> -- List represented with R
>
> newtype R x = R{unR :: forall w.
>  -- b
>  (x -> R x -> w -> w)
>  -- a
>  -> w
>  -- result
>  -> w}
>
> nil :: R x
> nil = R (\b a -> a)
>
> -- constant type
> cons :: x -> R x -> R x
> cons x r = R(\b a -> b x r (unR r b a))
>
> -- constant time
> rhead :: R x -> x
> rhead (R fr) = fr (\x _ _ -> x) (error "head of the empty list")
>
> -- constant time
> rtail :: R x -> R x
> rtail (R fr) = fr (\_ r _ -> r) (error "tail of the empty list")
>
> -- fold
> rfold :: (x -> w -> w) -> w -> R x -> w
> rfold f z (R fr) = fr (\x _ w -> f x w) z
>
> -- zip is expressed via fold
> rzipWith :: (x -> y -> z) -> R x -> R y -> R z
> rzipWith f r1 r2 =  rfold f' z r1 r2
> where f' x tD = \r2 -> cons (f x (rhead r2)) (tD (rtail r2))
>       z       = \_  -> nil
>
> -- tests
>
> toR :: [a] -> R a
> toR = foldr cons nil
>
> toL :: R a -> [a]
> toL = rfold (:) []
>
>
> l1 = toR [1..10]
> l2 = toR "abcde"
>
>
> t1 = toL $ rtail l2
> -- "bcde"
>
> t2 = toL $ rzipWith (,) l2 l1
> -- [('a',1),('b',2),('c',3),('d',4),('e',5)]
>


From jays at panix.com  Thu Sep 20 22:00:26 2012
From: jays at panix.com (Jay Sulzberger)
Date: Thu, 20 Sep 2012 16:00:26 -0400 (EDT)
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
In-Reply-To: 
References: <20120920081538.8054.qmail@www1.g3.pair.com>
	
Message-ID: 



On Thu, 20 Sep 2012, Jay Sulzberger wrote:

>
>
> On Thu, 20 Sep 2012, oleg at okmij.org wrote:
>
>> 
>> Dan Doel wrote:
>>>>> P.S. It is actually possible to write zip function using 
>>>>> Boehm-Berarducci
>>>>> encoding:
>>>>>         http://okmij.org/ftp/Algorithms.html#zip-folds
>>> 
>>> If you do, you might want to consider not using the above method, as I
>>> seem to recall it doing an undesirable amount of extra work (repeated
>>> O(n) tail).
>> It is correct. The Boehm-Berarducci web page discusses at some extent
>> the general inefficiency of the encoding, the need for repeated
>> reflections and reifications for some (but not all) operations. That
>> is why arithmetic on Church numerals is generally a bad idea.
>> 
>> A much better encoding of numerals is what I call P-numerals
>> 	http://okmij.org/ftp/Computation/lambda-calc.html#p-numerals
>> It turns out, I have re-discovered them after Michel Parigot (so my
>> name P-numerals is actually meaningful). Not only they are faster; one
>> can _syntactically_ prove that PRED . SUCC is the identity.
>
> What is the setup that, here, gives the distinction between a
> syntactic proof and some other kind of proof?
>
> oo--JS.

Ah, I have just read the for-any vs for-all part of

   http://okmij.org/ftp/Computation/lambda-calc.html#p-numerals

and I think I understand something.

oo--JS.


>
>
>> 
>> The general idea of course is Goedel's recursor R.
>>
>>   R b a 0 = a
>>   R b a (Succ n) = b n (R b a n)
>> 
>> which easily generalizes to lists. The enclosed code shows the list
>> encoding that has constant-time cons, head, tail and trivially
>> expressible fold and zip.
>> 
>> 
>> Kim-Ee Yeoh wrote:
>>> So properly speaking, tail and pred for Church-encoded lists and nats
>>> are trial-and-error affairs. But the point is they need not be if we
>>> use B-B encoding, which looks _exactly_ the same, except one gets a
>>> citation link to a systematic procedure.
>>> 
>>> So it looks like you're trying to set the record straight on who actually
>>> did what.
>> 
>> Exactly. Incidentally, there is more than one way to build a
>> predecessor of Church numerals. Kleene's solution is not the only
>> one. Many years ago I was thinking on this problem and designed a
>> different predecessor:
>> 
>> excerpted from http://okmij.org/ftp/Haskell/LC_neg.lhs
>> 
>>
>>    One ad hoc way of defining a predecessor of a positive numeral
>> 		    predp cn+1 ==> cn
>>    is to represent "predp cn" as "cn f v"
>>    where f and v are so chosen that (f z) acts as
>> 	    if z == v then c0 else (succ z)
>>    We know that z can be either a numeral cn or a special value v. All
>>    Church numerals have a property that (cn combI) is combI: the identity
>>    combinator is a fixpoint of every numeral. Therefore, ((cn combI) (succ
>>    cn)) reduces to (succ cn). We only need to choose the value v in such
>>    a way that ((v I) (succ v)) yields c0.
>>
>>    > predp = eval $
>>    >   c ^ c
>>    >        # (z ^ (z # combI # (succ # z)))       -- function f(z)
>>    >        # (a ^ x ^ c0)                         -- value v
>> 
>> 
>> {-# LANGUAGE Rank2Types #-}
>> 
>> -- List represented with R
>> 
>> newtype R x = R{unR :: forall w.
>>  -- b
>>  (x -> R x -> w -> w)
>>  -- a
>>  -> w
>>  -- result
>>  -> w}
>> 
>> nil :: R x
>> nil = R (\b a -> a)
>> 
>> -- constant type
>> cons :: x -> R x -> R x
>> cons x r = R(\b a -> b x r (unR r b a))
>> 
>> -- constant time
>> rhead :: R x -> x
>> rhead (R fr) = fr (\x _ _ -> x) (error "head of the empty list")
>> 
>> -- constant time
>> rtail :: R x -> R x
>> rtail (R fr) = fr (\_ r _ -> r) (error "tail of the empty list")
>> 
>> -- fold
>> rfold :: (x -> w -> w) -> w -> R x -> w
>> rfold f z (R fr) = fr (\x _ w -> f x w) z
>> 
>> -- zip is expressed via fold
>> rzipWith :: (x -> y -> z) -> R x -> R y -> R z
>> rzipWith f r1 r2 =  rfold f' z r1 r2
>> where f' x tD = \r2 -> cons (f x (rhead r2)) (tD (rtail r2))
>>       z       = \_  -> nil
>> 
>> -- tests
>> 
>> toR :: [a] -> R a
>> toR = foldr cons nil
>> 
>> toL :: R a -> [a]
>> toL = rfold (:) []
>> 
>> 
>> l1 = toR [1..10]
>> l2 = toR "abcde"
>> 
>> 
>> t1 = toL $ rtail l2
>> -- "bcde"
>> 
>> t2 = toL $ rzipWith (,) l2 l1
>> -- [('a',1),('b',2),('c',3),('d',4),('e',5)]
>> 
>
>


From kazu at iij.ad.jp  Fri Sep 21 03:29:22 2012
From: kazu at iij.ad.jp (Kazu Yamamoto (=?iso-2022-jp?B?GyRCOzNLXE9CSScbKEI=?=))
Date: Fri, 21 Sep 2012 10:29:22 +0900 (JST)
Subject: [Haskell-cafe] simple servers
In-Reply-To: <20120920.122410.1721442311047037312.kazu@iij.ad.jp>
References: <20120920.100535.1077347467635688888.kazu@iij.ad.jp>
	<20120920045857.12408752@tritium.streitmacht.eu>
	<20120920.122410.1721442311047037312.kazu@iij.ad.jp>
Message-ID: <20120921.102922.1937706388715859778.kazu@iij.ad.jp>

Hello,

> Non-threaded RTS would block FFI to C code. But it does not block file
> descriptors and sockets because the scheduler uses select(). To my
> experience, *simple* network programming with non-threaded RTS also
> works well except the case where we reach the limit of file
> descriptors for the process.

I need to correct the last sentence. It should be "we reach the limit
of select(), 1,024 file descriptors".

--Kazu


From ddssff at gmail.com  Fri Sep 21 07:30:52 2012
From: ddssff at gmail.com (David Fox)
Date: Thu, 20 Sep 2012 22:30:52 -0700
Subject: [Haskell-cafe] ANNOUNCE: uuid-1.2.6
In-Reply-To: 
References: 
Message-ID: 

I was wondering about this:

  -- My goal with this instance was to make it work just enough to do what
  -- I want when used with the HStringTemplate library.
  instance Data UUID where
      toConstr uu  = mkConstr uuidType (show uu) [] (error "fixity")
      gunfold _ _  = error "gunfold"
      dataTypeOf _ = uuidType

Is there any reason not to just say "deriving Data" in the type declaration?

On Wed, Jun 13, 2012 at 8:59 PM, Antoine Latter  wrote:

> Hi folks,
>
> I'm happy to announce a new point release of the uuid library, 1.2.6:
>
> http://hackage.haskell.org/package/uuid-1.2.6
>
> The 'uuid' package implements most of RFC 4122[1] including random
> generation and generation based on hardware MAC addresses.
>
> I haven't announced a point-release in a while. The changes since 1.2.1
> include:
>
> * When generating UUIDs from the hardware MAC address, if the MAC
> address is not available we now use a random seed for our (hidden,
> global) state machine
>
> * The 'Read' instance now drops leading spaces
>
> * Added the functions 'toWords' and 'fromWords', primary to support
> the package uuid-quasi[2].
>
> Take care,
> Antoine
>
> 1: http://tools.ietf.org/html/rfc4122
> 2: http://hackage.haskell.org/package/uuid-quasi
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From bo at ct.de  Fri Sep 21 08:29:07 2012
From: bo at ct.de (=?ISO-8859-15?Q?Harald_B=F6geholz?=)
Date: Fri, 21 Sep 2012 08:29:07 +0200
Subject: [Haskell-cafe] progress reporting in a backtracking algorithm
Message-ID: <505C0933.2090604@ct.de>

Dear Haskell Cafe,


I am playing around with a backtracking algorithm that can take quite a
while to compute all solutions to a problem.

I'd like to use Debug.Trace.trace to provisionally output something that
lets me estimate the total time it might take. But I just can't wrap my
head around it.

This is how I think I'd write it in a C-like language:

backtrack(int level, double position, double stepsize, misc...)
{
   // with variations = number of variations to try on this level
   double part = stepsize / variations // split time on this level

   for (i=0; i Index -> [State]

that on a certain level tries all allowable varaiants and returns a list
of those that can be further pursued on deeper levels.

Then solving the problem involves applying the step on all levels
(whicht are indexed by some array indices here):

solve :: Problem -> [State]
solve problem = foldM step start grid
    where start = stateFromProblem problem
          grid = indices (sLines start)

I am totally at loss at how I could accomplish some kind of progress
reporting in this lazily evaluated (I hope) backtracking scheme.

If anybody would like to review the full code (about 80 lines total vor
the solver, not counting I/O), this is where I am right now:

https://github.com/ctbo/slitherlink/tree/c8951ca1eaf83ce9de43f0483740ce339f4134ae

and this is the branch I am working on right now:

https://github.com/ctbo/slitherlink/tree/2lines

Or is there maybe a totally different and better way to approach this
kind of tree search in Haskell? I'm eager to learn.


Thanks for your attention
Harald

-- 
Harald B?geholz     (PGP key available from servers)
Redaktion c't      Tel.: +49 511 5352-300  Fax: +49 511 5352-417
                   http://www.ct.de/

                   int f[9814],b,c=9814,g,i;long a=1e4,d,e,h;
                   main(){for(;b=c,c-=14;i=printf("%04d",e+d/a),e=d%a)
                   while(g=--b*2)d=h*b+a*(i?f[b]:a/5),h=d/--g,f[b]=d%g;}
                                                          (Arndt/Haenel)

                   Affe Apfel Vergaser

/* Heise Zeitschriften Verlag GmbH & Co. KG * Karl-Wiechert-Allee 10 *
   30625 Hannover * Registergericht: Amtsgericht Hannover HRA 26709 *
   Pers?nlich haftende Gesellschafterin: Heise Zeitschriften Verlag *
   Gesch?ftsf?hrung GmbH * Registergericht: Amtsgericht Hannover, HRB
   60405 * Gesch?ftsf?hrer: Ansgar Heise, Dr. Alfons Schr?der */


From muranushi at gmail.com  Fri Sep 21 08:55:35 2012
From: muranushi at gmail.com (Takayuki Muranushi)
Date: Fri, 21 Sep 2012 15:55:35 +0900
Subject: [Haskell-cafe] An easy way to represent and modify graphs?
In-Reply-To: 
References: 
	
Message-ID: 

Yes Pointers. I've forgotten that. I have once dealt with structures,
with lots of IORefs.  It was smooth and fast. Thank you for reminding
me!

On the other hand, use of pointers means that our values are not
algebraic data type any more. We have to derive operations such as
map, fold, serialize by ourselves. I can do that, but am I right? Or
is there some systematic way to derive such operations?

Best regards,

Takayuki


From roma at ro-che.info  Fri Sep 21 11:47:27 2012
From: roma at ro-che.info (Roman Cheplyaka)
Date: Fri, 21 Sep 2012 12:47:27 +0300
Subject: [Haskell-cafe] simple servers
In-Reply-To: <20120921.102922.1937706388715859778.kazu@iij.ad.jp>
References: <20120920.100535.1077347467635688888.kazu@iij.ad.jp>
	<20120920045857.12408752@tritium.streitmacht.eu>
	<20120920.122410.1721442311047037312.kazu@iij.ad.jp>
	<20120921.102922.1937706388715859778.kazu@iij.ad.jp>
Message-ID: <20120921094727.GA8278@sniper>

* Kazu Yamamoto  [2012-09-21 10:29:22+0900]
> Hello,
> 
> > Non-threaded RTS would block FFI to C code. But it does not block file
> > descriptors and sockets because the scheduler uses select(). To my
> > experience, *simple* network programming with non-threaded RTS also
> > works well except the case where we reach the limit of file
> > descriptors for the process.
> 
> I need to correct the last sentence. It should be "we reach the limit
> of select(), 1,024 file descriptors".

Most of the modern systems provide a better alternative to select
(epoll, kqueue etc.) which is used by the IO manager instead.
They don't have such a low limit.

Roman


From aslatter at gmail.com  Fri Sep 21 13:38:53 2012
From: aslatter at gmail.com (Antoine Latter)
Date: Fri, 21 Sep 2012 06:38:53 -0500
Subject: [Haskell-cafe] ANNOUNCE: uuid-1.2.6
In-Reply-To: 
References: 
	
Message-ID: 

On Fri, Sep 21, 2012 at 12:30 AM, David Fox  wrote:
> I was wondering about this:
>
>   -- My goal with this instance was to make it work just enough to do what
>   -- I want when used with the HStringTemplate library.
>   instance Data UUID where
>       toConstr uu  = mkConstr uuidType (show uu) [] (error "fixity")
>       gunfold _ _  = error "gunfold"
>       dataTypeOf _ = uuidType
>
> Is there any reason not to just say "deriving Data" in the type declaration?
>

I didn't want my 'Data' instance to leak the details of the
constructor. Also I don't know much about how 'Data' works.

I think a similar conversation is going on about the Data declarations
in the 'containers' library.

Antoine


From florian.lorenzen at tu-berlin.de  Fri Sep 21 14:34:22 2012
From: florian.lorenzen at tu-berlin.de (Florian Lorenzen)
Date: Fri, 21 Sep 2012 14:34:22 +0200
Subject: [Haskell-cafe] Question about type inference of a GADT term
Message-ID: <505C5ECE.7020806@tu-berlin.de>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello cafe,

I have the following GADT definitions capturing the simply typed
lambda calculus with de Bruijn indices for variables and explicitly
annotated types for variables:


{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DataKinds #-}

- -- Typing contexts
data Ctx = CtxNil
         | CtxCons Ctx Type

- -- Types
data Type = TyInt
          | TyArrow Type Type

- -- Variable indices
data Ix (ctx :: Ctx) (ty :: Type) where
  IxZero :: Ix ctx ty
  IxSucc :: Ix ctx ty1 -> Ix (CtxCons ctx ty2) ty1

- -- Type representations
data TyRep (ty :: Type) where
  TyRepInt :: TyRep TyInt
  TyRepArrow :: TyRep ty1 -> TyRep ty2 -> TyRep (TyArrow ty1 ty2)

- -- Terms
data Term (ctx :: Ctx) (ty :: Type) where
  TmInt :: Integer -> Term ctx TyInt
  TmVar :: Ix ctx ty -> Term ctx ty
  TmAdd :: Term ctx TyInt -> Term ctx TyInt -> Term ctx TyInt
  TmApp :: Term ctx (TyArrow ty1 ty2) -> Term ctx ty1 -> Term ctx ty2
  TmAbs :: TyRep ty1 -> Term (CtxCons ctx ty1) ty2
           -> Term ctx (TyArrow ty1 ty2)

For the following definition

test1 = TmAbs TyRepInt (TmVar IxZero)

GHCi infers the type

test1 :: Term ctx (TyArrow 'TyInt ty2)

I was a bit puzzled because I expected

Term ctx (TyArrow TyInt TyInt)

Of course, this more special type is an instance of the inferred one,
so I can assign it by a type signature.

Can someone explain why the inferred type is more general?

Terms like

test2 = TmAbs TyRepInt (TmAdd (TmVar IxZero) (TmInt 5))

have the type I expected:

test2 :: Term ctx (TyArrow 'TyInt 'TyInt)


Thank you and best regards,

Florian


- -- 
Florian Lorenzen

Technische Universit?t Berlin
Fakult?t IV - Elektrotechnik und Informatik
?bersetzerbau und Programmiersprachen

Sekr. TEL12-2, Ernst-Reuter-Platz 7, D-10587 Berlin

Tel.:   +49 (30) 314-24618
E-Mail: florian.lorenzen at tu-berlin.de
WWW:    http://www.user.tu-berlin.de/florenz/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlBcXs4ACgkQvjzICpVvX7b1WQCePiL+SFNj9X+U0V2fnykuatLX
pIcAn1VDNRiSR18s7UgctdPeNzFgStbi
=LBGb
-----END PGP SIGNATURE-----


From mightybyte at gmail.com  Fri Sep 21 18:03:26 2012
From: mightybyte at gmail.com (MightyByte)
Date: Fri, 21 Sep 2012 12:03:26 -0400
Subject: [Haskell-cafe] [Snap] Argument Substitution in Heist Templates
 with Splices
In-Reply-To: 
References: 
Message-ID: 

This is one of the more subtle corner cases of Heist.  My default, splices
are recursively processed.  So when testSplice is executed for the 
tag, the results are fed back into splice processing.  I think this is the
right thing to do because it makes behavior less sensitive to evaluation
order.  Obviously this can lead to infinite recursion, so Heist limits the
splice call stack to a depth of 50.  If this limit is exceeded, then Heist
simply stops recursing and returns the nodes unprocessed.  I also think
this is the right thing to do because it is happening as we're serving a
page to the end user, so there's an argument for failing quietly instead of
going up in a ball of flames.

In your case, you are returning the same node that was spliced in, so you
are hitting the recursion limit and splice processing just stops.  I
discuss this issue in my blog post about splice subtleties (
http://softwaresimply.blogspot.com/2011/04/splice-subtleties.html).  Since
you're writing a filter splice, you need to call stopRecursion.  But if you
do that, then the child  tag won't be processed.  So what you need
to do is use the runChildren function to process the child nodes, then
return them in whatever your constructed node is.

I think the easiest solution to your problem is to not write it as a filter
splice.  Bind your testSplice function to the  tag and return a
 tag.  This avoids the infinite recursion and will work the way you
want without needing stopRecursion.

On Thu, Sep 20, 2012 at 3:00 PM, Sebastian Fischer  wrote:

> Hello,
>
> the following program demonstrates that arguments in Heist templates
> are sometimes not substituted in presence of splices:
>
> {-# LANGUAGE OverloadedStrings #-}
>
> import           Blaze.ByteString.Builder (toByteString)
> import qualified Data.ByteString.Char8    as BS
> import           Data.Functor             ((<$>))
> import           Data.Maybe               (fromJust)
> import           Text.Templating.Heist
>
> -- just return input node unchanged
> testSplice :: Splice IO
> testSplice = (:[]) <$> getParamNode
>
> main = do
>     writeFile "test.tpl" ""
>     state <- either error id <$> loadTemplates "." defaultHeistState
>
>     (builder,_) <- fromJust <$> renderWithArgs [("arg","42")] state "test"
>     BS.putStrLn $ toByteString builder
>     -- 4242
>
>     let state' = bindSplices [("test",testSplice)] state
>     (builder',_) <- fromJust <$> renderWithArgs [("arg","42")] state'
> "test"
>     BS.putStrLn $ toByteString builder'
>     -- 42
>
> Without using splices, all occurrences of 'arg' in the template are
> substituted. When using a splice, 'arg' is not substituted underneath
> the input node of the splice. It is substituted in an attribute of the
> input node.
>
> Is this intentional? How can I ensure substitution also underneath the
> input node?
>
> Best,
> Sebastian
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From darkniobe at gmail.com  Fri Sep 21 20:46:35 2012
From: darkniobe at gmail.com (Alexander Mumme)
Date: Fri, 21 Sep 2012 11:46:35 -0700 (PDT)
Subject: [Haskell-cafe] Passing CString array to Haskell shared library
Message-ID: <268d0c6f-fd6f-427c-9b32-7ed1c6c989d4@googlegroups.com>

Hello everyone! Long time reader, first time poster.

Was wondering if someone could give me some direction or hints on how I 
might go about passing a CString array into an exported Haskell function.

What I'm trying to do is augment the RecordLinkage package from R using 
Haskell. Seems pretty straight forward. With some help from Neil Mitchell's 
excellent blog post on the subject (
http://neilmitchell.blogspot.com/2011/10/calling-haskell-from-r.html) I've 
managed to make calls into Haskell and utilize the Text.EditDistance 
package.

This is working rather well, except that I'm trying to calculate the edit 
distance from each of 3000 strings to each of 780,000 strings. Since I'm 
calling Haskell from R once for every comparison (and allocating a result 
record in R for each return) I find myself running out of memory rather 
quickly. What I'd like to do is send both complete string lists into 
Haskell to process, and have it pass me back a result vector.

Below is how I'm currently making the call using individual strings. I've 
tried looking through the GHC User's Guide, through the Wiki on usingthe 
FFI, and a number of other resources, but I seem to have come to an 
impasse. Could anyone lend some assistance?

------------- Code start -----
{-# LANGUAGE ForeignFunctionInterface #-}
module Levenshtein where

    import Foreign.C.Types
    import Foreign.C.String
    import Foreign.Ptr
    import Foreign.Storable

    import Text.EditDistance

    levenshteinWeight :: Ptr Int -> Ptr Int -> Ptr Int -> Ptr CString -> 
Ptr CString -> Ptr Int -> IO ()
    levenshteinWeight del ins subs str1 str2 result = do
        del <- peek del
        ins <- peek ins
        subs <- peek subs   
        str1' <- peekCString =<< peek str1
        str2' <- peekCString =<< peek str2
        poke result $ levenshteinDistance EditCosts { deletionCosts = 
ConstantCost del, insertionCosts = ConstantCost ins, substitutionCosts = 
ConstantCost subs, transpositionCosts = ConstantCost 1} str1' str2'

    foreign export ccall levenshteinWeight :: Ptr Int -> Ptr Int -> Ptr Int 
-> Ptr CString -> Ptr CString -> Ptr Int -> IO ()

------------- Code end   -----

Thanks in Advance!
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From pumpkingod at gmail.com  Sat Sep 22 00:55:28 2012
From: pumpkingod at gmail.com (Daniel Peebles)
Date: Fri, 21 Sep 2012 18:55:28 -0400
Subject: [Haskell-cafe] Question about type inference of a GADT term
In-Reply-To: <505C5ECE.7020806@tu-berlin.de>
References: <505C5ECE.7020806@tu-berlin.de>
Message-ID: 

Shouldn't you have

IxZero :: Ix (CtxCons ty ctx) ty

instead of

IxZero :: Ix ctx ty


On Fri, Sep 21, 2012 at 8:34 AM, Florian Lorenzen <
florian.lorenzen at tu-berlin.de> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello cafe,
>
> I have the following GADT definitions capturing the simply typed
> lambda calculus with de Bruijn indices for variables and explicitly
> annotated types for variables:
>
>
> {-# LANGUAGE GADTs #-}
> {-# LANGUAGE KindSignatures #-}
> {-# LANGUAGE DataKinds #-}
>
> - -- Typing contexts
> data Ctx = CtxNil
>          | CtxCons Ctx Type
>
> - -- Types
> data Type = TyInt
>           | TyArrow Type Type
>
> - -- Variable indices
> data Ix (ctx :: Ctx) (ty :: Type) where
>   IxZero :: Ix ctx ty
>   IxSucc :: Ix ctx ty1 -> Ix (CtxCons ctx ty2) ty1
>
> - -- Type representations
> data TyRep (ty :: Type) where
>   TyRepInt :: TyRep TyInt
>   TyRepArrow :: TyRep ty1 -> TyRep ty2 -> TyRep (TyArrow ty1 ty2)
>
> - -- Terms
> data Term (ctx :: Ctx) (ty :: Type) where
>   TmInt :: Integer -> Term ctx TyInt
>   TmVar :: Ix ctx ty -> Term ctx ty
>   TmAdd :: Term ctx TyInt -> Term ctx TyInt -> Term ctx TyInt
>   TmApp :: Term ctx (TyArrow ty1 ty2) -> Term ctx ty1 -> Term ctx ty2
>   TmAbs :: TyRep ty1 -> Term (CtxCons ctx ty1) ty2
>            -> Term ctx (TyArrow ty1 ty2)
>
> For the following definition
>
> test1 = TmAbs TyRepInt (TmVar IxZero)
>
> GHCi infers the type
>
> test1 :: Term ctx (TyArrow 'TyInt ty2)
>
> I was a bit puzzled because I expected
>
> Term ctx (TyArrow TyInt TyInt)
>
> Of course, this more special type is an instance of the inferred one,
> so I can assign it by a type signature.
>
> Can someone explain why the inferred type is more general?
>
> Terms like
>
> test2 = TmAbs TyRepInt (TmAdd (TmVar IxZero) (TmInt 5))
>
> have the type I expected:
>
> test2 :: Term ctx (TyArrow 'TyInt 'TyInt)
>
>
> Thank you and best regards,
>
> Florian
>
>
> - --
> Florian Lorenzen
>
> Technische Universit?t Berlin
> Fakult?t IV - Elektrotechnik und Informatik
> ?bersetzerbau und Programmiersprachen
>
> Sekr. TEL12-2, Ernst-Reuter-Platz 7, D-10587 Berlin
>
> Tel.:   +49 (30) 314-24618
> E-Mail: florian.lorenzen at tu-berlin.de
> WWW:    http://www.user.tu-berlin.de/florenz/
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
>
> iEYEARECAAYFAlBcXs4ACgkQvjzICpVvX7b1WQCePiL+SFNj9X+U0V2fnykuatLX
> pIcAn1VDNRiSR18s7UgctdPeNzFgStbi
> =LBGb
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From oleg at okmij.org  Sat Sep 22 09:23:38 2012
From: oleg at okmij.org (oleg at okmij.org)
Date: 22 Sep 2012 07:23:38 -0000
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
In-Reply-To: 
Message-ID: <20120922072338.18755.qmail@www1.g3.pair.com>


> do you have any references for the extension of lambda-encoding of
> data into dependently typed systems?

> Is there a way out of this quagmire?  Or are we stuck defining actual
> datatypes if we want dependent types?

Although not directly answering your question, the following paper

 Inductive Data Types: Well-ordering Types Revisited
 Healfdene Goguen Zhaohui Luo
 http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.17.8970&rep=rep1&type=pdf

might still be relevant. Sec 2 reviews the major approaches to
inductive data types in Type Theory.




From colinpauladams at gmail.com  Sat Sep 22 11:40:56 2012
From: colinpauladams at gmail.com (Colin Adams)
Date: Sat, 22 Sep 2012 10:40:56 +0100
Subject: [Haskell-cafe] Haskell Wiki News
Message-ID: 

This doesn't seem to be up-to-date. It announces GHC 7.4 released (but
7.6.1 was released a couple of weeks ago).


From florian.lorenzen at tu-berlin.de  Sat Sep 22 12:28:38 2012
From: florian.lorenzen at tu-berlin.de (Florian Lorenzen)
Date: Sat, 22 Sep 2012 12:28:38 +0200
Subject: [Haskell-cafe] Question about type inference of a GADT term
In-Reply-To: 
References: <505C5ECE.7020806@tu-berlin.de>
	
Message-ID: <505D92D6.8090801@tu-berlin.de>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yes, of course! Stupid me, thanks for pointing that out Daniel.

Now it works as expected.

Florian

On 09/22/2012 12:55 AM, Daniel Peebles wrote:
> Shouldn't you have
> 
> IxZero :: Ix (CtxCons ty ctx) ty
> 
> instead of
> 
> IxZero :: Ix ctx ty
> 
> 
> On Fri, Sep 21, 2012 at 8:34 AM, Florian Lorenzen 
>  > wrote:
> 
> Hello cafe,
> 
> I have the following GADT definitions capturing the simply typed 
> lambda calculus with de Bruijn indices for variables and
> explicitly annotated types for variables:
> 
> 
> {-# LANGUAGE GADTs #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE
> DataKinds #-}
> 
> -- Typing contexts data Ctx = CtxNil | CtxCons Ctx Type
> 
> -- Types data Type = TyInt | TyArrow Type Type
> 
> -- Variable indices data Ix (ctx :: Ctx) (ty :: Type) where IxZero
> :: Ix ctx ty IxSucc :: Ix ctx ty1 -> Ix (CtxCons ctx ty2) ty1
> 
> -- Type representations data TyRep (ty :: Type) where TyRepInt ::
> TyRep TyInt TyRepArrow :: TyRep ty1 -> TyRep ty2 -> TyRep (TyArrow
> ty1 ty2)
> 
> -- Terms data Term (ctx :: Ctx) (ty :: Type) where TmInt :: Integer
> -> Term ctx TyInt TmVar :: Ix ctx ty -> Term ctx ty TmAdd :: Term
> ctx TyInt -> Term ctx TyInt -> Term ctx TyInt TmApp :: Term ctx
> (TyArrow ty1 ty2) -> Term ctx ty1 -> Term ctx ty2 TmAbs :: TyRep
> ty1 -> Term (CtxCons ctx ty1) ty2 -> Term ctx (TyArrow ty1 ty2)
> 
> For the following definition
> 
> test1 = TmAbs TyRepInt (TmVar IxZero)
> 
> GHCi infers the type
> 
> test1 :: Term ctx (TyArrow 'TyInt ty2)
> 
> I was a bit puzzled because I expected
> 
> Term ctx (TyArrow TyInt TyInt)
> 
> Of course, this more special type is an instance of the inferred
> one, so I can assign it by a type signature.
> 
> Can someone explain why the inferred type is more general?
> 
> Terms like
> 
> test2 = TmAbs TyRepInt (TmAdd (TmVar IxZero) (TmInt 5))
> 
> have the type I expected:
> 
> test2 :: Term ctx (TyArrow 'TyInt 'TyInt)
> 
> 
> Thank you and best regards,
> 
> Florian
> 
> 
> 
> _______________________________________________ Haskell-Cafe
> mailing list Haskell-Cafe at haskell.org
>  
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 

- -- 
Florian Lorenzen

Technische Universit?t Berlin
Fakult?t IV - Elektrotechnik und Informatik
?bersetzerbau und Programmiersprachen

Sekr. TEL12-2, Ernst-Reuter-Platz 7, D-10587 Berlin

Tel.:   +49 (30) 314-24618
E-Mail: florian.lorenzen at tu-berlin.de
WWW:    http://www.user.tu-berlin.de/florenz/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlBdktYACgkQvjzICpVvX7ZskwCgnJC9VaIkoWHuTZoP8kGg70Tb
MFsAn0yuBDClSxe32ZTO8pZzz1xOpI2T
=EoV6
-----END PGP SIGNATURE-----


From chneukirchen at gmail.com  Sat Sep 22 18:04:42 2012
From: chneukirchen at gmail.com (Christian Neukirchen)
Date: Sat, 22 Sep 2012 18:04:42 +0200
Subject: [Haskell-cafe] Munich Haskell Meeting
Message-ID: <87d31ehwmd.fsf@gmail.com>

Dear all,

Heinrich is on holiday next week, thus I'll manage it this time:
Once again, it's time for our monthly get-together.  Functional
programmers from Munich and other cities will meet on Thu, 27th of
September, at 19h30 at Cafe Puck in Munich.

If you plan to join, please go to

http://www.haskell-munich.de/dates

and click the button!

With hope to meet many of you there,
-- 
Christian Neukirchen    http://chneukirchen.org


From nominolo at googlemail.com  Sat Sep 22 18:13:24 2012
From: nominolo at googlemail.com (Thomas Schilling)
Date: Sat, 22 Sep 2012 17:13:24 +0100
Subject: [Haskell-cafe] Haskell Wiki News
In-Reply-To: 
References: 
Message-ID: 

It's a wiki.  I went ahead and fixed it, this time.

To paraphrase Bryan O'Sullivan: Whenever you think "why hasn't anyone done
...", or "why doesn't somebody fix ...", you should ask yourself "Why don't
*I* do ..." or "Why don't *I* fix ...". That's how open source works.

(Not trying to be offensive, just pointing out that's how we should think
about open source. That's how we got "Real World Haskell", that's how we
got "Criterion", that's how we got the "text" package in its current
version.)

On 22 September 2012 10:40, Colin Adams  wrote:

> This doesn't seem to be up-to-date. It announces GHC 7.4 released (but
> 7.6.1 was released a couple of weeks ago).
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Push the envelope. Watch it bend.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From haskell-cafe at matthewwest.co.uk  Sat Sep 22 22:05:08 2012
From: haskell-cafe at matthewwest.co.uk (Matthew West)
Date: Sat, 22 Sep 2012 21:05:08 +0100
Subject: [Haskell-cafe] Fwd: ANNOUNCE: hsqml-0.1.1 (and hsqml-morris-0.1.0)
References: <284A32C0-4182-4D03-9FEF-6CC3C23F1B4C@matthewwest.co.uk>
Message-ID: 

Hello,
 In case anyone is wondering this does not compile on vanilla Mac OS 10.6 because XCode 3.2 doesn't support C++11.  I believe that XCode 4.2 does support it however I've not yet paid Apple the $100 they want before I can download it for 10.6.  Macports has more recent versions of GCC however this option turned out to be fraught with difficulties[1][2].  Has anybody got HsQML working with XCode 4.2?

Matt

[1] https://trac.macports.org/wiki/UsingTheRightCompiler
[2] http://www.haskell.org/haskellwiki/Mac_OS_X_Strike_Force

On 11 Sep 2012, at 08:47, Robin KAY wrote:

> Dear All,
> 
> I would like to announce a new package called 'hsqml' [1].
> 
> HsQML provides a Haskell binding to the Qt Quick framework. It allows you to write graphical applications where the front-end is written in Qt Quick's QML language (incorporating JavaScript) and the back-end is written in Haskell. The two layers are coupled together via a facility to define custom JavaScript objects through which QML code can call into Haskell.
> 
> HsQML requires an installation of Qt 4.7 (including QtDeclarative) or later on your path. It has been tested with GHC 7.4 on both Linux and Windows.
> 
> There is also a simple example program available using HsQML on Hackage called 'hsqml-morris'. It implements a human v computer game of Nine Men's Morris with game logic and AI written in Haskell and the presentation layer in QML.
> 
> The library is currently limited by a lack of support for Qt signals, so calls can only be made from JavaScript to Haskell and not the other way. I plan to add support for these in a future release. Migration over to Qt 5.x is also likely once it's released.
> 
> [1] http://hackage.haskell.org/package/hsqml-0.1.1
> [2] http://hackage.haskell.org/package/hsqml-morris-0.1.0
> 
> Regards,
> 
> -- 
> Robin KAY



From vigalchin at gmail.com  Sat Sep 22 22:18:58 2012
From: vigalchin at gmail.com (Vasili I. Galchin)
Date: Sat, 22 Sep 2012 13:18:58 -0700
Subject: [Haskell-cafe] Darcs on Windows 7
Message-ID: 

Hello Haskellers,

      I installed darcs on a Windows 7 machine. A darcs folder was created
under "Program Files(x86)" folder. However, when I pull up "Program..." on
the left side, darcs not there for me to run it. Why? Is darcs run only
from the CLI?

Regard,

Vasili
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From mle+hs at mega-nerd.com  Sun Sep 23 00:36:47 2012
From: mle+hs at mega-nerd.com (Erik de Castro Lopo)
Date: Sun, 23 Sep 2012 08:36:47 +1000
Subject: [Haskell-cafe] Darcs on Windows 7
In-Reply-To: 
References: 
Message-ID: <20120923083647.b03b886e53543518ba1eebd0@mega-nerd.com>

Vasili I. Galchin wrote:

> Hello Haskellers,
> 
>       I installed darcs on a Windows 7 machine. A darcs folder was created
> under "Program Files(x86)" folder. However, when I pull up "Program..." on
> the left side, darcs not there for me to run it. Why? Is darcs run only
> from the CLI?

Yes, darcs is a command line program.

Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/


From michael at snoyman.com  Sun Sep 23 06:06:57 2012
From: michael at snoyman.com (Michael Snoyman)
Date: Sun, 23 Sep 2012 06:06:57 +0200
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
Message-ID: 

(Prettier formatting available at: https://gist.github.com/3761252)

Many of us use the OverloadedStrings language extension on a regular
basis. It provides the ability to keep the ease-of-use of string
literal syntax, while getting the performance and correctness
advantages of specialized datatypes like ByteString and Text. I think
we can get the same kind of benefit by allowing another literal syntax
to be overloaded, namely lists.

## Overly simple approach

The simplest example I can think of is allowing easier usage of Vector:

    [1, 2, 3] :: Vector Int

In order to allow this, we could use a typeclass approach similar to
how OverloadedStrings works:

    class IsList a where
        fromList :: [b] -> a b
    instance IsList Vector where
        fromList = V.fromList
    foo :: Vector Int
    foo = fromList [1, 2, 3]

## Flaws

However, such a proposal does not allow for constraints, e.g.:

    instance IsList Set where
        fromList = Set.fromList

    No instance for (Ord b)
      arising from a use of `Set.fromList'
    In the expression: Set.fromList
    In an equation for `fromList': fromList = Set.fromList
    In the instance declaration for `IsList Set'

Additionally, it provides for no means of creating instances for
datatypes like Map, where the contained value is not identical to the
value contained in the original list. In other words, what I'd like to
see is:

    [("foo", 1), ("bar", 2)] :: Map Text Int

## A little better: MPTC

A simplistic approach to solve this would be to just use MultiParamTypeClasses:

    class IsList input output where
        fromList :: [input] -> output
    instance IsList a (Vector a) where
        fromList = V.fromList
    foo :: Vector Int
    foo = fromList [1, 2, 3]

Unfortunately, this will fail due to too much polymorphism:

    No instance for (IsList input0 (Vector Int))
      arising from a use of `fromList'
    Possible fix:
      add an instance declaration for (IsList input0 (Vector Int))
    In the expression: fromList [1, 2, 3]
    In an equation for `foo': foo = fromList [1, 2, 3]

This can be worked around by giving an explicit type signature on the
numbers in the list, but that's not a robust solution. In order to
solve this properly, I think we need either functional dependencies or
type families:

## Functional dependencies

    class IsList input output | output -> input where
        fromList :: [input] -> output
    instance IsList a (Vector a) where
        fromList = V.fromList
    instance Ord a => IsList a (Set a) where
        fromList = Set.fromList
    instance Ord k => IsList (k, v) (Map k v) where
        fromList = Map.fromList

    foo :: Vector Int
    foo = fromList [1, 2, 3]

    bar :: Set Int
    bar = fromList [1, 2, 3]

    baz :: Map String Int
    baz = fromList [("foo", 1), ("bar", 2)]

## Type families

    class IsList a where
        type IsListInput a
        fromList :: [IsListInput a] -> a
    instance IsList (Vector a) where
        type IsListInput (Vector a) = a
        fromList = V.fromList
    instance Ord a => IsList (Set a) where
        type IsListInput (Set a) = a
        fromList = Set.fromList
    instance Ord k => IsList (Map k v) where
        type IsListInput (Map k v) = (k, v)
        fromList = Map.fromList

    foo :: Vector Int
    foo = fromList [1, 2, 3]

    bar :: Set Int
    bar = fromList [1, 2, 3]

    baz :: Map String Int
    baz = fromList [("foo", 1), ("bar", 2)]

## Conclusion

Consider most of this proposal to be a strawman: names and techniques
are completely up to debate. I'm fairly certain that our only two
choices to implement this extension is a useful way is fundeps and
type families, but perhaps there's another approach I'm missing. I
don't have any particular recommendation here, except to say that
fundeps is likely more well supported by other compilers.


From mail at sebfisch.de  Sun Sep 23 10:45:21 2012
From: mail at sebfisch.de (Sebastian Fischer)
Date: Sun, 23 Sep 2012 10:45:21 +0200
Subject: [Haskell-cafe] [Snap] Argument Substitution in Heist Templates
 with Splices
In-Reply-To: 
References: 
	
Message-ID: 

Thanks! For the record, here is how to achieve what I want by
explicitly using `runChildren` and `stopRecursion`:

testSplice :: Splice IO
testSplice = do
    input <- getParamNode
    kids <- runChildren
    stopRecursion
    return [input { elementChildren = kids }]

It surprises me that an explicit call to `runChildren` is necessary,
especially after your comment regarding sensitivity to evaulation
order.

Your linked post shows that Heist splices are processed top down,
which reminds me of the `transform` combinator in Uniplate:

    http://community.haskell.org/~ndm/downloads/paper-uniform_boilerplate_and_list_processing-30_sep_2007.pdf

The authors discuss bottom-up and top-down transformations in Sections
2.3 and 2.4 and argue for providing bottom-up transformations and only
a specific form of top-down transformations.

I think Heist's splice processing would be more intuitive (less
sensitive to evaluation order?) if applied bottom up rather than top
down. This only seems to require a slight change in the definition of
`runNode` from the post you linked - to process children before
applying the splice:

runNode :: Monad m => X.Node -> Splice m
runNode (X.Element nm at ch) = do
    newAtts <- mapM attSubst at
    newKids <- runNodeList ch  -- added this line
    let n = X.Element nm newAtts newKids -- changed this line
    s <- liftM (lookupSplice nm) getTS
    maybe n (recurseSplice n) s  -- changed this line
  -- removed local function `runKids`
runNode n                    = return [n]

This change would simplify the definition of filter splices which
would not need to call `runChildren` explicitly. It would also make
the definition of substitution splices more uniform, because children
would be already processed when applying the splice - just like
attributes are.

Are Heist splices processed top down intentionally? (Reasons for doing
so are the same reasons people might have for preferring call-by-name
over call-by-value. However, I tend to agree with the discussion in
the Uniplate paper and would prefer "call-by-value" aka bottom-up
transformation.)

Best,
Sebastian

On Fri, Sep 21, 2012 at 6:03 PM, MightyByte  wrote:
> This is one of the more subtle corner cases of Heist.  My default, splices
> are recursively processed.  So when testSplice is executed for the 
> tag, the results are fed back into splice processing.  I think this is the
> right thing to do because it makes behavior less sensitive to evaluation
> order.  Obviously this can lead to infinite recursion, so Heist limits the
> splice call stack to a depth of 50.  If this limit is exceeded, then Heist
> simply stops recursing and returns the nodes unprocessed.  I also think this
> is the right thing to do because it is happening as we're serving a page to
> the end user, so there's an argument for failing quietly instead of going up
> in a ball of flames.
>
> In your case, you are returning the same node that was spliced in, so you
> are hitting the recursion limit and splice processing just stops.  I discuss
> this issue in my blog post about splice subtleties
> (http://softwaresimply.blogspot.com/2011/04/splice-subtleties.html).  Since
> you're writing a filter splice, you need to call stopRecursion.  But if you
> do that, then the child  tag won't be processed.  So what you need to
> do is use the runChildren function to process the child nodes, then return
> them in whatever your constructed node is.
>
> I think the easiest solution to your problem is to not write it as a filter
> splice.  Bind your testSplice function to the  tag and return a
>  tag.  This avoids the infinite recursion and will work the way you
> want without needing stopRecursion.
>
> On Thu, Sep 20, 2012 at 3:00 PM, Sebastian Fischer  wrote:
>>
>> Hello,
>>
>> the following program demonstrates that arguments in Heist templates
>> are sometimes not substituted in presence of splices:
>>
>> {-# LANGUAGE OverloadedStrings #-}
>>
>> import           Blaze.ByteString.Builder (toByteString)
>> import qualified Data.ByteString.Char8    as BS
>> import           Data.Functor             ((<$>))
>> import           Data.Maybe               (fromJust)
>> import           Text.Templating.Heist
>>
>> -- just return input node unchanged
>> testSplice :: Splice IO
>> testSplice = (:[]) <$> getParamNode
>>
>> main = do
>>     writeFile "test.tpl" ""
>>     state <- either error id <$> loadTemplates "." defaultHeistState
>>
>>     (builder,_) <- fromJust <$> renderWithArgs [("arg","42")] state "test"
>>     BS.putStrLn $ toByteString builder
>>     -- 4242
>>
>>     let state' = bindSplices [("test",testSplice)] state
>>     (builder',_) <- fromJust <$> renderWithArgs [("arg","42")] state'
>> "test"
>>     BS.putStrLn $ toByteString builder'
>>     -- 42
>>
>> Without using splices, all occurrences of 'arg' in the template are
>> substituted. When using a splice, 'arg' is not substituted underneath
>> the input node of the splice. It is substituted in an attribute of the
>> input node.
>>
>> Is this intentional? How can I ensure substitution also underneath the
>> input node?
>>
>> Best,
>> Sebastian
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>


From apfelmus at quantentunnel.de  Sun Sep 23 10:51:26 2012
From: apfelmus at quantentunnel.de (Heinrich Apfelmus)
Date: Sun, 23 Sep 2012 10:51:26 +0200
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: 
References: 
Message-ID: 

Michael Snoyman wrote:
> (Prettier formatting available at: https://gist.github.com/3761252)
> 
> Many of us use the OverloadedStrings language extension on a regular
> basis. It provides the ability to keep the ease-of-use of string
> literal syntax, while getting the performance and correctness
> advantages of specialized datatypes like ByteString and Text. I think
> we can get the same kind of benefit by allowing another literal syntax
> to be overloaded, namely lists.

Actually, I am already somewhat reserved about the  OverloadedStrings 
proposal.

The core point of the OverloadedSomething extensions is that they 
address a syntactic issue, namely that we can write

   "example"

instead of

   (pack "example")

The extension does this by making the literal polymorphic.

Unfortunately, making literals polymorphic does not always achieve the 
desired effect of reducing syntax. In fact, they can instead increase 
syntax! In other words, I would like to point out that there is a 
trade-off involved: is it worth introducing a small syntactic reduction 
at the cost of both a small additional conceptual complexity and some 
syntactic enlargement elsewhere?


The increase in syntax happened to me while using one of the json 
libraries. The thing is that if a "receiver" function is agnostic in the 
string used, or if it is otherwise polymorphic,

     receive1 :: IsString s => s -> Foo
     receive2 :: JSON s => s -> Foo

then I have to specify the type of the overloaded argument (either by a 
type annotation or a monomorphic function call).

In other words, without  OverloadedStrings , I was able to write

     receive2 "example"

but with the extension, I now have to write

     receive2 (pack "example")


A similar effect can be seen with the good old numeric literals. 
Sometimes, you just have to introduce a type signature (:: Int) to make 
a program unambiguous.


In this light, I don't think that the trade-off made by the 
OverloadedLists extension is big enough.


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com



From jan.stolarek at p.lodz.pl  Sun Sep 23 11:25:48 2012
From: jan.stolarek at p.lodz.pl (Jan Stolarek)
Date: Sun, 23 Sep 2012 11:25:48 +0200
Subject: [Haskell-cafe] Organizaing tests in Haskell
Message-ID: <201209231125.48198.jan.stolarek@p.lodz.pl>

Dear list,

during many years of Java programming I've been faithful to TDD methology. Recently I've been 
trying to figure out how to do tests in Haskell. Thanks to RWH and help from great folks at 
#haskell I've managed to get on my feet. There is however one issue I wasn't able to solve.

In Java it is very easy to separate test code from the actual source. A Java project simply 
contains two folders: src and tests. These two are treated as the source directories. Both these 
directories have the same subdirectory structure. For example I have a source file 
src/myPackage/mySubpackage/MyClass.java and test for it are kept in file 
tests/myPackage/mySubpackage/MyClassTest.java. These two files are considered by Java to be in 
the same package. Here's the main trick: fileds and methods that are marked as protected in Java 
are accessible to other classes in the same package. This allows to test internal methods of a 
class by marking them as protected instead of private. This breaks encapsulation but only within 
a package, which is acceptable.

Now I'd like to achieve something similar in Haskell. I'm using cabal's support for testing. I 
created separate src and tests directories, both with the same subdirectory structure. I keep 
tests for each module in a separate file (e.g. I have src/Math/MyModule.hs and 
tests/Math/MyModuleTest.hs) and I have one file that assembles all the tests into a single test 
suite (I use test-framework for that). The only problem is that in order to test some function 
from a module I have to expose that function, which pretty much forces me to give up on 
encapsulation.

Is there any better solution to organize tests in Haskell? Should I just give up on module 
encapsulation, or should I only test functions exposed by the module and don't worry about 
internal functions? Perhaps I should use some different approach?

Jan


From sol at typeful.net  Sun Sep 23 12:06:28 2012
From: sol at typeful.net (Simon Hengel)
Date: Sun, 23 Sep 2012 12:06:28 +0200
Subject: [Haskell-cafe] Organizaing tests in Haskell
In-Reply-To: <201209231125.48198.jan.stolarek@p.lodz.pl>
References: <201209231125.48198.jan.stolarek@p.lodz.pl>
Message-ID: <20120923100628.GA2844@x200>

Hi,

> Is there any better solution to organize tests in Haskell?

(Disclaimer: I'm the maintainer of Hspec ;)

If you use Hspec[1] for testing, you do not have to assemble your
individual tests manually into a test suit; hspec-discover[2] takes care
of that.

There is no comprehensive user's guide for Hspec yet, but a basic
introduction is at [3].  If you have any questions, feel free to join in
at #hspec on freenode.

> Should I just give up on module encapsulation, or should I only test
> functions exposed by the module and don't worry about internal
> functions?

You can do it with CPP.  Say, if you have a module Foo, with functions
foo, bar and baz, where baz  is not part of the public interface, then
the export list becomes:


    {-# LANGUAGE CPP #-}
    module Foo where (
      foo
    , bar
    #ifdef TEST
    , baz
    #endif
    )

You then run tests with -DTEST.  To make development easier you can add
a .ghci file to your project, with:

    echo ':set -DTEST -isrc -itest' > .ghci

And of course you need to add 

    cpp-options: -DTEST

to your Cabal test-suite section.

Cheers,
Simon

[1] http://hackage.haskell.org/package/hspec
[2] https://github.com/hspec/hspec/tree/master/hspec-discover#automatically-discover-and-run-hspec-tests
[3] http://hspec.github.com/


From haskell-cafe at matthewwest.co.uk  Sun Sep 23 12:16:46 2012
From: haskell-cafe at matthewwest.co.uk (Matthew West)
Date: Sun, 23 Sep 2012 11:16:46 +0100
Subject: [Haskell-cafe] Organizaing tests in Haskell
In-Reply-To: <201209231125.48198.jan.stolarek@p.lodz.pl>
References: <201209231125.48198.jan.stolarek@p.lodz.pl>
Message-ID: <588054B2-F98F-4B0A-8B7A-3A8A0441B3A8@matthewwest.co.uk>


On 23 Sep 2012, at 10:25, Jan Stolarek wrote:

> Dear list,
> 
> during many years of Java programming I've been faithful to TDD methology. Recently I've been 
> trying to figure out how to do tests in Haskell. Thanks to RWH and help from great folks at 
> #haskell I've managed to get on my feet. There is however one issue I wasn't able to solve.
> 
> In Java it is very easy to separate test code from the actual source. A Java project simply 
> contains two folders: src and tests. These two are treated as the source directories. Both these 
> directories have the same subdirectory structure. For example I have a source file 
> src/myPackage/mySubpackage/MyClass.java and test for it are kept in file 
> tests/myPackage/mySubpackage/MyClassTest.java. These two files are considered by Java to be in 
> the same package. Here's the main trick: fileds and methods that are marked as protected in Java 
> are accessible to other classes in the same package. This allows to test internal methods of a 
> class by marking them as protected instead of private. This breaks encapsulation but only within 
> a package, which is acceptable.
> 
> Now I'd like to achieve something similar in Haskell. I'm using cabal's support for testing. I 
> created separate src and tests directories, both with the same subdirectory structure. I keep 
> tests for each module in a separate file (e.g. I have src/Math/MyModule.hs and 
> tests/Math/MyModuleTest.hs) and I have one file that assembles all the tests into a single test 
> suite (I use test-framework for that). The only problem is that in order to test some function 
> from a module I have to expose that function, which pretty much forces me to give up on 
> encapsulation.
> 
> Is there any better solution to organize tests in Haskell? Should I just give up on module 
> encapsulation, or should I only test functions exposed by the module and don't worry about 
> internal functions? Perhaps I should use some different approach?
> 
> Jan
> 
Hi,
  From looking at other packages on Hackage a common trick seems to be to create some internal modules, 
then have an external module that simply exposes the 'public' functions.  Your internal tests can then import 
the internal modules, and your API tests can import the external module.  Of course others are still able to import 
your Internal modules, but you have at least made it clear that that is a bad idea.

for example:

MyLib/Internal/Lib.hs:

module MyLib.Internal.Lib where -- exports all the functions defined in this function
internalFunction = ...
externalFunction = ...

MyLib/Lib.hs
module MyLib.Lib (       -- exports only the public functions
	externalFunction
	)
where
import MyLib.Internal.Lib  -- imports all the internal functions

test/Internal/Lib.hs
...
import MyLib.Internal.Lib
...

test/Lib.hs
...
import MyLib.Lib   -- imports only the public API
...

Yesod is an example of a large project using this approach, for example https://github.com/yesodweb/yesod/tree/master/yesod-core

Matt
	

> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



From sol at typeful.net  Sun Sep 23 12:28:06 2012
From: sol at typeful.net (Simon Hengel)
Date: Sun, 23 Sep 2012 12:28:06 +0200
Subject: [Haskell-cafe] Organizaing tests in Haskell
In-Reply-To: <588054B2-F98F-4B0A-8B7A-3A8A0441B3A8@matthewwest.co.uk>
References: <201209231125.48198.jan.stolarek@p.lodz.pl>
	<588054B2-F98F-4B0A-8B7A-3A8A0441B3A8@matthewwest.co.uk>
Message-ID: <20120923102806.GA8765@x200>

> Of course others are still able to import your Internal modules

That is not necessarily true.  For libraries, you can list internal
modules as other-modules (in contrast to exposed-modules) in you Cabal
file.  That way they are not part of the public interface of your
library.

However, that approach does not work if you want to do encapsulation
within a single project.  I think in that case you most likely end up
with CPP (it's ugly, but it works).

Cheers,
Simon


From agocorona at gmail.com  Sun Sep 23 12:51:15 2012
From: agocorona at gmail.com (Alberto G. Corona )
Date: Sun, 23 Sep 2012 12:51:15 +0200
Subject: [Haskell-cafe] Platform Versioning Policy: upper bounds are not
 our friends
In-Reply-To: <5036DDD9.80806@freegeek.org>
References: 
	<1345106746.3901.13.camel@kirk>
	
	<503062E9.6050606@freegeek.org>
	
	
	<5036DDD9.80806@freegeek.org>
Message-ID: 

Just thinking  aloud:

What if  we add  "-current"  ?

pacage -current

Would select the versions of the package that were current art the time the
cabal file was uploaded and sucessfully compiled in hackage,  if the packae
is installed from hackage

If the cabal file is local then current == any.

This option would eliminate the need to guess bounds for package
dependencies. It would also give more guaranties that the package will
compile sucessfully when downloaded from hackage.

Certainly,it would not guarantee it if your version of ghc differs from the
one in Hackage, but it would make things more simple and would reduce the
spectrum of possible failures


2012/8/24 wren ng thornton 

> On 8/22/12 12:35 PM, David Menendez wrote:
>
>> As I see it, there are four possibilities for a given version of
>> dependency:
>>
>> 1. The version DOES work. The author (or some delegate) has compiled
>> the package against this version and the resulting code is considered
>> good.
>> 2. The version SHOULD work. No one has tested against this version,
>> but the versioning policy promises not to break anything.
>> 3. The version MIGHT NOT work. No one has tested against this version,
>> and the versioning policy allows breaking changes.
>> 4. The version DOES NOT work. This has been tested and the resulting
>> code (if any) is considered not good.
>>
>> Obviously, cases 1 and 4 can only apply to previously released
>> versions. The PVP requires setting upper bounds in order to
>> distinguish cases 2 and 3 for the sake of future compatibility.
>> Leaving off upper bounds except when incompatibility is known
>> essentially combines cases 2 and 3.
>>
>
> Right-o.
>
>
>
>  So there are two failure modes:
>>
>> I. A version which DOES work is outside the bounds (that is, in case
>> 3). I think eliminating case 3 is too extreme. I like the idea of
>> temporarily overriding upper bounds with a command-line option. The
>> danger here is that we might actually be in case 4, in which case we
>> don't want to override the bounds, but requiring an explicit override
>> gives users a chance to determine if a particular version is
>> disallowed because it is untested or because it is known to be
>> incompatible.
>>
>
> There are two failure modes with overriding stated bounds, however. On the
> one hand, the code could fail to compile. Okay, we know we're in case 4;
> all is well. On the other hand the code could successfully compile in ways
> the package designer knows to be buggy/wrong; we're actually in case 4, but
> the user does not know this. This is why it's problematic to simply allow
> overriding constraints. The package developer has some special knowledge
> that the compiler lacks, but if all constraints are considered equal then
> the developer has no way to convey that knowledge to the user (i.e., in an
> automated machine-checkable way). Consequently, the user can end up in a
> bad place because they thought this second failure mode was actually the
> success mode.
>
> This is why I advocate distinguishing hard constraints from soft
> constraints. By making this distinction, the developer has a means of
> conveying their knowledge to users. A soft bound defines an explicit
> boundary between case 1 and cases 2--4, which can be automatically (per
> PVP) extended to an implicit boundary between cases 1--2 and cases 3--4; a
> boundary which, as you say, can only be truly discovered after the code has
> been published. Extending soft boundaries in this way should be safe; at
> least it's as safe as possible with the foresight available to us. On the
> other hand, a hard bound defines an explicit boundary between case 4 and
> cases 1--3. If these are overridable, things may break silently as
> discussed above--- but the important thing is, in virtue of distinguishing
> hard and soft bounds, the user is made aware of this fact. By
> distinguishing hard and soft bounds, the developer can convey their special
> knowledge to the user. The user can ignore this information, but at least
> they'll do so in an informed way.
>
>
> --
> Live well,
> ~wren
>
> ______________________________**_________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/**mailman/listinfo/haskell-cafe
>



-- 
Alberto.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From michael at snoyman.com  Sun Sep 23 13:49:59 2012
From: michael at snoyman.com (Michael Snoyman)
Date: Sun, 23 Sep 2012 13:49:59 +0200
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: 
References: 
	
Message-ID: 

On Sun, Sep 23, 2012 at 10:51 AM, Heinrich Apfelmus
 wrote:
> Michael Snoyman wrote:
>>
>> (Prettier formatting available at: https://gist.github.com/3761252)
>>
>> Many of us use the OverloadedStrings language extension on a regular
>> basis. It provides the ability to keep the ease-of-use of string
>> literal syntax, while getting the performance and correctness
>> advantages of specialized datatypes like ByteString and Text. I think
>> we can get the same kind of benefit by allowing another literal syntax
>> to be overloaded, namely lists.
>
>
> Actually, I am already somewhat reserved about the  OverloadedStrings
> proposal.
>
> The core point of the OverloadedSomething extensions is that they address a
> syntactic issue, namely that we can write
>
>   "example"
>
> instead of
>
>   (pack "example")
>
> The extension does this by making the literal polymorphic.
>
> Unfortunately, making literals polymorphic does not always achieve the
> desired effect of reducing syntax. In fact, they can instead increase
> syntax! In other words, I would like to point out that there is a trade-off
> involved: is it worth introducing a small syntactic reduction at the cost of
> both a small additional conceptual complexity and some syntactic enlargement
> elsewhere?
>
>
> The increase in syntax happened to me while using one of the json libraries.
> The thing is that if a "receiver" function is agnostic in the string used,
> or if it is otherwise polymorphic,
>
>     receive1 :: IsString s => s -> Foo
>     receive2 :: JSON s => s -> Foo
>
> then I have to specify the type of the overloaded argument (either by a type
> annotation or a monomorphic function call).
>
> In other words, without  OverloadedStrings , I was able to write
>
>     receive2 "example"
>
> but with the extension, I now have to write
>
>     receive2 (pack "example")
>
>
> A similar effect can be seen with the good old numeric literals. Sometimes,
> you just have to introduce a type signature (:: Int) to make a program
> unambiguous.
>
>
> In this light, I don't think that the trade-off made by the OverloadedLists
> extension is big enough.
>
>
> Best regards,
> Heinrich Apfelmus
>
> --
> http://apfelmus.nfshost.com
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

I agree with your point. But what you've pointed out is that there's a
trade-off involved, and then elaborated on the downsides of the
trade-off. Let's not forget that there are significant upsides as
well. And based on the large amount of code out there that actually
uses OverloadedStrings, I think many people feel that the upsides
outweigh the downsides in many cases. The nice thing about an
extension like OverloadedStrings or OverloadedLists is that it need
not affect your code in any way: if you don't turn it on, your code
will continue to work. And you'll still be able to use libraries that
themselves use the extensions without any ill effects.

That said, it would be great to come up with ways to mitigate the
downsides of unbounded polymorphism that you bring up. One idea I've
seen mentioned before is to modify these extension so that they target
a specific instance of IsString/IsList, e.g.:

{-# STRING_LITERALS_AS Text #-}

"foo" ==> (fromString "foo" :: Text)

Another might be more intelligent/powerful defaulting rules, similar
to what we have already with numeric literal overloading.

Michael


From jan.stolarek at p.lodz.pl  Sun Sep 23 16:10:56 2012
From: jan.stolarek at p.lodz.pl (Jan Stolarek)
Date: Sun, 23 Sep 2012 16:10:56 +0200
Subject: [Haskell-cafe] Organizaing tests in Haskell
In-Reply-To: <20120923102806.GA8765@x200>
References: <201209231125.48198.jan.stolarek@p.lodz.pl>
	<588054B2-F98F-4B0A-8B7A-3A8A0441B3A8@matthewwest.co.uk>
	<20120923102806.GA8765@x200>
Message-ID: <201209231610.56283.jan.stolarek@p.lodz.pl>

Thanks for replies. CPP approach seems to be what I would like to achieve, but it looks more like 
a hack than a real solution. That said, I like the idea of creating a module that acts as an 
external interface to the library and I I don't mind sacrificing encapsulation within the package 
itself. If it works for project as big as Yesod it should work for me.

> If you use Hspec[1] for testing, you do not have to assemble your
> individual tests manually into a test suit; hspec-discover[2] takes care
> of that.
I guess that I like to have my tests organized manually. It takes a bit of more work and there's a 
risk that I forget to add some test to the suite, but I'm willing to accept these drawbacks and 
get more fine-grained control in return.

Jan


From ky3 at atamo.com  Sun Sep 23 16:36:19 2012
From: ky3 at atamo.com (Kim-Ee Yeoh)
Date: Sun, 23 Sep 2012 21:36:19 +0700
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
In-Reply-To: <20120920081538.8054.qmail@www1.g3.pair.com>
References: <20120920081538.8054.qmail@www1.g3.pair.com>
Message-ID: 

On Thu, Sep 20, 2012 at 3:15 PM, wrote:

> Incidentally, there is more than one way to build a predecessor of Church
> numerals. Kleene's solution is not the only one.


Wouldn't you say then that "Church encoding" is still the more appropriate
reference given that Boehm-Berarducci's algorithm is rarely used? And also
that on discovering Church numerals in the untyped setting, one easily sees
how to get it to work in Haskell? Even when one has no inkling of the
larger picture of the embedding into System F?

When I need to encode pattern matching it's goodbye Church and hello Scott.
Aside from your projects, where else is the B-B procedure used?


-- Kim-Ee


On Thu, Sep 20, 2012 at 3:15 PM,  wrote:

>
> Dan Doel wrote:
> > >> P.S. It is actually possible to write zip function using
> Boehm-Berarducci
> > >> encoding:
> > >>         http://okmij.org/ftp/Algorithms.html#zip-folds
> >
> > If you do, you might want to consider not using the above method, as I
> > seem to recall it doing an undesirable amount of extra work (repeated
> > O(n) tail).
> It is correct. The Boehm-Berarducci web page discusses at some extent
> the general inefficiency of the encoding, the need for repeated
> reflections and reifications for some (but not all) operations. That
> is why arithmetic on Church numerals is generally a bad idea.
>
> A much better encoding of numerals is what I call P-numerals
>         http://okmij.org/ftp/Computation/lambda-calc.html#p-numerals
> It turns out, I have re-discovered them after Michel Parigot (so my
> name P-numerals is actually meaningful). Not only they are faster; one
> can _syntactically_ prove that PRED . SUCC is the identity.
>
> The general idea of course is Goedel's recursor R.
>
>    R b a 0 = a
>    R b a (Succ n) = b n (R b a n)
>
> which easily generalizes to lists. The enclosed code shows the list
> encoding that has constant-time cons, head, tail and trivially
> expressible fold and zip.
>
>
> Kim-Ee Yeoh wrote:
> > So properly speaking, tail and pred for Church-encoded lists and nats
> > are trial-and-error affairs. But the point is they need not be if we
> > use B-B encoding, which looks _exactly_ the same, except one gets a
> > citation link to a systematic procedure.
> >
> > So it looks like you're trying to set the record straight on who actually
> > did what.
>
> Exactly. Incidentally, there is more than one way to build a
> predecessor of Church numerals. Kleene's solution is not the only
> one. Many years ago I was thinking on this problem and designed a
> different predecessor:
>
> excerpted from http://okmij.org/ftp/Haskell/LC_neg.lhs
>
>
>     One ad hoc way of defining a predecessor of a positive numeral
>                     predp cn+1 ==> cn
>     is to represent "predp cn" as "cn f v"
>     where f and v are so chosen that (f z) acts as
>             if z == v then c0 else (succ z)
>     We know that z can be either a numeral cn or a special value v. All
>     Church numerals have a property that (cn combI) is combI: the identity
>     combinator is a fixpoint of every numeral. Therefore, ((cn combI) (succ
>     cn)) reduces to (succ cn). We only need to choose the value v in such
>     a way that ((v I) (succ v)) yields c0.
>
>     > predp = eval $
>     >   c ^ c
>     >        # (z ^ (z # combI # (succ # z)))       -- function f(z)
>     >        # (a ^ x ^ c0)                         -- value v
>
>
> {-# LANGUAGE Rank2Types #-}
>
> -- List represented with R
>
> newtype R x = R{unR :: forall w.
>   -- b
>   (x -> R x -> w -> w)
>   -- a
>   -> w
>   -- result
>   -> w}
>
> nil :: R x
> nil = R (\b a -> a)
>
> -- constant type
> cons :: x -> R x -> R x
> cons x r = R(\b a -> b x r (unR r b a))
>
> -- constant time
> rhead :: R x -> x
> rhead (R fr) = fr (\x _ _ -> x) (error "head of the empty list")
>
> -- constant time
> rtail :: R x -> R x
> rtail (R fr) = fr (\_ r _ -> r) (error "tail of the empty list")
>
> -- fold
> rfold :: (x -> w -> w) -> w -> R x -> w
> rfold f z (R fr) = fr (\x _ w -> f x w) z
>
> -- zip is expressed via fold
> rzipWith :: (x -> y -> z) -> R x -> R y -> R z
> rzipWith f r1 r2 =  rfold f' z r1 r2
>  where f' x tD = \r2 -> cons (f x (rhead r2)) (tD (rtail r2))
>        z       = \_  -> nil
>
> -- tests
>
> toR :: [a] -> R a
> toR = foldr cons nil
>
> toL :: R a -> [a]
> toL = rfold (:) []
>
>
> l1 = toR [1..10]
> l2 = toR "abcde"
>
>
> t1 = toL $ rtail l2
> -- "bcde"
>
> t2 = toL $ rzipWith (,) l2 l1
> -- [('a',1),('b',2),('c',3),('d',4),('e',5)]
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From roma at ro-che.info  Sun Sep 23 17:34:22 2012
From: roma at ro-che.info (Roman Cheplyaka)
Date: Sun, 23 Sep 2012 18:34:22 +0300
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: 
References: 
	
Message-ID: <20120923153422.GA16107@sniper>

* Heinrich Apfelmus  [2012-09-23 10:51:26+0200]
> Unfortunately, making literals polymorphic does not always achieve
> the desired effect of reducing syntax. In fact, they can instead
> increase syntax! In other words, I would like to point out that there
> is a trade-off involved: is it worth introducing a small syntactic
> reduction at the cost of both a small additional conceptual
> complexity and some syntactic enlargement elsewhere?

Can't you just disable the extension when you realise that it
makes your life harder?

Roman


From cdsmith at gmail.com  Sun Sep 23 17:51:18 2012
From: cdsmith at gmail.com (Chris Smith)
Date: Sun, 23 Sep 2012 08:51:18 -0700
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: 
References: 
	
	
Message-ID: 

Michael Snoyman  wrote:
> That said, it would be great to come up with ways to mitigate the
> downsides of unbounded polymorphism that you bring up. One idea I've
> seen mentioned before is to modify these extension so that they target
> a specific instance of IsString/IsList, e.g.:
>
> {-# STRING_LITERALS_AS Text #-}
>
> "foo" ==> (fromString "foo" :: Text)

That makes sense for OverloadedStrings, but probably not for
OverloadedLists or overloaded numbers... String literals have the
benefit that there's one type that you probably always really meant.
The cases where you really wanted [Char] or ByteString are rare.  On
the other hand, there really is no sensible "I always want this"
answer for lists or numbers.  It seems like a kludge to do it
per-module if each module is going to give different answers most of
the time.

-- 
Chris


From michael at snoyman.com  Sun Sep 23 17:59:31 2012
From: michael at snoyman.com (Michael Snoyman)
Date: Sun, 23 Sep 2012 17:59:31 +0200
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: 
References: 
	
	
	
Message-ID: 

On Sun, Sep 23, 2012 at 5:51 PM, Chris Smith  wrote:
> Michael Snoyman  wrote:
>> That said, it would be great to come up with ways to mitigate the
>> downsides of unbounded polymorphism that you bring up. One idea I've
>> seen mentioned before is to modify these extension so that they target
>> a specific instance of IsString/IsList, e.g.:
>>
>> {-# STRING_LITERALS_AS Text #-}
>>
>> "foo" ==> (fromString "foo" :: Text)
>
> That makes sense for OverloadedStrings, but probably not for
> OverloadedLists or overloaded numbers... String literals have the
> benefit that there's one type that you probably always really meant.
> The cases where you really wanted [Char] or ByteString are rare.  On
> the other hand, there really is no sensible "I always want this"
> answer for lists or numbers.  It seems like a kludge to do it
> per-module if each module is going to give different answers most of
> the time.
>
> --
> Chris

Note that I wasn't necessarily advocating such a pragma. And a lot of
my XML code actually *does* use two IsString instances at the same
time, e.g.:

    Element ("img" :: Name) (singleton ("href" :: Name) ("foo.png" ::
Text)) [NodeComment ("No content inside an image" :: Text)]

(Courtesy of xml-conduit.)

To prove your point even further, with OverloadedLists we could
replace that `singleton` call with `[("href", "foo.png")]` and then be
using two `IsList` instances simultaneously as well (`Map` and `[]`).

Also, I use the `ByteString` instance of `IsString` regularly when
using `http-conduit` and `warp` (for all of the header values), and to
an even greater extent when hacking on the internals of any HTTP
library (whether `http-conduit` or something in the `wai` ecosystem).

Michael


From allbery.b at gmail.com  Sun Sep 23 18:09:12 2012
From: allbery.b at gmail.com (Brandon Allbery)
Date: Sun, 23 Sep 2012 12:09:12 -0400
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: 
References: 
	
	
	
	
Message-ID: 

Maybe what's needed is a way to mutate the lexer by adding new kinds of
literals; Unicode offers a number of paired brackets and quote-like
characters.  Although that is likely to get into readability issues
especially if you do have a mixture of [Char], ByteString, and Text for
some reason.  (Map vs. [] is probably easy enough but add another one or
two in and the sam problem rears its head quickly.)

-- 
brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From apfelmus at quantentunnel.de  Sun Sep 23 18:11:59 2012
From: apfelmus at quantentunnel.de (Heinrich Apfelmus)
Date: Sun, 23 Sep 2012 18:11:59 +0200
Subject: [Haskell-cafe] Organizaing tests in Haskell
In-Reply-To: <20120923102806.GA8765@x200>
References: <201209231125.48198.jan.stolarek@p.lodz.pl>	<588054B2-F98F-4B0A-8B7A-3A8A0441B3A8@matthewwest.co.uk>
	<20120923102806.GA8765@x200>
Message-ID: 

Simon Hengel wrote:
>> Of course others are still able to import your Internal modules
> 
> That is not necessarily true.  For libraries, you can list internal
> modules as other-modules (in contrast to exposed-modules) in you Cabal
> file.  That way they are not part of the public interface of your
> library.

How do I access internal modules with  cabal test , though? Last time I 
tried, I could not find a way to expose in the test section of the cabal 
file.


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com



From sol at typeful.net  Sun Sep 23 19:00:51 2012
From: sol at typeful.net (Simon Hengel)
Date: Sun, 23 Sep 2012 19:00:51 +0200
Subject: [Haskell-cafe] Organizaing tests in Haskell
In-Reply-To: 
References: <201209231125.48198.jan.stolarek@p.lodz.pl>
	<588054B2-F98F-4B0A-8B7A-3A8A0441B3A8@matthewwest.co.uk>
	<20120923102806.GA8765@x200> 
Message-ID: <20120923170051.GA11983@x200>

On Sun, Sep 23, 2012 at 06:11:59PM +0200, Heinrich Apfelmus wrote:
> Simon Hengel wrote:
> >>Of course others are still able to import your Internal modules
> >
> >That is not necessarily true.  For libraries, you can list internal
> >modules as other-modules (in contrast to exposed-modules) in you Cabal
> >file.  That way they are not part of the public interface of your
> >library.
> 
> How do I access internal modules with  cabal test , though? Last
> time I tried, I could not find a way to expose in the test section
> of the cabal file.

It works, if you add the source directory to hs-source-dirs of the test
suite (in contrast to depending on the library!), e.g.:

  hs-source-dirs: test, src

or

  hs-source-dirs: test, .

This still has the disadvantage, that the sources are compiled twice.
But I'm not aware of a better way to do it.  If you mostly use GHCi for
development, it's not a big issue.

Cheers,
Simon


From sol at typeful.net  Sun Sep 23 19:11:10 2012
From: sol at typeful.net (Simon Hengel)
Date: Sun, 23 Sep 2012 19:11:10 +0200
Subject: [Haskell-cafe] Organizaing tests in Haskell
In-Reply-To: <201209231610.56283.jan.stolarek@p.lodz.pl>
References: <201209231125.48198.jan.stolarek@p.lodz.pl>
	<588054B2-F98F-4B0A-8B7A-3A8A0441B3A8@matthewwest.co.uk>
	<20120923102806.GA8765@x200>
	<201209231610.56283.jan.stolarek@p.lodz.pl>
Message-ID: <20120923171110.GB11983@x200>

On Sun, Sep 23, 2012 at 04:10:56PM +0200, Jan Stolarek wrote:
> I don't mind sacrificing encapsulation within the package itself. If
> it works for project as big as Yesod it should work for me.

Yesod uses the CPP solution, too (e.g. [1]).

Cheers,
Simon

[1] https://github.com/yesodweb/shakespeare/blob/master/shakespeare/Text/Shakespeare.hs


From rwallace at thewallacepack.net  Sun Sep 23 19:43:45 2012
From: rwallace at thewallacepack.net (Richard Wallace)
Date: Sun, 23 Sep 2012 10:43:45 -0700
Subject: [Haskell-cafe] Getting started with Shake
Message-ID: 

Hey all,

I'm going to be working on a webapp in Haskell in the upcoming months
and am thinking Shake would be a good fit - I'll need to do js, css,
and probably some graphics processing as part of the build and would
like to use Shake to automate deployment.

I'm not entirely sure how to get started with Shake.  I've used to
make, jam, maven, sbt and other build tools in the past.  All of these
keep a build configuration in the project and use that to build the
project.  In sbt, which is most like Shake, the build configuration is
written in Scala and compiled by sbt when you run the build.  The
result of the compilation is saved and reused unless it detects that
the build source files changed.

With shake I'm not sure exactly how to get started.  Should I have a
separate project where I create the build system for the webapp?  Or
can I setup something similar to sbt?

Also, how do I handle dependencies with shake?  cabal will pull in
packages from hackage and do the needful, is there anything in shake
to do the same?  If not, how is it normally done?

Thanks,
Rich


From ekmett at gmail.com  Mon Sep 24 12:47:29 2012
From: ekmett at gmail.com (Edward Kmett)
Date: Mon, 24 Sep 2012 06:47:29 -0400
Subject: [Haskell-cafe] haddock changes between 2.10 and 2.12?
Message-ID: 

Was there some significant change/bug introduced to haddock made between
2.10 and 2.12?

When I look at the haddocks for kan-extensions 3.1:
Data.Functor.Yoneda
which
purports to have been built by haddock 2.12 it shows all sorts of spurious
superclass constraints on almost every instance that should have simplified
out, but going back to kan-extensions-2.7:
Data.Functor.Yoneda
none of this extra noise is present -- and the code in question hasn't been
changed in the interim, so I'm pretty sure its not on my end.

-Edward
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From jason.dusek at gmail.com  Mon Sep 24 13:42:56 2012
From: jason.dusek at gmail.com (Jason Dusek)
Date: Mon, 24 Sep 2012 11:42:56 +0000
Subject: [Haskell-cafe] Partial statical linking
In-Reply-To: 
References: 
	<1322726819-sup-1706@ezyang>
	<0284E8E8-CEED-4E06-AAF0-788B8CA900D5@gmail.com>
	
	
Message-ID: 

2012/9/19 Brandon Allbery :
> On Wed, Sep 19, 2012 at 7:06 AM, Jason Dusek  wrote:
>> What I attempted was building a binary with only some C libraries
>> statically linked, with this command line:
>>
>>   # Build https://github.com/erudify/sssp on Ubunut 12.04
>>   ghc -outputdir ./tmp -v --make -O2 sssp.hs -o sssp.ubuntu \
>>     /usr/lib/x86_64-linux-gnu/libffi.a \
>>     /usr/lib/x86_64-linux-gnu/libgmp.a \
>>     /usr/lib/x86_64-linux-gnu/libz.a
>>
>> However, this really made no difference. Running `ldd' on the
>> resulting binary reveals that libz and friends are still
>> dynamically linked:
>
> On Linux you probably need -optl--whole-archive for this to do anything;
> alternately, you would need to get the final ld command line out of ghc and
> insert the above libraries into it *after* the package .a files.
>
> Putting them before the packages (including the GHC runtime) that need them,
> as will happen by default, will cause them to be ignored because they
> contain no required symbols *at that point* in the link.  --whole-archive
> tells to blindly link the whole static archive in instead of ignoring it.

Hi Brandon,

This turned out to be the right ticket. The full command line is
like this:

  ghc -outputdir ./tmp --make -O2 sssp.hs -o sssp.ubuntu \
    -optl-Wl,--whole-archive \
      /usr/lib/x86_64-linux-gnu/libffi.a \
      /usr/lib/x86_64-linux-gnu/libgmp.a \
      /usr/lib/x86_64-linux-gnu/libz.a \
    -optl-Wl,--no-whole-archive

Without the --no-whole-archive at the end, I get errors like:

  (.text+0x880): multiple definition of `__morestack_unblock_signals'
  /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc.a(generic-morestack.o):(.text+0x880):
first defined here
  /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc.a(generic-morestack.o): In
function `__morestack_allocate_stack_space':

I am not sure why that happens -- libgcc.a wasn't explicitly
asked for; but it stands to reason that one shouldn't specify
--whole-archive for everything GHC links, just the archives of
interest. Life is short and art is long.

--
Jason Dusek
pgp // solidsnack // C1EBC57DC55144F35460C8DF1FD4C6C1FED18A2B


From giorgidze at gmail.com  Mon Sep 24 14:53:12 2012
From: giorgidze at gmail.com (George Giorgidze)
Date: Mon, 24 Sep 2012 14:53:12 +0200
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
Message-ID: 

Hi Michael,

Here at the University of T?bingen, I am co-supervising (together with
Jeroen Weijers) a student project implementing the OverloadedLists
extension for GHC. Achim Krause is the student who is working on the
project. We took into consideration earlier discussions on this topic
[1,2] before embarking on the project.

Achim has worked on two approaches.

The first approach is very simple, both from the user's and the
extension implementor's perspective (it follows the implementation of
OverloadedStrings closely) and typechecks and desugars lists like

[] ; [x,y,z] ;  ['a' .. 'z'] ;

as

fromList [] ;  fromList [x,y,z] ; fromList ['a' .. 'z'] ;

where fromList is whatever is in scope with that name. That said, we
do provide the FromList type class that can be used to overload
fromList. In the following I give the definition of the class, as well
as, example instances:

class FromList l where
  type Item l
  fromList :: [Item l] -> l

instance FromList [a] where
  type Item [a] = a
  fromList = id

instance (Ord a) => FromList (Set a) where
  type Item (Set a) = a
  fromList = Set.fromList

instance (Ord k) => FromList (Map k v) where
  type Item (Map k v) = (k,v)
  fromList = Map.fromList

instance FromList (IntMap v) where
  type Item (IntMap v) = (Int,v)
  fromList = IntMap.fromList

instance FromList Text where
  type Item Text = Char
  fromList = Text.pack

This approach has already been implemented by Achim as patch against GHC head.

This approach is very simple, but can be inefficient as it may result
into unnecessary construction of lists at runtime. This can be a
serious issue when constructing large structures from arithmetic
sequences (e.g., from the [ .. ] notation) or when using non-literal
expressions (e.g., variables) inside the square brackets.

Our second approach to OverloadedLists is to avoid the construction of
lists altogether. By typechecking and desugaring lists like

[] ; [x,y,z] ;  ['a' .. 'z'] ;

as

mempty ; singleton x `mappend` singleton y `mappend` singleton z ;
genericEnumFromTo 'a' 'z' ;

We  provide the Singleton and GenericEnum type classes for overloading
singleton and genericEnum(..) functions. In the following, I give the
definitions of the classes, as well as, example instances:

-- Singleton class

class Singleton l where
  type SingletonItem l
  singleton :: SingletonItem l -> l

-- Singleton instances

instance Singleton [a] where
  type SingletonItem [a] = a
  singleton a = [a]

instance (Ord a) => Singleton (Set a) where
  type SingletonItem (Set a) = a
  singleton = Set.singleton

instance (Ord k) => Singleton (Map k v) where
  type SingletonItem (Map k v) = (k,v)
  singleton (k,v) = Map.singleton k v

instance Singleton (IntMap v) where
  type SingletonItem (IntMap v) = (Int,v)
  singleton (k,v) = IntMap.singleton k v

instance Singleton Text where
  type SingletonItem Text = Char
  singleton = Text.singleton

-- GenericEnum class

class GenericEnum l where
  type EnumItem l
  genericEnumFrom        :: EnumItem l -> l
  genericEnumFromThen    :: EnumItem l -> EnumItem l -> l
  genericEnumFromTo      :: EnumItem l -> EnumItem l -> l
  genericEnumFromThenTo  :: EnumItem l -> EnumItem l -> EnumItem l -> l

-- GenericEnum instances

instance (Enum a) => GenericEnum [a] where
  type EnumItem [a] = a
  genericEnumFrom        = enumFrom
  genericEnumFromThen    = enumFromThen
  genericEnumFromTo      = enumFromTo
  genericEnumFromThenTo  = enumFromThenTo

instance (Ord a,Enum a) => GenericEnum (Set a) where
  type EnumItem (Set a) = a
  genericEnumFrom       a     = Set.fromList (enumFrom a)
  genericEnumFromThen   a b   = Set.fromList (enumFromThen a b)
  genericEnumFromTo     a b   = Set.fromList (enumFromTo a b)
  genericEnumFromThenTo a b c = Set.fromList (enumFromThenTo a b c)

instance (Ord k,Enum (k,v)) => GenericEnum (Map k v) where
  type EnumItem (Map k v) = (k,v)
  genericEnumFrom       a     = Map.fromList (enumFrom a)
  genericEnumFromThen   a b   = Map.fromList (enumFromThen a b)
  genericEnumFromTo     a b   = Map.fromList (enumFromTo a b)
  genericEnumFromThenTo a b c = Map.fromList (enumFromThenTo a b c)

instance (Enum (Int,v)) => GenericEnum (IntMap v) where
  type EnumItem (IntMap v) = (Int,v)
  genericEnumFrom       a     = IntMap.fromList (enumFrom a)
  genericEnumFromThen   a b   = IntMap.fromList (enumFromThen a b)
  genericEnumFromTo     a b   = IntMap.fromList (enumFromTo a b)
  genericEnumFromThenTo a b c = IntMap.fromList (enumFromThenTo a b c)

instance GenericEnum Text where
  type EnumItem Text = Char
  genericEnumFrom       a     = Text.pack (enumFrom a)
  genericEnumFromThen   a b   = Text.pack (enumFromThen a b)
  genericEnumFromTo     a b   = Text.pack (enumFromTo a b)
  genericEnumFromThenTo a b c = Text.pack (enumFromThenTo a b c)

Note that the GenericEnum instances can be implemented more
efficiently, but for now I give simple definitions that go through
lists.

Our second approach avoids the construction of intermediate lists at
runtime and directly constructs the target data structure for which
the list notation is used.

We will release GHC patches for both approaches, meanwhile the
feedback from the community on the approaches that we took would be
very much appreciated. Which one those would you prefer? or would you
suggest a different one.

Note that we intend to make fromList in the first approach and
singleton, genericEnum(..), mempty and mapped rebindable. This means
that the definitions of the type classes that overload this functions
can be easily changed. Having said that, altering the changes that
Achim already made to the GHC source code (including typechecking and
desugaring rules) will be more work and we hope that one of the
approaches that we took will be acceptable for the community.

Cheers, George

[1] http://www.mail-archive.com/glasgow-haskell-users at haskell.org/msg20447.html
[2] http://www.mail-archive.com/glasgow-haskell-users at haskell.org/msg20518.html


From magnus at therning.org  Mon Sep 24 15:07:05 2012
From: magnus at therning.org (Magnus Therning)
Date: Mon, 24 Sep 2012 15:07:05 +0200
Subject: [Haskell-cafe] Darcs on Windows 7
In-Reply-To: <20120923083647.b03b886e53543518ba1eebd0@mega-nerd.com>
References: 
	<20120923083647.b03b886e53543518ba1eebd0@mega-nerd.com>
Message-ID: 

On Sun, Sep 23, 2012 at 12:36 AM, Erik de Castro Lopo
 wrote:
> Vasili I. Galchin wrote:
>
>> Hello Haskellers,
>>
>>       I installed darcs on a Windows 7 machine. A darcs folder was created
>> under "Program Files(x86)" folder. However, when I pull up "Program..." on
>> the left side, darcs not there for me to run it. Why? Is darcs run only
>> from the CLI?
>
> Yes, darcs is a command line program.

There is a GUI for windows, but I have no idea whether it's good or
not: http://tortoisedarcs.sourceforge.net/

/M

-- 
Magnus Therning                      OpenPGP: 0xAB4DFBA4
email: magnus at therning.org   jabber: magnus at therning.org
twitter: magthe               http://therning.org/magnus


From alpmestan at gmail.com  Mon Sep 24 15:13:57 2012
From: alpmestan at gmail.com (Alp Mestanogullari)
Date: Mon, 24 Sep 2012 15:13:57 +0200
Subject: [Haskell-cafe] Darcs on Windows 7
In-Reply-To: 
References: 
	<20120923083647.b03b886e53543518ba1eebd0@mega-nerd.com>
	
Message-ID: 

I have tested it a long time ago. It worked fine.
However, when I need to use darcs on Windows 7 now, I just use the CLI, I
don't really need more.

On Mon, Sep 24, 2012 at 3:07 PM, Magnus Therning wrote:

> On Sun, Sep 23, 2012 at 12:36 AM, Erik de Castro Lopo
>  wrote:
> > Vasili I. Galchin wrote:
> >
> >> Hello Haskellers,
> >>
> >>       I installed darcs on a Windows 7 machine. A darcs folder was
> created
> >> under "Program Files(x86)" folder. However, when I pull up "Program..."
> on
> >> the left side, darcs not there for me to run it. Why? Is darcs run only
> >> from the CLI?
> >
> > Yes, darcs is a command line program.
>
> There is a GUI for windows, but I have no idea whether it's good or
> not: http://tortoisedarcs.sourceforge.net/
>
> /M
>
> --
> Magnus Therning                      OpenPGP: 0xAB4DFBA4
> email: magnus at therning.org   jabber: magnus at therning.org
> twitter: magthe               http://therning.org/magnus
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Alp Mestanogullari
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From michael at snoyman.com  Mon Sep 24 15:33:20 2012
From: michael at snoyman.com (Michael Snoyman)
Date: Mon, 24 Sep 2012 15:33:20 +0200
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: 
References: 
Message-ID: 

On Mon, Sep 24, 2012 at 2:53 PM, George Giorgidze  wrote:
> Hi Michael,
>
> Here at the University of T?bingen, I am co-supervising (together with
> Jeroen Weijers) a student project implementing the OverloadedLists
> extension for GHC. Achim Krause is the student who is working on the
> project. We took into consideration earlier discussions on this topic
> [1,2] before embarking on the project.
>
> Achim has worked on two approaches.
>
> The first approach is very simple, both from the user's and the
> extension implementor's perspective (it follows the implementation of
> OverloadedStrings closely) and typechecks and desugars lists like
>
> [] ; [x,y,z] ;  ['a' .. 'z'] ;
>
> as
>
> fromList [] ;  fromList [x,y,z] ; fromList ['a' .. 'z'] ;
>
> where fromList is whatever is in scope with that name. That said, we
> do provide the FromList type class that can be used to overload
> fromList. In the following I give the definition of the class, as well
> as, example instances:
>
> class FromList l where
>   type Item l
>   fromList :: [Item l] -> l
>
> instance FromList [a] where
>   type Item [a] = a
>   fromList = id
>
> instance (Ord a) => FromList (Set a) where
>   type Item (Set a) = a
>   fromList = Set.fromList
>
> instance (Ord k) => FromList (Map k v) where
>   type Item (Map k v) = (k,v)
>   fromList = Map.fromList
>
> instance FromList (IntMap v) where
>   type Item (IntMap v) = (Int,v)
>   fromList = IntMap.fromList
>
> instance FromList Text where
>   type Item Text = Char
>   fromList = Text.pack
>
> This approach has already been implemented by Achim as patch against GHC head.
>
> This approach is very simple, but can be inefficient as it may result
> into unnecessary construction of lists at runtime. This can be a
> serious issue when constructing large structures from arithmetic
> sequences (e.g., from the [ .. ] notation) or when using non-literal
> expressions (e.g., variables) inside the square brackets.
>
> Our second approach to OverloadedLists is to avoid the construction of
> lists altogether. By typechecking and desugaring lists like
>
> [] ; [x,y,z] ;  ['a' .. 'z'] ;
>
> as
>
> mempty ; singleton x `mappend` singleton y `mappend` singleton z ;
> genericEnumFromTo 'a' 'z' ;
>
> We  provide the Singleton and GenericEnum type classes for overloading
> singleton and genericEnum(..) functions. In the following, I give the
> definitions of the classes, as well as, example instances:
>
> -- Singleton class
>
> class Singleton l where
>   type SingletonItem l
>   singleton :: SingletonItem l -> l
>
> -- Singleton instances
>
> instance Singleton [a] where
>   type SingletonItem [a] = a
>   singleton a = [a]
>
> instance (Ord a) => Singleton (Set a) where
>   type SingletonItem (Set a) = a
>   singleton = Set.singleton
>
> instance (Ord k) => Singleton (Map k v) where
>   type SingletonItem (Map k v) = (k,v)
>   singleton (k,v) = Map.singleton k v
>
> instance Singleton (IntMap v) where
>   type SingletonItem (IntMap v) = (Int,v)
>   singleton (k,v) = IntMap.singleton k v
>
> instance Singleton Text where
>   type SingletonItem Text = Char
>   singleton = Text.singleton
>
> -- GenericEnum class
>
> class GenericEnum l where
>   type EnumItem l
>   genericEnumFrom        :: EnumItem l -> l
>   genericEnumFromThen    :: EnumItem l -> EnumItem l -> l
>   genericEnumFromTo      :: EnumItem l -> EnumItem l -> l
>   genericEnumFromThenTo  :: EnumItem l -> EnumItem l -> EnumItem l -> l
>
> -- GenericEnum instances
>
> instance (Enum a) => GenericEnum [a] where
>   type EnumItem [a] = a
>   genericEnumFrom        = enumFrom
>   genericEnumFromThen    = enumFromThen
>   genericEnumFromTo      = enumFromTo
>   genericEnumFromThenTo  = enumFromThenTo
>
> instance (Ord a,Enum a) => GenericEnum (Set a) where
>   type EnumItem (Set a) = a
>   genericEnumFrom       a     = Set.fromList (enumFrom a)
>   genericEnumFromThen   a b   = Set.fromList (enumFromThen a b)
>   genericEnumFromTo     a b   = Set.fromList (enumFromTo a b)
>   genericEnumFromThenTo a b c = Set.fromList (enumFromThenTo a b c)
>
> instance (Ord k,Enum (k,v)) => GenericEnum (Map k v) where
>   type EnumItem (Map k v) = (k,v)
>   genericEnumFrom       a     = Map.fromList (enumFrom a)
>   genericEnumFromThen   a b   = Map.fromList (enumFromThen a b)
>   genericEnumFromTo     a b   = Map.fromList (enumFromTo a b)
>   genericEnumFromThenTo a b c = Map.fromList (enumFromThenTo a b c)
>
> instance (Enum (Int,v)) => GenericEnum (IntMap v) where
>   type EnumItem (IntMap v) = (Int,v)
>   genericEnumFrom       a     = IntMap.fromList (enumFrom a)
>   genericEnumFromThen   a b   = IntMap.fromList (enumFromThen a b)
>   genericEnumFromTo     a b   = IntMap.fromList (enumFromTo a b)
>   genericEnumFromThenTo a b c = IntMap.fromList (enumFromThenTo a b c)
>
> instance GenericEnum Text where
>   type EnumItem Text = Char
>   genericEnumFrom       a     = Text.pack (enumFrom a)
>   genericEnumFromThen   a b   = Text.pack (enumFromThen a b)
>   genericEnumFromTo     a b   = Text.pack (enumFromTo a b)
>   genericEnumFromThenTo a b c = Text.pack (enumFromThenTo a b c)
>
> Note that the GenericEnum instances can be implemented more
> efficiently, but for now I give simple definitions that go through
> lists.
>
> Our second approach avoids the construction of intermediate lists at
> runtime and directly constructs the target data structure for which
> the list notation is used.
>
> We will release GHC patches for both approaches, meanwhile the
> feedback from the community on the approaches that we took would be
> very much appreciated. Which one those would you prefer? or would you
> suggest a different one.
>
> Note that we intend to make fromList in the first approach and
> singleton, genericEnum(..), mempty and mapped rebindable. This means
> that the definitions of the type classes that overload this functions
> can be easily changed. Having said that, altering the changes that
> Achim already made to the GHC source code (including typechecking and
> desugaring rules) will be more work and we hope that one of the
> approaches that we took will be acceptable for the community.
>
> Cheers, George
>
> [1] http://www.mail-archive.com/glasgow-haskell-users at haskell.org/msg20447.html
> [2] http://www.mail-archive.com/glasgow-haskell-users at haskell.org/msg20518.html

Hi George,

It's very exciting to hear that this work has already been starting,
thank you for letting me know. Your first approach is more inline with
my initial proposal, though that doesn't mean I necessarily prefer it.

I'm certainly interested having a more efficient implementation
available, but I wonder if this second approach isn't a premature
optimization. GHC rewrite rules provide a lot of power in this
department: both ByteString and Text are able to avoid the
intermediate String and build their representations from the buffers
GHC creates. In my own work in conduit, I was able (with some help
from Joachim Breitner[1]) to remove the intermediate list structure,
and I'd be surprised if it's not possible to do the same thing with
calls to `fromList`.

That said, I haven't actually tried implementing any of this in real
code, and it could be that there are serious performance advantages to
the second approach. I'm quite happy with either implementation making
it into GHC.

Michael

[1] http://www.haskell.org/pipermail/haskell-cafe/2012-April/100793.html


From apfelmus at quantentunnel.de  Mon Sep 24 15:46:55 2012
From: apfelmus at quantentunnel.de (Heinrich Apfelmus)
Date: Mon, 24 Sep 2012 15:46:55 +0200
Subject: [Haskell-cafe] Organizaing tests in Haskell
In-Reply-To: <20120923170051.GA11983@x200>
References: <201209231125.48198.jan.stolarek@p.lodz.pl>	<588054B2-F98F-4B0A-8B7A-3A8A0441B3A8@matthewwest.co.uk>	<20120923102806.GA8765@x200>
	 <20120923170051.GA11983@x200>
Message-ID: 

Simon Hengel wrote:
> On Sun, Sep 23, 2012 at 06:11:59PM +0200, Heinrich Apfelmus wrote:
>>
>> How do I access internal modules with  cabal test , though? Last
>> time I tried, I could not find a way to expose in the test section
>> of the cabal file.
> 
> It works, if you add the source directory to hs-source-dirs of the test
> suite (in contrast to depending on the library!), e.g.:
> 
>   hs-source-dirs: test, src
> 
> or
> 
>   hs-source-dirs: test, .
> 
> This still has the disadvantage, that the sources are compiled twice.
> But I'm not aware of a better way to do it.  If you mostly use GHCi for
> development, it's not a big issue.

I got it to work, thanks!

I also had to duplicate the dependency information, but that's alright.


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com



From apfelmus at quantentunnel.de  Mon Sep 24 15:57:11 2012
From: apfelmus at quantentunnel.de (Heinrich Apfelmus)
Date: Mon, 24 Sep 2012 15:57:11 +0200
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: <20120923153422.GA16107@sniper>
References: 	
	<20120923153422.GA16107@sniper>
Message-ID: 

Roman Cheplyaka wrote:
> * Heinrich Apfelmus  [2012-09-23 10:51:26+0200]
>> Unfortunately, making literals polymorphic does not always achieve
>> the desired effect of reducing syntax. In fact, they can instead
>> increase syntax! In other words, I would like to point out that there
>> is a trade-off involved: is it worth introducing a small syntactic
>> reduction at the cost of both a small additional conceptual
>> complexity and some syntactic enlargement elsewhere?
> 
> Can't you just disable the extension when you realise that it
> makes your life harder?

I thought so, too, but there is actually a "social" catch.

Namely, a library/DSL can be designed with that extension in mind and 
advocate its use. The [scotty][] library is an example for this.

In particular, the  RoutePattern  type is made an instance of  IsString 
  and the example code uses it extensively. If I want to disable the 
extension, I have to translate the example code first. When learning a 
library for the first time, this can be rather confusing.

   [scotty]: http://hackage.haskell.org/package/scotty

Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com



From byorgey at seas.upenn.edu  Mon Sep 24 15:59:32 2012
From: byorgey at seas.upenn.edu (Brent Yorgey)
Date: Mon, 24 Sep 2012 09:59:32 -0400
Subject: [Haskell-cafe] ANN: New wiki page and mailing list for
	combinatorics and Haskell
Message-ID: <20120924135932.GA31360@seas.upenn.edu>

Quite a while ago there was a mailing list thread where the idea was
brought up of creating a mailing list for those interested in
combinatorics in the setting of Haskell.

Well, I've finally gotten around to it.  If you're interested in
(probably extremely low-traffic) discussion and announcements relating
to doing combinatorics in Haskell (computing combinatorial/
number-theoretic functions; exhaustive or random generation of
combinatorial objects; type algebra; etc.), please join!  

  http://projects.haskell.org/cgi-bin/mailman/listinfo/combinatorics

There is also a wiki page for collecting information here:

  http://www.haskell.org/haskellwiki/Combinatorics

-Brent


From allbery.b at gmail.com  Mon Sep 24 16:44:47 2012
From: allbery.b at gmail.com (Brandon Allbery)
Date: Mon, 24 Sep 2012 10:44:47 -0400
Subject: [Haskell-cafe] Partial statical linking
In-Reply-To: 
References: 
	<1322726819-sup-1706@ezyang>
	<0284E8E8-CEED-4E06-AAF0-788B8CA900D5@gmail.com>
	
	
	
Message-ID: 

On Mon, Sep 24, 2012 at 7:42 AM, Jason Dusek  wrote:

> I am not sure why that happens -- libgcc.a wasn't explicitly
> asked for; but it stands to reason that one shouldn't specify
>

No, but it's required for anything that uses the C compiler (which in this
case would be glibc and any foreign libraries) --- it contains the
implementation of things like (long long) support on 32-bit platforms,
exception unwinding, and other compiler intrinsics.  You may not use them
but glibc does.

-- 
brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From qdunkan at gmail.com  Mon Sep 24 17:01:00 2012
From: qdunkan at gmail.com (Evan Laforge)
Date: Mon, 24 Sep 2012 15:01:00 +0000
Subject: [Haskell-cafe] Getting started with Shake
In-Reply-To: 
References: 
Message-ID: 

> With shake I'm not sure exactly how to get started.  Should I have a
> separate project where I create the build system for the webapp?  Or
> can I setup something similar to sbt?
>
> Also, how do I handle dependencies with shake?  cabal will pull in
> packages from hackage and do the needful, is there anything in shake
> to do the same?  If not, how is it normally done?

I have a Shake directory in the project toplevel.  It has Shakefile.hs
and various other utility modules.  A shell script called mkmk
rebuilds the shakefile: 'exec runghc Shake/Shakefile.hs "$@"
build/opt/shakefile', and I usually use 'mk', which is another shell
script: 'exec build/opt/shakefile "$@"'.  You could use runghc all the
time, but I have a large project and interpreting the shakefile is
noticeably slower.

For dependencies I have HsDeps and CcDeps modules which do the minimal
amount of parsing to pull out 'import qualified XYZ' or '#include
"something.h"' lines.  The hs link rule uses it to get the transitive
imports of a binary to 'need' them, and the *.hs.o rule uses it to get
the direct imports of the file it's compiling.  Same story for the
*.cc.o rule and C++ binaries.

There are extra wrinkles for CPP-using hs file and FFI using files
that depend on C wrappers, and multiple build modes (debug, opt,
profile, test) but that's the gist of it.

I don't have a cabal file, just an INSTALL file that I can copy paste
into cabal install.  In the future I'll probably have a cabal file
that doesn't actually compile, just gives deps and their versions, but
so far copy pasting a bunch of stuff into cabal install hasn't been a
big deal.


From rl at cse.unsw.edu.au  Mon Sep 24 17:50:45 2012
From: rl at cse.unsw.edu.au (Roman Leshchinskiy)
Date: Mon, 24 Sep 2012 16:50:45 +0100
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: 
References: 
Message-ID: <6c0898292c48912c6ab7b3c01f6e35c2.squirrel@webmail.cse.unsw.edu.au>

Michael Snoyman wrote:
>
> The simplest example I can think of is allowing easier usage of Vector:
>
>     [1, 2, 3] :: Vector Int
>
> In order to allow this, we could use a typeclass approach similar to
> how OverloadedStrings works:
>
>     class IsList a where
>         fromList :: [b] -> a b
>     instance IsList Vector where
>         fromList = V.fromList
>     foo :: Vector Int
>     foo = fromList [1, 2, 3]

I remember a similar discussion a few years ago. The question of whether
or not overloading list literals a good idea notwithstanding, the problem
with this is that fromList for vectors is highly inefficient. So if
something like this gets implemented and if vector/array literals are one
of the main motivations then I really hope there will be no lists
involved.

Roman





From simonpj at microsoft.com  Mon Sep 24 18:29:00 2012
From: simonpj at microsoft.com (Simon Peyton-Jones)
Date: Mon, 24 Sep 2012 16:29:00 +0000
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: 
References: 
Message-ID: <59543203684B2244980D7E4057D5FBC1379E726C@DB3EX14MBXC306.europe.corp.microsoft.com>

|  Many of us use the OverloadedStrings language extension on a regular
|  basis. It provides the ability to keep the ease-of-use of string
|  literal syntax, while getting the performance and correctness
|  advantages of specialized datatypes like ByteString and Text. I think
|  we can get the same kind of benefit by allowing another literal syntax
|  to be overloaded, namely lists.	

Interestingly, Achim Krause, George Giorgidze and Jeroen Weijers have been thinking about this very question.  They have most of an implementation too. I'm ccing them so they can post a status update.

Your email broadens the topic somewhat; I don't think we'd considered overloading for maps too, though I can see it makes sense.  I'd much prefer the type-family solution (with a single-parameter type class) to the fundep one, if we go that route.

This topic deserves its own page on the GHC wiki, if someone wants to start one.

If we can evolve a design consensus, I'm happy to incorporate the result in GHC.

Simon


|  -----Original Message-----
|  From: haskell-cafe-bounces at haskell.org [mailto:haskell-cafe-
|  bounces at haskell.org] On Behalf Of Michael Snoyman
|  Sent: 23 September 2012 05:07
|  To: Haskell Cafe
|  Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
|  
|  (Prettier formatting available at: https://gist.github.com/3761252)
|  
|  Many of us use the OverloadedStrings language extension on a regular
|  basis. It provides the ability to keep the ease-of-use of string
|  literal syntax, while getting the performance and correctness
|  advantages of specialized datatypes like ByteString and Text. I think
|  we can get the same kind of benefit by allowing another literal syntax
|  to be overloaded, namely lists.	
|  
|  ## Overly simple approach
|  
|  The simplest example I can think of is allowing easier usage of Vector:
|  
|      [1, 2, 3] :: Vector Int
|  
|  In order to allow this, we could use a typeclass approach similar to
|  how OverloadedStrings works:
|  
|      class IsList a where
|          fromList :: [b] -> a b
|      instance IsList Vector where
|          fromList = V.fromList
|      foo :: Vector Int
|      foo = fromList [1, 2, 3]
|  
|  ## Flaws
|  
|  However, such a proposal does not allow for constraints, e.g.:
|  
|      instance IsList Set where
|          fromList = Set.fromList
|  
|      No instance for (Ord b)
|        arising from a use of `Set.fromList'
|      In the expression: Set.fromList
|      In an equation for `fromList': fromList = Set.fromList
|      In the instance declaration for `IsList Set'
|  
|  Additionally, it provides for no means of creating instances for
|  datatypes like Map, where the contained value is not identical to the
|  value contained in the original list. In other words, what I'd like to
|  see is:
|  
|      [("foo", 1), ("bar", 2)] :: Map Text Int
|  
|  ## A little better: MPTC
|  
|  A simplistic approach to solve this would be to just use MultiParamTypeClasses:
|  
|      class IsList input output where
|          fromList :: [input] -> output
|      instance IsList a (Vector a) where
|          fromList = V.fromList
|      foo :: Vector Int
|      foo = fromList [1, 2, 3]
|  
|  Unfortunately, this will fail due to too much polymorphism:
|  
|      No instance for (IsList input0 (Vector Int))
|        arising from a use of `fromList'
|      Possible fix:
|        add an instance declaration for (IsList input0 (Vector Int))
|      In the expression: fromList [1, 2, 3]
|      In an equation for `foo': foo = fromList [1, 2, 3]
|  
|  This can be worked around by giving an explicit type signature on the
|  numbers in the list, but that's not a robust solution. In order to
|  solve this properly, I think we need either functional dependencies or
|  type families:
|  
|  ## Functional dependencies
|  
|      class IsList input output | output -> input where
|          fromList :: [input] -> output
|      instance IsList a (Vector a) where
|          fromList = V.fromList
|      instance Ord a => IsList a (Set a) where
|          fromList = Set.fromList
|      instance Ord k => IsList (k, v) (Map k v) where
|          fromList = Map.fromList
|  
|      foo :: Vector Int
|      foo = fromList [1, 2, 3]
|  
|      bar :: Set Int
|      bar = fromList [1, 2, 3]
|  
|      baz :: Map String Int
|      baz = fromList [("foo", 1), ("bar", 2)]
|  
|  ## Type families
|  
|      class IsList a where
|          type IsListInput a
|          fromList :: [IsListInput a] -> a
|      instance IsList (Vector a) where
|          type IsListInput (Vector a) = a
|          fromList = V.fromList
|      instance Ord a => IsList (Set a) where
|          type IsListInput (Set a) = a
|          fromList = Set.fromList
|      instance Ord k => IsList (Map k v) where
|          type IsListInput (Map k v) = (k, v)
|          fromList = Map.fromList
|  
|      foo :: Vector Int
|      foo = fromList [1, 2, 3]
|  
|      bar :: Set Int
|      bar = fromList [1, 2, 3]
|  
|      baz :: Map String Int
|      baz = fromList [("foo", 1), ("bar", 2)]
|  
|  ## Conclusion
|  
|  Consider most of this proposal to be a strawman: names and techniques
|  are completely up to debate. I'm fairly certain that our only two
|  choices to implement this extension is a useful way is fundeps and
|  type families, but perhaps there's another approach I'm missing. I
|  don't have any particular recommendation here, except to say that
|  fundeps is likely more well supported by other compilers.
|  
|  _______________________________________________
|  Haskell-Cafe mailing list
|  Haskell-Cafe at haskell.org
|  http://www.haskell.org/mailman/listinfo/haskell-cafe




From simonpj at microsoft.com  Mon Sep 24 19:19:07 2012
From: simonpj at microsoft.com (Simon Peyton-Jones)
Date: Mon, 24 Sep 2012 17:19:07 +0000
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: <6c0898292c48912c6ab7b3c01f6e35c2.squirrel@webmail.cse.unsw.edu.au>
References: 
	<6c0898292c48912c6ab7b3c01f6e35c2.squirrel@webmail.cse.unsw.edu.au>
Message-ID: <59543203684B2244980D7E4057D5FBC1379E7818@DB3EX14MBXC306.europe.corp.microsoft.com>

|  I remember a similar discussion a few years ago. The question of whether
|  or not overloading list literals a good idea notwithstanding, the problem
|  with this is that fromList for vectors is highly inefficient. So if
|  something like this gets implemented and if vector/array literals are one
|  of the main motivations then I really hope there will be no lists
|  involved.

Would you like to remind us why it is so inefficient?  Can't the vector construction be a fold over the list?  Ah... you need to know the *length* of the list, don't you?  So that you can allocate a suitably-sized vector.  Which of course we do for literal lists.

So what if fromList went
	fromList :: Int -> [b] -> a b
where the Int is the length of the list?

Simon



From claude at mathr.co.uk  Mon Sep 24 22:11:14 2012
From: claude at mathr.co.uk (Claude Heiland-Allen)
Date: Mon, 24 Sep 2012 21:11:14 +0100
Subject: [Haskell-cafe] [Haskell] Well-Typed and Skills Matter offer
 Haskell courses in London in October
In-Reply-To: 
References: 
	<50597EF4.3090904@mathr.co.uk> <505981CA.2010906@mathr.co.uk>
	
Message-ID: <5060BE62.70209@mathr.co.uk>

Hi Andres, list,

On 19/09/12 09:41, Andres L?h wrote:
>> Oops, I hit send too prematurely, sorry for the seeming bluntness (but it is
>> still a blunt message, can't apologize for that I suppose):
>
> No need to apologize. There's a need for informal meetings as much (or
> even more) as there is for courses and conferences.

Thank you.

> Regarding London, I know there's the
> Haskell Hoodlums meetup (http://www.meetup.com/hoodlums/)

Thanks, I wasn't aware of this one.  I have signed up.


Claude


From magicloud.magiclouds at gmail.com  Tue Sep 25 08:51:16 2012
From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds)
Date: Tue, 25 Sep 2012 14:51:16 +0800
Subject: [Haskell-cafe] How to take a minimum sub list that only contain
 certain number of elements of certain type?
Message-ID: 

Hi,
  For example, I have an array [0..]. Now I want to take a sub list
that starts from index 0, and only contain 4 odds, and is minimum
result. The answer should be [0, 1, 2, 3, 4, 5, 6, 7].
  How to do that? Combining lazy computing, I cannot figure out an
efficient algorithm.
-- 
???????
???????

And for G+, please use magiclouds#gmail.com.


From ivan.miljenovic at gmail.com  Tue Sep 25 09:11:51 2012
From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic)
Date: Tue, 25 Sep 2012 17:11:51 +1000
Subject: [Haskell-cafe] How to take a minimum sub list that only contain
 certain number of elements of certain type?
In-Reply-To: 
References: 
Message-ID: 

On 25 September 2012 16:51, Magicloud Magiclouds
 wrote:
> Hi,
>   For example, I have an array [0..]. Now I want to take a sub list
> that starts from index 0, and only contain 4 odds, and is minimum
> result. The answer should be [0, 1, 2, 3, 4, 5, 6, 7].

If you have listTest :: [a] -> Bool, then head . dropWhile (not .
listTest) . inits ?

>   How to do that? Combining lazy computing, I cannot figure out an
> efficient algorithm.
> --
> ???????
> ???????
>
> And for G+, please use magiclouds#gmail.com.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com


From mail at paulvisschers.net  Tue Sep 25 09:19:58 2012
From: mail at paulvisschers.net (Paul Visschers)
Date: Tue, 25 Sep 2012 09:19:58 +0200
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: <59543203684B2244980D7E4057D5FBC1379E7818@DB3EX14MBXC306.europe.corp.microsoft.com>
References: 
	<6c0898292c48912c6ab7b3c01f6e35c2.squirrel@webmail.cse.unsw.edu.au>
	<59543203684B2244980D7E4057D5FBC1379E7818@DB3EX14MBXC306.europe.corp.microsoft.com>
Message-ID: 

Would that also work for vectors that have their length in their type? And
while we are at it, how about overloaded tuples?

Paul

On Mon, Sep 24, 2012 at 7:19 PM, Simon Peyton-Jones
wrote:

> |  I remember a similar discussion a few years ago. The question of whether
> |  or not overloading list literals a good idea notwithstanding, the
> problem
> |  with this is that fromList for vectors is highly inefficient. So if
> |  something like this gets implemented and if vector/array literals are
> one
> |  of the main motivations then I really hope there will be no lists
> |  involved.
>
> Would you like to remind us why it is so inefficient?  Can't the vector
> construction be a fold over the list?  Ah... you need to know the *length*
> of the list, don't you?  So that you can allocate a suitably-sized vector.
>  Which of course we do for literal lists.
>
> So what if fromList went
>         fromList :: Int -> [b] -> a b
> where the Int is the length of the list?
>
> Simon
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From simonpj at microsoft.com  Tue Sep 25 10:01:06 2012
From: simonpj at microsoft.com (Simon Peyton-Jones)
Date: Tue, 25 Sep 2012 08:01:06 +0000
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: 
References: 
Message-ID: <59543203684B2244980D7E4057D5FBC1379E81E7@DB3EX14MBXC306.europe.corp.microsoft.com>

| Here at the University of T?bingen, I am co-supervising (together with
| Jeroen Weijers) a student project implementing the OverloadedLists
| extension for GHC. Achim Krause is the student who is working on the
| project. We took into consideration earlier discussions on this topic
| [1,2] before embarking on the project.
| 
| Achim has worked on two approaches.

Your second approach is this:

| [x,y,z] 
| 
| as
| 
| singleton x `mappend` singleton y `mappend` singleton z ;

This approach is not good for long literal lists, because you get tons of executable code where the user thought he was just defining a data  structure.  And long literal lists are an important use-case.

One other possibility is to use a variant of what GHC does for literal strings. Currently
	"foo"
turns into	
	unpackCString "foo"#
where "foo"# is a statically allocate C string, and the "unpackCString" unpacks it lazily.

Maybe we could make a literal [a,b.c] turn into
	unpack [a,b,c]#
where 
	[a,b,c]#
is a statically-allocated vector?  See http://hackage.haskell.org/trac/ghc/ticket/5218, which is stalled awaiting brain cycles from someone.

I'm maxed out at the moment.  I'd be very happy if you guys were able to make progress; I'm happy to advise.  Open a ticket, start a wiki page, etc!

Simon


From trupill at gmail.com  Tue Sep 25 10:02:47 2012
From: trupill at gmail.com (Alejandro Serrano Mena)
Date: Tue, 25 Sep 2012 10:02:47 +0200
Subject: [Haskell-cafe] How to take a minimum sub list that only contain
 certain number of elements of certain type?
In-Reply-To: 
References: 
	
Message-ID: 

It also comes to my mind that you can use something similar to regular
expressions and parsing, seeing your list as a word made of Int elements. I
think you can achieve it using Parsec or attoparsec.
One you define your basic combinators for 'odd', you can see your sublist
as the minimal part of the list matching
(even* odd)(even* odd)(even* odd)(even* odd)

2012/9/25 Ivan Lazar Miljenovic 

> On 25 September 2012 16:51, Magicloud Magiclouds
>  wrote:
> > Hi,
> >   For example, I have an array [0..]. Now I want to take a sub list
> > that starts from index 0, and only contain 4 odds, and is minimum
> > result. The answer should be [0, 1, 2, 3, 4, 5, 6, 7].
>
> If you have listTest :: [a] -> Bool, then head . dropWhile (not .
> listTest) . inits ?
>
> >   How to do that? Combining lazy computing, I cannot figure out an
> > efficient algorithm.
> > --
> > ???????
> > ???????
> >
> > And for G+, please use magiclouds#gmail.com.
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
> --
> Ivan Lazar Miljenovic
> Ivan.Miljenovic at gmail.com
> http://IvanMiljenovic.wordpress.com
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From rl at cse.unsw.edu.au  Tue Sep 25 10:25:31 2012
From: rl at cse.unsw.edu.au (Roman Leshchinskiy)
Date: Tue, 25 Sep 2012 09:25:31 +0100
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: <59543203684B2244980D7E4057D5FBC1379E7818@DB3EX14MBXC306.europe.corp.microsoft.com>
References: 
	<6c0898292c48912c6ab7b3c01f6e35c2.squirrel@webmail.cse.unsw.edu.au>
	<59543203684B2244980D7E4057D5FBC1379E7818@DB3EX14MBXC306.europe.corp.microsoft.com>
Message-ID: <4d40778c0d8b474832e438d55871d45b.squirrel@webmail.cse.unsw.edu.au>

Simon Peyton-Jones wrote:
> |  I remember a similar discussion a few years ago. The question of
> whether
> |  or not overloading list literals a good idea notwithstanding, the
> problem
> |  with this is that fromList for vectors is highly inefficient. So if
> |  something like this gets implemented and if vector/array literals are
> one
> |  of the main motivations then I really hope there will be no lists
> |  involved.
>
> Would you like to remind us why it is so inefficient?  Can't the vector
> construction be a fold over the list?  Ah... you need to know the *length*
> of the list, don't you?  So that you can allocate a suitably-sized vector.
>  Which of course we do for literal lists.
>
> So what if fromList went
> 	fromList :: Int -> [b] -> a b
> where the Int is the length of the list?

That's part of a problem. There are really two aspects to it. Firstly, a
naive list-based implementation would be a loop. But when I write ([x,y]
:: Vector Double) somewhere in an inner loop in my program, I *really*
don't want a loop with two iterations at runtime - I want just an
allocation and two writes. I suppose this could be solved by doing
something like this:

  {-# INLINE fromList #-}
  fromList [] = V.empty
  fromList [x] = V.singleton x
  fromList [x,y] = ...
  -- and so on up to 8? 16? 32?
  fromList xs = fromList_loop xs

But it's ugly and, more importantly, inlines a huge term for every literal.

The other problem is with literals where all values are known at compile
time. Suppose I have ([2.5,1.4] :: Vector Double) in an inner loop. Here,
I don't want a complicated CAF for the constant vector which would have to
be entered on every loop iteration. I'd much rather just have a pointer to
the actual data somewhere in memory and use that. This is more or less
what happens for strings at the moment, even though you have to use
rewrite rules to get at the pointer which, in my opinion, is neither ideal
nor really necessary. IMO, the "right" design shouldn't rely on rewrite
rules. Also, strings give you an Addr# whereas vector supports ByteArray#,
too.

Since enumerated literals have been mentioned in a different post, I'll
just mention that the Enum class as it is now can't support those
efficiently for arrays because there is no way to determine either the
length or the nth element of [x..y] in constant time. This would have to
be fixed.

Roman





From simonpj at microsoft.com  Tue Sep 25 10:31:44 2012
From: simonpj at microsoft.com (Simon Peyton-Jones)
Date: Tue, 25 Sep 2012 08:31:44 +0000
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: <4d40778c0d8b474832e438d55871d45b.squirrel@webmail.cse.unsw.edu.au>
References: 
	<6c0898292c48912c6ab7b3c01f6e35c2.squirrel@webmail.cse.unsw.edu.au>
	<59543203684B2244980D7E4057D5FBC1379E7818@DB3EX14MBXC306.europe.corp.microsoft.com>
	<4d40778c0d8b474832e438d55871d45b.squirrel@webmail.cse.unsw.edu.au>
Message-ID: <59543203684B2244980D7E4057D5FBC1379E8419@DB3EX14MBXC306.europe.corp.microsoft.com>


| pointer to the actual data somewhere in memory and use that. This is
| more or less what happens for strings at the moment, even though you
| have to use rewrite rules to get at the pointer which, in my opinion, is
| neither ideal nor really necessary. IMO, the "right" design shouldn't
| rely on rewrite rules. Also, strings give you an Addr# whereas vector
| supports ByteArray#, too.

If it's not necessary, I wonder if you have an idea for the "right" design?  

I find it a lot easier to see what is wrong with the current situation than to think of solutions.

Simon



From alexey.skladnoy at gmail.com  Tue Sep 25 10:49:53 2012
From: alexey.skladnoy at gmail.com (Aleksey Khudyakov)
Date: Tue, 25 Sep 2012 12:49:53 +0400
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: <4d40778c0d8b474832e438d55871d45b.squirrel@webmail.cse.unsw.edu.au>
References: 
	<6c0898292c48912c6ab7b3c01f6e35c2.squirrel@webmail.cse.unsw.edu.au>
	<59543203684B2244980D7E4057D5FBC1379E7818@DB3EX14MBXC306.europe.corp.microsoft.com>
	<4d40778c0d8b474832e438d55871d45b.squirrel@webmail.cse.unsw.edu.au>
Message-ID: 

> That's part of a problem. There are really two aspects to it. Firstly, a
> naive list-based implementation would be a loop. But when I write ([x,y]
> :: Vector Double) somewhere in an inner loop in my program, I *really*
> don't want a loop with two iterations at runtime - I want just an
> allocation and two writes. I suppose this could be solved by doing
> something like this:
>
Some time ago I played with function fromList and rewrite rules.
For statically known lists it's possible to rewrite

fromList [a,b,c] ? cons a $ cons b $ cons c $ empty

Latter is compiled down to single allocation and three writes.


From rl at cse.unsw.edu.au  Tue Sep 25 10:51:53 2012
From: rl at cse.unsw.edu.au (Roman Leshchinskiy)
Date: Tue, 25 Sep 2012 09:51:53 +0100
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: <59543203684B2244980D7E4057D5FBC1379E8419@DB3EX14MBXC306.europe.corp.microsoft.com>
References: 
	<6c0898292c48912c6ab7b3c01f6e35c2.squirrel@webmail.cse.unsw.edu.au>
	<59543203684B2244980D7E4057D5FBC1379E7818@DB3EX14MBXC306.europe.corp.microsoft.com>
	<4d40778c0d8b474832e438d55871d45b.squirrel@webmail.cse.unsw.edu.au>
	<59543203684B2244980D7E4057D5FBC1379E8419@DB3EX14MBXC306.europe.corp.microsoft.com>
Message-ID: 

Simon Peyton-Jones wrote:
>
> | pointer to the actual data somewhere in memory and use that. This is
> | more or less what happens for strings at the moment, even though you
> | have to use rewrite rules to get at the pointer which, in my opinion, is
> | neither ideal nor really necessary. IMO, the "right" design shouldn't
> | rely on rewrite rules. Also, strings give you an Addr# whereas vector
> | supports ByteArray#, too.
>
> If it's not necessary, I wonder if you have an idea for the "right"
> design?

For strings, we could have something like this:

data StringPtr

stringFromStringPtr :: StringPtr -> Int -> String
unsafeStringPtrToPtr :: StringPtr -> Ptr CChar

class IsString a where
  fromString :: String -> a
  fromStringPtr :: StringPtr -> Int -> a
  fromStringPtr p n = fromString $ stringFromStringPtr p n

"abc" would then desugar to fromStringPtr (address of "abc") 3. Note that
we couldn't just use Ptr CChar instead of StringPtr because stringFromPtr
would only be safe if the data that the pointer references never changes.

It's much trickier for general-purpose arrays. It's also much trickier to
support both Ptr and ByteArray. I'd have to think about how to do that.

Roman





From jon.fairbairn at cl.cam.ac.uk  Tue Sep 25 11:16:52 2012
From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn)
Date: Tue, 25 Sep 2012 10:16:52 +0100
Subject: [Haskell-cafe] How to take a minimum sub list that only contain
	certain number of elements of certain type?
References: 
Message-ID: 

Magicloud Magiclouds  writes:

> Hi,
>   For example, I have an array [0..]. Now I want to take a sub list
> that starts from index 0, and only contain 4 odds, and is minimum
> result. The answer should be [0, 1, 2, 3, 4, 5, 6, 7].
>   How to do that? Combining lazy computing, I cannot figure out an
> efficient algorithm.

Does

f bound odds_so_far [] = []
f bound odds_so_far (x:xs)
 | odds_so_far == bound = []
 | otherwise = x : f bound (odds_so_far + if odd x then 1 else 0) xs

required_funciton = f 4 0

meet your criteria, or am I missing something?

-- 
J?n Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk




From agocorona at gmail.com  Tue Sep 25 13:08:19 2012
From: agocorona at gmail.com (Alberto G. Corona )
Date: Tue, 25 Sep 2012 13:08:19 +0200
Subject: [Haskell-cafe] Fwd: [Haskell] ANNOUNCE: MFlow-0.1.5
In-Reply-To: 
References: 
	
	
	
	
	
	
	
Message-ID: 

Hi,

This is an difficult problem in which the design principles of MFlow can
help to creare a solution amazingly easily.

I forward this message from, Web-devel because I think that it may be of
interest

A Web app. that creates Haskel computations from form responses. Store
them, retrieve and execute them


http://haskell-web.blogspot.com.es/2012/09/a.html


Alberto

2012/9/18 Alberto G. Corona 
>
> However if in a tab out of sync the user press refresh, the tab will
refresh to the current state.
> I took care not to try to synchronize back as a consequence of a page
that is in a  forward state in one tab, as a consequence of navigating back
in other tab.  However I may have not considered all the edge extreme
cases.
>
> There is a back detection primitive "goingBack" that allow the programmer
to control the back behaviour in some special cases.
>
> For example if i want to step over  a menu and present a default page,
But if when the user go back i want to present the menu, I can detect this
condition and present this menu, that did not appeared in a normal
navigation:
>
> This code sets and get a default option  in the menu, so the menu is not
shown again in the navigation, except in the case that the user press the
back button. Otherwise, the menu would be never accessible.
>
> However this is very specialized. normally the back button detection is
not necessary. In a persistent flow even this default entry option would be
completely automatic, since the process would restar at the last page
visited. No setting is necessary.
>
> menu= do
>        mop <- getGoStraighTo
>        back <- goingBack
>        case (mop,back) of
>         (Just goop,False) -> goop
>         _ -> do
>                r <- ask option1 <|> option2
>                case r of
>                 op1 -> setGoStraighTo (Just goop1) >> goop1
>                 op2 -> setGoStraighTo (Just goop2) >> goop2
>
>
>
>
>
> 2012/9/18 Alberto G. Corona 
>>
>> Hi Jake,
>> right, it depends on the identification of the session:
>>
>> iAll the tabs share the same state because they share the same cookies.
so if in one tab the use continue the interaction then the other tabs are
out of sync. If the user goes to these other tabs and press any widget, the
application will  synchronize back to this page.
>>
>>
>> This happens also if the user is logged in different computers.
>>
>> Alberto.
>>
>> 2012/9/18 Jake McArthur 
>>>
>>> Actually, I meant users that spawn multiple tabs from a single root
>>> session. You mentioned that you have some special support for the back
>>> button. What happens if I open a couple new tabs in which I may or may
>>> not go forward and backward. Do they all share the same state?
>>> Different states (how?)? Partially shared states?
>>>
>>> On Tue, Sep 18, 2012 at 12:33 PM, Alberto G. Corona 
wrote:
>>> > Oh,  I?m stupid. You mean web pages with multiple tabs....
>>> >
>>> >  I have not tested it. but each tab can be handled easily by a
different
>>> > server process.. or it can be handled in a single server process,
like in a
>>> > menu. For example, this code present different options, and the
process
>>> > renders different things depending on the response.
>>> >
>>> > The last option is a link to a different process, while the others(
wlinks)
>>> > are links that return back to the same process.
>>> > The operator <|> is the applicative operator.  a breakline is
prepended to
>>> > each link:
>>> >
>>> > data Ops= Ints | Strings | Actions | Ajax | Opt
deriving(Typeable,Read,
>>> > Show)
>>> >
>>> >  mainf=   do
>>> >         r <- ask $   wlink Ints (bold << "increase an Int")
>>> >                 <|>  br ++> wlink Strings (bold << "increase a
String")
>>> >                 <|>  br ++> wlink Actions (bold << "Example of a
string
>>> > widget with an action")
>>> >                 <|>  br ++> wlink Ajax (bold << "Simple AJAX example")
>>> >                 <|>  br ++> wlink Opt (bold << "select options")
>>> >                 <++ (br +++ linkShop) -- this is an ordinary XHtml
link
>>> >
>>> >         case r of
>>> >           Ints    ->  clickn 0
>>> >           Strings ->  clicks "1"
>>> >           Actions ->  actions 1
>>> >           Ajax    ->  ajaxsample
>>> >           Opt     ->  options
>>> >         mainf
>>> >      where
>>> >      linkShop= toHtml $ hotlink  "shop" << "shopping"
>>> >
>>> > .
>>> > Alberto
>>> >
>>> > 2012/9/18 Alberto G. Corona :
>>> >
>>> >> Hi Jake
>>> >>
>>> >> I don?t know what you mean with multiple tabs. The user management is
>>> >> simple, anonymous clients are identified with  a cookie. if the user
>>> >> is logged (MFlow has widgets for logging-validation) the user is the
>>> >> identifier.
>>> >>
>>> >> The state of a process is associated to the client identifier and to
>>> >> the path invoked in the url requested.
>>> >>
>>> >> I don?t know if this answer your question....
>>> >>
>>> >> Alberto
>>> >>
>>> >> 2012/9/18 Jake McArthur :
>>> >>> This sounds really cool.
>>> >>>
>>> >>> How do you handle users having multiple tabs?
>>> >>>
>>> >>> On Tue, Sep 18, 2012 at 11:26 AM, Alberto G. Corona <
agocorona at gmail.com>
>>> >>> wrote:
>>> >>>> Hi haskellers and specially the web developers.
>>> >>>>
>>> >>>> http://hackage.haskell.org/package/MFlow-0.1.5.3
>>> >>>>
>>> >>>> MFlow is a is a Web framework with some unique, and I mean unique,
>>> >>>> characteristics that I find exciting:
>>> >>>>
>>> >>>> - It is a Web application server that start and restart on-demand
>>> >>>> stateful web server processes (not request.-response)
>>> >>>>   This means that all the page navigation can be coded in a single
>>> >>>> procedure. This increases readability of the programmer code. I
woul
>>> >>>> call it
>>> >>>> a anti-node.js.  Buit usual request-response (stateless) server
>>> >>>> processes are also allowed
>>> >>>>
>>> >>>> - When the process is invoqued as result of an URL request, the Web
>>> >>>> app server not only restart the process but also recover its
execution
>>> >>>> state. The enclosing Workflow monad provides the thread state
>>> >>>> persistence. There are state timeouts and process timeouts defined
by
>>> >>>> the programmer. Processes with no persistent state (transient) are
>>> >>>> possible.
>>> >>>>
>>> >>>> -The user interface is made of widgets. They are  formlets with
added
>>> >>>> formatting,   attributes, validations, modifiers and callbacks,
that
>>> >>>> are composable, so the pieces are reusable and return type safe
>>> >>>> responses to the calling process. Even the links are part of
widgets
>>> >>>> and return back type safe inputs at compile time to the calling
server
>>> >>>> process. Tho glue these components, ordinary applicative
combinators
>>> >>>> and other extra combinators are used.
>>> >>>>
>>> >>>> - The widgets and the communication don?t make assumptions about
the
>>> >>>> architecture, so it can be adapted to non-web environments. This
>>> >>>> versions has interface for WAI-warp, Hack, Text.XHtml (xhtml) , and
>>> >>>> Haskell Server Pages.
>>> >>>>
>>> >>>> -The widget rendering can be converted to ByteStrings automatically
>>> >>>> with special combinators. A mix of widgets with different formats
can
>>> >>>> be combined in the same source file. For example Text.Html and HSP
>>> >>>> (Haskell server pages)
>>> >>>>
>>> >>>> -These widgets can be cached, to avoid widget rendering on every
>>> >>>> interaction.
>>> >>>>
>>> >>>> -To handle the back button, and because the processes are stateful,
>>> >>>> they can run backwards until the response match. This is
transparent
>>> >>>> for the programmer, thanks to the embedded FlowM monad.
>>> >>>>
>>> >>>> -All the code is in pure Haskell. No deployment, special scripts,
>>> >>>> formats etc are necessary.
>>> >>>>
>>> >>>> -Besides automatic state persistence, TCache provides transactions
and
>>> >>>> user data persistence, that can be configured for SQL databases.
>>> >>>> Default persistence in files permit very rapid prototyping. Just
code
>>> >>>> and run it with runghc.
>>> >>>>
>>> >>>> -Has AJAX support
>>> >>>>
>>> >>>> All of this sounds very complicated, but really it is simple!.
Most of
>>> >>>> these things are transparent. The resulting code is quite readable
and
>>> >>>> has very little plumbing!
>>> >>>>
>>> >>>> There is a non trivial example that some of these functionalities
>>> >>>> embedded here that you can run:
>>> >>>>
>>> >>>>
>>> >>>>
http://hackage.haskell.org/packages/archive/MFlow/0.1.5.3/doc/html/MFlow-Forms.html
>>> >>>>
>>> >>>> Take a look and tell me your opinion.  I hope that you find it as
>>> >>>> exciting as me.
>>> >>>>
>>> >>>>  I?m looking for people  to collaborate in the development of
MFlow.
>>> >>>>
>>> >>>> Although still it is experimental, it is being used in at least one
>>> >>>> future commercial project. So I have te commitment to continue its
>>> >>>> development. There are many examples in the documentation and in
the
>>> >>>> package.
>>> >>>>
>>> >>>> Alberto
>>> >>>>
>>> >>>> _______________________________________________
>>> >>>> Haskell mailing list
>>> >>>> Haskell at haskell.org
>>> >>>> http://www.haskell.org/mailman/listinfo/haskell
>>> >
>>> >
>>> >
>>> > _______________________________________________
>>> > Haskell-Cafe mailing list
>>> > Haskell-Cafe at haskell.org
>>> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>>> >
>>
>>
>



--
Alberto.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From shawjef3 at gmail.com  Tue Sep 25 16:58:19 2012
From: shawjef3 at gmail.com (Jeff Shaw)
Date: Tue, 25 Sep 2012 10:58:19 -0400
Subject: [Haskell-cafe] in the vector library, why define unbox tuples > 2?
Message-ID: <5061C68B.9020807@gmail.com>

I'm looking at storing a data type with 7 fields in an unboxed vector, 
which means that I'll have to use GenUnboxTuple to create an instance 
for Unbox (a,b,c,d,e,f,g), but I was thinking that another solution is 
to use "instance (Unbox a, Unbox b) => Unbox (a,b)" recursively to 
create "instance Unbox (a,(b,(c,(d,(e,(f,g))))))". Is there any reason I 
shouldn't say something like,

import qualified Data.Vector.Unboxed as Vector

data X = X Int Int Int Int Int Int Int

toTuple (X a b c d e f g) = (a,(b,(c,(d,(e,(f,g))))))

toVector = Vector.fromList . map toTuple

I guess I'm wondering if there is a technical reason why I should use an 
explicit Unbox instance for 7-tuples, or if it's just a convenience to 
have Unbox defined for tuples > 2?

Thanks,
Jeff


From ndmitchell at gmail.com  Tue Sep 25 18:02:09 2012
From: ndmitchell at gmail.com (Neil Mitchell)
Date: Tue, 25 Sep 2012 17:02:09 +0100
Subject: [Haskell-cafe] [Haskell] Well-Typed and Skills Matter offer
 Haskell courses in London in October
In-Reply-To: <5060BE62.70209@mathr.co.uk>
References: 
	<50597EF4.3090904@mathr.co.uk> <505981CA.2010906@mathr.co.uk>
	
	<5060BE62.70209@mathr.co.uk>
Message-ID: 

Hi Claude,

I have a promo code which gives ?50 off to make the Haskell Exchange
?175. HASKELLX-2012-TE1.

Note that this cost isn't profiteering - unfortunately running a
conference (just getting a venue) is expensive.

There will probably be some social aspect afterwards, I'll certainly
go to a pub if anyone wants.

I would love to see London HUG revived, I know people have tried
(including in the very recent past, a few months ago), but as yet no
one has managed to get any meetings going. Perhaps soon though.

Hoodlums is a great event, more teaching and less talk based, but very
well run and I highly recommend it!

Thanks, Neil

On Mon, Sep 24, 2012 at 9:11 PM, Claude Heiland-Allen
 wrote:
> Hi Andres, list,
>
>
> On 19/09/12 09:41, Andres L?h wrote:
>>>
>>> Oops, I hit send too prematurely, sorry for the seeming bluntness (but it
>>> is
>>> still a blunt message, can't apologize for that I suppose):
>>
>>
>> No need to apologize. There's a need for informal meetings as much (or
>> even more) as there is for courses and conferences.
>
>
> Thank you.
>
>
>> Regarding London, I know there's the
>> Haskell Hoodlums meetup (http://www.meetup.com/hoodlums/)
>
>
> Thanks, I wasn't aware of this one.  I have signed up.
>
>
> Claude
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


From apfelmus at quantentunnel.de  Tue Sep 25 18:21:24 2012
From: apfelmus at quantentunnel.de (Heinrich Apfelmus)
Date: Tue, 25 Sep 2012 18:21:24 +0200
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: 
References: 			
	
Message-ID: 

Michael Snoyman wrote:
> 
> Note that I wasn't necessarily advocating such a pragma. And a lot of
> my XML code actually *does* use two IsString instances at the same
> time, e.g.:
> 
>     Element ("img" :: Name) (singleton ("href" :: Name) ("foo.png" ::
> Text)) [NodeComment ("No content inside an image" :: Text)]

In this particular case, would it make sense to use smart constructors 
instead?

The idea is that you can put the polymorphism in two places: either make 
the "output" polymorphic, or make the "input" polymorphic. The latter 
would correspond to a type

    element :: (IsString name, IsString s, IsMap map)
        => name -> map name s -> [Element]
    element name map = Element (toName name) (toMap map)

One benefit would be that the function will accept any list as a map, 
not just list literals.


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com



From bos at serpentine.com  Tue Sep 25 19:17:59 2012
From: bos at serpentine.com (Bryan O'Sullivan)
Date: Tue, 25 Sep 2012 10:17:59 -0700
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: 
References: 
Message-ID: 

On Mon, Sep 24, 2012 at 5:53 AM, George Giorgidze wrote:

> Our second approach to OverloadedLists is to avoid the construction of
> lists altogether. By typechecking and desugaring lists like
>
> [] ; [x,y,z] ;  ['a' .. 'z'] ;
>
> as
>
> mempty ; singleton x `mappend` singleton y `mappend` singleton z ;
> genericEnumFromTo 'a' 'z' ;
>

This is very interesting.

As Michael mentions later, we already have mechanisms in place to work
around the creation of constant strings for the Text and ByteString types,
and they rely on a combination of GHC rewrite rules and knowledge about the
internal representation of constant strings used by GHC. We are fortunate
that GHC uses a very efficient representation to store constant strings, so
doing the translation is efficient.

Constant lists are another story entirely (for good reason); the generated
object files are bloated and poorly laid out, when for simple types
(integers and whatnot), I'd really like to see a packed array in the .data
section.

I would be interested to see if an approach that avoids list construction
can also aim to achieve a more efficient object file layout, with the
implied goal being to make fast translation to the runtime representation
easily achievable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From rishabh11 at live.com  Tue Sep 25 19:42:26 2012
From: rishabh11 at live.com (Rishabh Jain)
Date: Tue, 25 Sep 2012 23:12:26 +0530
Subject: [Haskell-cafe] How to take a minimum sub list that only contain
 certain number of elements of certain type?
In-Reply-To: 
References: ,
	
Message-ID: 

f x 0 = []f (x:xs) y | x `mod` 2 == 0 = x : (f xs y) | otherwise = x : (f xs (y-1))
> f [0..] 4> [0,1,2,3,4,5,6,7]
> To: haskell-cafe at haskell.org
> From: jon.fairbairn at cl.cam.ac.uk
> Date: Tue, 25 Sep 2012 10:16:52 +0100
> Subject: Re: [Haskell-cafe] How to take a minimum sub list that only contain	certain number of elements of certain type?
> 
> Magicloud Magiclouds  writes:
> 
> > Hi,
> >   For example, I have an array [0..]. Now I want to take a sub list
> > that starts from index 0, and only contain 4 odds, and is minimum
> > result. The answer should be [0, 1, 2, 3, 4, 5, 6, 7].
> >   How to do that? Combining lazy computing, I cannot figure out an
> > efficient algorithm.
> 
> Does
> 
> f bound odds_so_far [] = []
> f bound odds_so_far (x:xs)
>  | odds_so_far == bound = []
>  | otherwise = x : f bound (odds_so_far + if odd x then 1 else 0) xs
> 
> required_funciton = f 4 0
> 
> meet your criteria, or am I missing something?
> 
> -- 
> J?n Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk
> 
> 
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From gwern0 at gmail.com  Tue Sep 25 19:56:48 2012
From: gwern0 at gmail.com (Gwern Branwen)
Date: Tue, 25 Sep 2012 13:56:48 -0400
Subject: [Haskell-cafe] How to take a minimum sub list that only contain
 certain number of elements of certain type?
In-Reply-To: 
References: 
	
	
Message-ID: 

On Tue, Sep 25, 2012 at 1:42 PM, Rishabh Jain  wrote:
> f x 0 = []
> f (x:xs) y | x `mod` 2 == 0 = x : (f xs y) | otherwise = x : (f xs (y-1))
>
>> f [0..] 4
>> [0,1,2,3,4,5,6,7]

Tsk, tsk. So ugly. How's this:

> let f x = take x . filter odd
>
> f 4 [0..]
~> [1, 3, 5, 7]

Notice that 0 is excluded, since 0 is *even*, not odd:
http://en.wikipedia.org/wiki/Parity_of_zero
If this is a serious problem, one can always just prepend zero:

> 0 : f 4 [1..]
~> [0, 1, 3, 5, 7]

-- 
gwern
http://www.gwern.net


From sjoerd at w3future.com  Tue Sep 25 19:57:32 2012
From: sjoerd at w3future.com (Sjoerd Visscher)
Date: Tue, 25 Sep 2012 19:57:32 +0200
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: <59543203684B2244980D7E4057D5FBC1379E81E7@DB3EX14MBXC306.europe.corp.microsoft.com>
References: 
	<59543203684B2244980D7E4057D5FBC1379E81E7@DB3EX14MBXC306.europe.corp.microsoft.com>
Message-ID: <075A3427-67C1-497F-8226-ECCB53039E0B@w3future.com>

So, in order not to have to rely on rewrite rules, would it be a good idea to add unpackCString to the IsString class?

import GHC.Base (unpackCString#, Addr#)

class IsString a where
    fromString :: String -> a
    unpackCString :: Addr# -> a
    unpackCString addr = fromString (unpackCString# addr)

For lists something similar could probably be done.

Sjoerd

On Sep 25, 2012, at 10:01 AM, Simon Peyton-Jones  wrote:

> | Here at the University of T?bingen, I am co-supervising (together with
> | Jeroen Weijers) a student project implementing the OverloadedLists
> | extension for GHC. Achim Krause is the student who is working on the
> | project. We took into consideration earlier discussions on this topic
> | [1,2] before embarking on the project.
> | 
> | Achim has worked on two approaches.
> 
> Your second approach is this:
> 
> | [x,y,z] 
> | 
> | as
> | 
> | singleton x `mappend` singleton y `mappend` singleton z ;
> 
> This approach is not good for long literal lists, because you get tons of executable code where the user thought he was just defining a data  structure.  And long literal lists are an important use-case.
> 
> One other possibility is to use a variant of what GHC does for literal strings. Currently
> 	"foo"
> turns into	
> 	unpackCString "foo"#
> where "foo"# is a statically allocate C string, and the "unpackCString" unpacks it lazily.
> 
> Maybe we could make a literal [a,b.c] turn into
> 	unpack [a,b,c]#
> where 
> 	[a,b,c]#
> is a statically-allocated vector?  See http://hackage.haskell.org/trac/ghc/ticket/5218, which is stalled awaiting brain cycles from someone.
> 
> I'm maxed out at the moment.  I'd be very happy if you guys were able to make progress; I'm happy to advise.  Open a ticket, start a wiki page, etc!
> 
> Simon
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



From jays at panix.com  Tue Sep 25 21:54:44 2012
From: jays at panix.com (Jay Sulzberger)
Date: Tue, 25 Sep 2012 15:54:44 -0400 (EDT)
Subject: [Haskell-cafe] [Haskell] ANN: HERMIT for GHC 7.6
In-Reply-To: 
References: 
Message-ID: 

[Note that original post was on the Haskell list, and not the
Haskell-cafe list.]

On Tue, 25 Sep 2012, Andrew Farmer  wrote:

> A new version of HERMIT (0.1.2.0) that is compatible with GHC 7.6 is now
> available on hackage. This release has essentially the same functionality
> as the 7.4-only pre-alpha release made before ICFP 2012.
>
> HERMIT (Haskell Equational Reasoning Model-to-Implementation Tunnel) is a
> plugin for GHC that provides an interactive interface for applying
> transformations directly to GHC's internal intermediate language, Core.
> This plugin is part of a larger HERMIT toolkit, which is being developed at
> the University of Kansas with the aims of supporting equational reasoning
> and allowing custom optimizations to be applied without modifying either
> GHC or the Haskell source code.
>
> Introduction to HERMIT via Neil Sculthorpe's Haskell Symposium 2012 talk:
>
> http://www.youtube.com/watch?v=x2QH3jJCJso
>
> Example transformations can be found in the examples folder, contained in
> the cabal source package.
>
> Hackage: http://hackage.haskell.org/package/hermit
> Github (for bug reports): https://github.com/ku-fpg/hermit
>
> Andrew Farmer

Thank you and all the HERMIT Team for this!

Does the HERMIT system provide an executable Haskell Core, that
is, we can get an ordinary text file which can be executed by
some version of GHC+HERMIT?

oo--JS.


From ivan.miljenovic at gmail.com  Tue Sep 25 23:24:32 2012
From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic)
Date: Wed, 26 Sep 2012 07:24:32 +1000
Subject: [Haskell-cafe] How to take a minimum sub list that only contain
 certain number of elements of certain type?
In-Reply-To: 
References: 
	
	
	
Message-ID: 

On 26 September 2012 03:56, Gwern Branwen  wrote:
> On Tue, Sep 25, 2012 at 1:42 PM, Rishabh Jain  wrote:
>> f x 0 = []
>> f (x:xs) y | x `mod` 2 == 0 = x : (f xs y) | otherwise = x : (f xs (y-1))
>>
>>> f [0..] 4
>>> [0,1,2,3,4,5,6,7]
>
> Tsk, tsk. So ugly. How's this:
>
>> let f x = take x . filter odd
>>
>> f 4 [0..]
> ~> [1, 3, 5, 7]
>
> Notice that 0 is excluded, since 0 is *even*, not odd:
> http://en.wikipedia.org/wiki/Parity_of_zero
> If this is a serious problem, one can always just prepend zero:
>
>> 0 : f 4 [1..]
> ~> [0, 1, 3, 5, 7]

Except that your solution is incorrect, as Magicloud wanted the
smallest _prefix_ that contained four odd numbers...

>
> --
> gwern
> http://www.gwern.net
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
http://IvanMiljenovic.wordpress.com


From ok at cs.otago.ac.nz  Wed Sep 26 00:09:03 2012
From: ok at cs.otago.ac.nz (Richard O'Keefe)
Date: Wed, 26 Sep 2012 10:09:03 +1200
Subject: [Haskell-cafe] How to take a minimum sub list that only contain
	certain number of elements of certain type?
In-Reply-To: 
References: 
	
	
Message-ID: <61DC6BC4-47F5-4755-A657-7D9E802C39BE@cs.otago.ac.nz>

> 2012/9/25 Ivan Lazar Miljenovic 
> On 25 September 2012 16:51, Magicloud Magiclouds
>  wrote:
> > Hi,
> >   For example, I have an array [0..]. Now I want to take a sub list
> > that starts from index 0, and only contain 4 odds, and is minimum
> > result. The answer should be [0, 1, 2, 3, 4, 5, 6, 7].

What do you actually *mean*?
When you say you "have an array", but actually display a *list*,
do you really mean you have something fitting into Data.Array,
or do you really mean you have a list?

When you say "sub list" do you mean a *slice* (a contiguous
chunk) or a *subsequence* (elements preserve their order but
there may be gaps).  Or looking at your example, do you mean
a *prefix* (n `take` xs for some n)?

When you say "odds" I presume you mean odd integer, although
the even/odd concept applies to Gaussian integers too (m+ni
is even if it is divisible by 1+i, which turns out to be
equivalent to m+ni being even (odd) iff m and n have the
same (different) parity).

When you say "is minimum result", what does that mean?  Does
it mean the sum of the elements is minimal?  (If you consider
the list [1,3,5,7,-2,-4,-6,-8,-10,...] it is clear that a
minimum result in that sense could be infinitely long.)

Let's take just one interpretation:
 - the "array" is a list
 - whose elements are Integers
 - the result must be a prefix of the input
 - which contains four odd Integers
 - and is otherwise as short as possible.

We'll generalise `take`: it will have an integer n,
a predicate p, and a list xs.

ptake :: Int -> (a -> Bool) -> [a] -> [a]

ptake n p (x:xs) | n > 0 = x : ptake (if p x then n-1 else n) p xs
ptake _ _ _              = []

answer :: [Integer] -> [Integer]

answer xs = ptake 4 odd xs

Now this is pretty trivial (it's _exactly_ `take` except for
only counting elements where p is true), so that interpretation
of the problem cannot be the right one.



From ekirpichov at gmail.com  Wed Sep 26 01:52:14 2012
From: ekirpichov at gmail.com (Eugene Kirpichov)
Date: Tue, 25 Sep 2012 16:52:14 -0700
Subject: [Haskell-cafe] 64-bit vs 32-bit haskell platform on Mac: misleading
 notice on Platform website?
Message-ID: 

Hi,

I installed Haskell Platform 32-bit on a fresh 64-bit mac, because the
page http://www.haskell.org/platform/mac.html says: "Pick the 32-bit
vesion, unless you have a specific reason to use the 64-bit version.
The 32-bit one is slightly faster for most programs."

Then, during the installation of a package, the following happeed:

Loading package cairo-0.12.3.1 ... : can't load .so/.DLL
for: /opt/local/lib/libz.dylib (dlopen(/opt/local/lib/libz.dylib, 9):
no suitable image found. ?Did find:
 ? ? ? ?/opt/local/lib/libz.dylib: mach-o, but wrong architecture)

That libz.dylib is a 64-bit library and it can't be used by 32-bit
Haskell platform.

QUESTION: It seems to me that most people, at least most who care
about "slightly faster" programs, are likely to run into something
like this - using native 64-bit libraries. Compatibility exists only
in the opposite direction. Wouldn't it be appropriate to remove this
notice and ask people to use the 64-bit version unless they have a
specific reason not to?


-- 
Eugene Kirpichov
http://www.linkedin.com/in/eugenekirpichov
We're hiring! http://tinyurl.com/mirantis-openstack-engineer


From ok at cs.otago.ac.nz  Wed Sep 26 02:17:56 2012
From: ok at cs.otago.ac.nz (Richard O'Keefe)
Date: Wed, 26 Sep 2012 12:17:56 +1200
Subject: [Haskell-cafe] How to take a minimum sub list that only contain
	certain number of elements of certain type?
In-Reply-To: 
References: 
	
	
	
Message-ID: <78539F80-375B-4EF9-B05A-DE6B91E15A11@cs.otago.ac.nz>


On 26/09/2012, at 5:56 AM, Gwern Branwen wrote:

> On Tue, Sep 25, 2012 at 1:42 PM, Rishabh Jain  wrote:
>> f x 0 = []
>> f (x:xs) y | x `mod` 2 == 0 = x : (f xs y) | otherwise = x : (f xs (y-1))
>> 
>>> f [0..] 4
>>> [0,1,2,3,4,5,6,7]
> 
> Tsk, tsk. So ugly. How's this:
> 
>> let f x = take x . filter odd

Wrong.  The original poster gave an explicit example
in which even elements were *retained* in the output,
they just weren't *counted*.



From gwern0 at gmail.com  Wed Sep 26 02:28:19 2012
From: gwern0 at gmail.com (Gwern Branwen)
Date: Tue, 25 Sep 2012 20:28:19 -0400
Subject: [Haskell-cafe] How to take a minimum sub list that only contain
 certain number of elements of certain type?
In-Reply-To: <78539F80-375B-4EF9-B05A-DE6B91E15A11@cs.otago.ac.nz>
References: 
	
	
	
	<78539F80-375B-4EF9-B05A-DE6B91E15A11@cs.otago.ac.nz>
Message-ID: 

On Tue, Sep 25, 2012 at 8:17 PM, Richard O'Keefe  wrote:
> Wrong.  The original poster gave an explicit example
> in which even elements were *retained* in the output,
> they just weren't *counted*.

You are at least the fourth person to email me now to point this out.
I'm glad I could make four people's day better with the joy of
correction...

But I never said it was a full solution - please note that I did
include the output of the function!

One could consider it a partial solution, however: that gives you the
_nth_ odd, so if you want a list of numbers up to the _nth_ odd, that
gives you a stop condition - 'takeWhile =/ nth+1' etc. A 2N traverse
(which laziness might fuse to just 1 traverse, dunno).

-- 
gwern
http://www.gwern.net


From ok at cs.otago.ac.nz  Wed Sep 26 02:45:09 2012
From: ok at cs.otago.ac.nz (Richard O'Keefe)
Date: Wed, 26 Sep 2012 12:45:09 +1200
Subject: [Haskell-cafe] How to take a minimum sub list that only contain
	certain number of elements of certain type?
In-Reply-To: 
References: 
	
	
	
	<78539F80-375B-4EF9-B05A-DE6B91E15A11@cs.otago.ac.nz>
	
Message-ID: <666CB430-C487-4ABC-A807-9A15BC4CB25F@cs.otago.ac.nz>


On 26/09/2012, at 12:28 PM, Gwern Branwen wrote:

> On Tue, Sep 25, 2012 at 8:17 PM, Richard O'Keefe  wrote:
>> Wrong.  The original poster gave an explicit example
>> in which even elements were *retained* in the output,
>> they just weren't *counted*.
> 
> You are at least the fourth person to email me now to point this out.
> I'm glad I could make four people's day better with the joy of
> correction...
> 
> But I never said it was a full solution - please note that I did
> include the output of the function!

The "tsk tsk" is probably what made people so keen to reply.

> One could consider it a partial solution, however: that gives you the
> _nth_ odd, so if you want a list of numbers up to the _nth_ odd, that
> gives you a stop condition - 'takeWhile =/ nth+1' etc.

That doesn't work either.  Consider the list [1,1,1,1,1].
The element just after the 5th odd number in the list is 1;
takeWhile (/= 1) will thus return [] instead of [1,1,1,1].

|A 2N traverse
> (which laziness might fuse to just 1 traverse, dunno).

Not in this case, for fairly obvious reasons.


From gwern0 at gmail.com  Wed Sep 26 02:59:28 2012
From: gwern0 at gmail.com (Gwern Branwen)
Date: Tue, 25 Sep 2012 20:59:28 -0400
Subject: [Haskell-cafe] How to take a minimum sub list that only contain
 certain number of elements of certain type?
In-Reply-To: <666CB430-C487-4ABC-A807-9A15BC4CB25F@cs.otago.ac.nz>
References: 
	
	
	
	<78539F80-375B-4EF9-B05A-DE6B91E15A11@cs.otago.ac.nz>
	
	<666CB430-C487-4ABC-A807-9A15BC4CB25F@cs.otago.ac.nz>
Message-ID: 

On Tue, Sep 25, 2012 at 8:45 PM, Richard O'Keefe  wrote:
> That doesn't work either.  Consider the list [1,1,1,1,1].
> The element just after the 5th odd number in the list is 1;
> takeWhile (/= 1) will thus return [] instead of [1,1,1,1].

I'm not sure that OP would prefer [1,1,1,1] to []. Another area of
underspecification.

-- 
gwern
http://www.gwern.net


From oleg at okmij.org  Wed Sep 26 06:41:46 2012
From: oleg at okmij.org (oleg at okmij.org)
Date: 26 Sep 2012 04:41:46 -0000
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
In-Reply-To: 
Message-ID: <20120926044146.20204.qmail@www1.g3.pair.com>


> Wouldn't you say then that "Church encoding" is still the more appropriate
> reference given that Boehm-Berarducci's algorithm is rarely used? 
>
> When I need to encode pattern matching it's goodbye Church and hello Scott.
> Aside from your projects, where else is the B-B procedure used?

First of all, the Boehm-Berarducci encoding is inefficient only when
doing an operation that is not easily representable as a fold. Quite
many problems can be efficiently tackled by a fold.

Second, I must stress the foundational advantage of the
Boehm-Berarducci encoding: plain System F. Boehm-Berarducci encoding
uses _no_ recursion: not at the term level, not at the type level.  In
contrast, the efficient for pattern-match encodings need general
recursive types. With such types, a fix-point combinator becomes
expressible, and the system, as a logic, becomes inconsistent.



From dan.doel at gmail.com  Wed Sep 26 07:06:59 2012
From: dan.doel at gmail.com (Dan Doel)
Date: Wed, 26 Sep 2012 01:06:59 -0400
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
In-Reply-To: <20120926044146.20204.qmail@www1.g3.pair.com>
References: 
	<20120926044146.20204.qmail@www1.g3.pair.com>
Message-ID: 

On Wed, Sep 26, 2012 at 12:41 AM,   wrote:
> First of all, the Boehm-Berarducci encoding is inefficient only when
> doing an operation that is not easily representable as a fold. Quite
> many problems can be efficiently tackled by a fold.

Indeed. Some operations are even more efficient than usually expected
when operating on folds. For instance:

    snoc xs x f = xs f . f x

People often recommend using ([a] -> [a]) for efficiently building up
lists without worrying about introducing O(n^2) costs through bad
associativity, but the Boehm-Berarducci encoding gets you that and
more (map g xs f = xs (f . g) ; map h (map g xs) = \f -> xs (f . g .
h)).

-- Dan


From carter.schonwald at gmail.com  Wed Sep 26 07:44:12 2012
From: carter.schonwald at gmail.com (Carter Schonwald)
Date: Wed, 26 Sep 2012 01:44:12 -0400
Subject: [Haskell-cafe] 64-bit vs 32-bit haskell platform on Mac:
 misleading notice on Platform website?
In-Reply-To: 
References: 
Message-ID: 

Hi Eugene,
To the best of my knowledge there is absolutely no reason to use the 32bit
haskell on OS X (aside from memory usage optimization cases which likely do
not matter to the *typical* user), and the community should probably update
the recommendation to reflect this.

I can certainly attest to having to baby sit new haskellers when installing
and repeatedly say  "yes, do the 64 bit version, please, no, ignore the
recommendation for 32bit, no one knows why its there, but its wrong"

what can we (the community ) do to address the fact that the haskell
platform installer suggestions for os x are sadly completely backwards? (or
am I completely wrong in my personal stance on this matter)

cheers
-Carter

On Tue, Sep 25, 2012 at 7:52 PM, Eugene Kirpichov wrote:

> Hi,
>
> I installed Haskell Platform 32-bit on a fresh 64-bit mac, because the
> page http://www.haskell.org/platform/mac.html says: "Pick the 32-bit
> vesion, unless you have a specific reason to use the 64-bit version.
> The 32-bit one is slightly faster for most programs."
>
> Then, during the installation of a package, the following happeed:
>
> Loading package cairo-0.12.3.1 ... : can't load .so/.DLL
> for: /opt/local/lib/libz.dylib (dlopen(/opt/local/lib/libz.dylib, 9):
> no suitable image found.  Did find:
>         /opt/local/lib/libz.dylib: mach-o, but wrong architecture)
>
> That libz.dylib is a 64-bit library and it can't be used by 32-bit
> Haskell platform.
>
> QUESTION: It seems to me that most people, at least most who care
> about "slightly faster" programs, are likely to run into something
> like this - using native 64-bit libraries. Compatibility exists only
> in the opposite direction. Wouldn't it be appropriate to remove this
> notice and ask people to use the 64-bit version unless they have a
> specific reason not to?
>
>
> --
> Eugene Kirpichov
> http://www.linkedin.com/in/eugenekirpichov
> We're hiring! http://tinyurl.com/mirantis-openstack-engineer
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From s9gf4ult at gmail.com  Wed Sep 26 08:55:03 2012
From: s9gf4ult at gmail.com (Alexey Uimanov)
Date: Wed, 26 Sep 2012 12:55:03 +0600
Subject: [Haskell-cafe] Help me with space leaks
Message-ID: 

Hello. I am trying to write some thing in haskell and i need fast
storage to store and select this things from storage.
https://github.com/s9gf4ult/projs/tree/master/haskell/teststorage

I am writing simple testing package to determine my needs and select
the fastest storage and i have encountered problems.

Firstly i decided to check out postgresql-simple, but when i am doing
"executeMany" i see space leaks, here is the picture
http://bayimg.com/NAdjHAaeA
http://bayimg.com/NADjKAAea
I dont fully understand what is happening here, but i belive this is
because of lazy consuming of "executeMany" or something. So things im
trying to insert do not calculate one by one, but this is creating
many thunks for calculate them.

I would understand how to narrow the cause of this problem and create
more strict function "executeMany" which would work in constant space
(or space of data).

Here the insertMany from postgresql-simple

executeMany :: (ToRow q) => Connection -> Query -> [q] -> IO Int64
executeMany _ _ [] = return 0
executeMany conn q qs = do
  result <- exec conn =<< formatMany conn q qs
  finishExecute conn q result

And this is not looks like a problem case go to formatMany

formatMany :: (ToRow q) => Connection -> Query -> [q] -> IO ByteString
formatMany _ q [] = fmtError "no rows supplied" q []
formatMany conn q@(Query template) qs = do
  case parseTemplate template of
    Just (before, qbits, after) -> do
      bs <- mapM (buildQuery conn q qbits . toRow) qs
      return . toByteString . mconcat $ fromByteString before :
                                        intersperse (fromChar ',') bs ++
                                        [fromByteString after]
    Nothing -> fmtError "syntax error in multi-row template" q []

Here bs is the map of bs and must stay lazy evaluated
and here we see mconcat which must be strict i think, and if i am
right so problem must disapear whan i replace it with strict mconcat

mconcat' :: (Monod a) => [a] -> a
mconcat' [] = mempty
mconcat' (x:xs) = x `seq` (mappend x $ mconcat' xs)

but it doesnt.
I assume i must write the same for "deepseq" to realy calculate each
parameter up to value. But if so, this must touch several projects
such as blaze and maybe bytestring because of the need to make NFData instances.
How to solve this problem right - way ? Maybe haskell have elegant
solution for this ?


From johan.tibell at gmail.com  Wed Sep 26 10:58:06 2012
From: johan.tibell at gmail.com (Johan Tibell)
Date: Wed, 26 Sep 2012 10:58:06 +0200
Subject: [Haskell-cafe] 64-bit vs 32-bit haskell platform on Mac:
 misleading notice on Platform website?
In-Reply-To: 
References: 
	
Message-ID: 

Hi,

On Wed, Sep 26, 2012 at 7:44 AM, Carter Schonwald
 wrote:
> To the best of my knowledge there is absolutely no reason to use the 32bit
> haskell on OS X (aside from memory usage optimization cases which likely do
> not matter to the *typical* user), and the community should probably update
> the recommendation to reflect this.

The source of the recommendation are the benchmark results presented here:

http://mtnviewmark.wordpress.com/2011/12/07/32-bits-less-is-more/

Note that it's very common to run other GC:ed languages, such as Java
and Python, in 32-bit mode whenever possible. 32-bit almost halves the
memory footprint and thus shortens GC pauses, in particular major
ones, which are O(n) in the size of the heap.

The problem of missing 32-bit C libraries might be a good reason for
us to recommend 64-bit though and leave the 32-bit recommendation to
people who know what they are doing.

Cheers,
Johan


From hesselink at gmail.com  Wed Sep 26 11:57:07 2012
From: hesselink at gmail.com (Erik Hesselink)
Date: Wed, 26 Sep 2012 11:57:07 +0200
Subject: [Haskell-cafe] 64-bit vs 32-bit haskell platform on Mac:
 misleading notice on Platform website?
In-Reply-To: 
References: 
	
	
Message-ID: 

On Wed, Sep 26, 2012 at 10:58 AM, Johan Tibell  wrote:
> On Wed, Sep 26, 2012 at 7:44 AM, Carter Schonwald
>  wrote:
>> To the best of my knowledge there is absolutely no reason to use the 32bit
>> haskell on OS X (aside from memory usage optimization cases which likely do
>> not matter to the *typical* user), and the community should probably update
>> the recommendation to reflect this.
>
> The source of the recommendation are the benchmark results presented here:
>
> http://mtnviewmark.wordpress.com/2011/12/07/32-bits-less-is-more/
>
> The problem of missing 32-bit C libraries might be a good reason for
> us to recommend 64-bit though and leave the 32-bit recommendation to
> people who know what they are doing.

We switched to a 64bit GHC recently for this exact reason. The 64bit
libraries are either already installed, or can easily be installed
through e.g. brew. For 32bit libraries, we sometimes had to compile
from source, passing all kinds of flags. The downside for us is
doubling the memory usage, but that's more easily solved (with more
memory). I haven't noticed the performance reduction.

So in short, I think the 64bit version should be the default
recommendation on OS X.

Erik


From hutch-lists at recursive.ca  Wed Sep 26 13:16:31 2012
From: hutch-lists at recursive.ca (Bob Hutchison)
Date: Wed, 26 Sep 2012 07:16:31 -0400
Subject: [Haskell-cafe] 64-bit vs 32-bit haskell platform on Mac:
	misleading notice on Platform website?
In-Reply-To: 
References: 
	
Message-ID: 


On 2012-09-26, at 1:44 AM, Carter Schonwald  wrote:

> what can we (the community ) do to address the fact that the haskell platform installer suggestions for os x are sadly completely backwards? (or am I completely wrong in my personal stance on this matter)
> 

I'd much prefer the 64 bit myself, unfortunately http://hackage.haskell.org/trac/ghc/ticket/7040 affects the current version of the Haskell Platform. It's fixed in 7.6.x. This bug prevents me from using Yesod with the 64 bit version of 7.4.2, and it's not just Yesod affected?

Cheers,
Bob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From johan.tibell at gmail.com  Wed Sep 26 14:15:41 2012
From: johan.tibell at gmail.com (Johan Tibell)
Date: Wed, 26 Sep 2012 14:15:41 +0200
Subject: [Haskell-cafe] 64-bit vs 32-bit haskell platform on Mac:
 misleading notice on Platform website?
In-Reply-To: 
References: 
	
	
	
Message-ID: 

Adding Mark who's the release manager for the platform (and also the
maintainer of the OS X builds).

On Wed, Sep 26, 2012 at 11:57 AM, Erik Hesselink  wrote:
> On Wed, Sep 26, 2012 at 10:58 AM, Johan Tibell  wrote:
>> On Wed, Sep 26, 2012 at 7:44 AM, Carter Schonwald
>>  wrote:
>>> To the best of my knowledge there is absolutely no reason to use the 32bit
>>> haskell on OS X (aside from memory usage optimization cases which likely do
>>> not matter to the *typical* user), and the community should probably update
>>> the recommendation to reflect this.
>>
>> The source of the recommendation are the benchmark results presented here:
>>
>> http://mtnviewmark.wordpress.com/2011/12/07/32-bits-less-is-more/
>>
>> The problem of missing 32-bit C libraries might be a good reason for
>> us to recommend 64-bit though and leave the 32-bit recommendation to
>> people who know what they are doing.
>
> We switched to a 64bit GHC recently for this exact reason. The 64bit
> libraries are either already installed, or can easily be installed
> through e.g. brew. For 32bit libraries, we sometimes had to compile
> from source, passing all kinds of flags. The downside for us is
> doubling the memory usage, but that's more easily solved (with more
> memory). I haven't noticed the performance reduction.
>
> So in short, I think the 64bit version should be the default
> recommendation on OS X.


From ky3 at atamo.com  Wed Sep 26 15:48:03 2012
From: ky3 at atamo.com (Kim-Ee Yeoh)
Date: Wed, 26 Sep 2012 20:48:03 +0700
Subject: [Haskell-cafe] Church vs Boehm-Berarducci encoding of Lists
In-Reply-To: <20120926044146.20204.qmail@www1.g3.pair.com>
References: 
	<20120926044146.20204.qmail@www1.g3.pair.com>
Message-ID: 

Both are excellent points, thank you.

Your mention of general recursion prompts the following: in 1995, ten years
after publication of Boehm-Berarducci, Launchbury and Sheard investigated
transformation of programs written in general recursive form into
build-foldr form, with an eye towards the normalization laid out in "A Fold
for All Seasons."

L&S does not cite B&B. Could they be the same algorithm?


-- Kim-Ee


On Wed, Sep 26, 2012 at 11:41 AM,  wrote:

>
> > Wouldn't you say then that "Church encoding" is still the more
> appropriate
> > reference given that Boehm-Berarducci's algorithm is rarely used?
> >
> > When I need to encode pattern matching it's goodbye Church and hello
> Scott.
> > Aside from your projects, where else is the B-B procedure used?
>
> First of all, the Boehm-Berarducci encoding is inefficient only when
> doing an operation that is not easily representable as a fold. Quite
> many problems can be efficiently tackled by a fold.
>
> Second, I must stress the foundational advantage of the
> Boehm-Berarducci encoding: plain System F. Boehm-Berarducci encoding
> uses _no_ recursion: not at the term level, not at the type level.  In
> contrast, the efficient for pattern-match encodings need general
> recursive types. With such types, a fix-point combinator becomes
> expressible, and the system, as a logic, becomes inconsistent.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From jason.dusek at gmail.com  Wed Sep 26 16:20:58 2012
From: jason.dusek at gmail.com (Jason Dusek)
Date: Wed, 26 Sep 2012 14:20:58 +0000
Subject: [Haskell-cafe] Partial statical linking
In-Reply-To: 
References: 
	<1322726819-sup-1706@ezyang>
	<0284E8E8-CEED-4E06-AAF0-788B8CA900D5@gmail.com>
	
	
	
Message-ID: 

Hi,

I made a mistake when I said this worked, earlier. My experiment
was run on a system where I had implemented Christian Maeder's
suggestion, by symlinking some static libs in to GHC's libdir.
Naturally, everything appeared to work.

It turns out we have to pass the libraries with -optl, to
prevent GHC from reordering them relative to the other linker
options we've passed.

  ghc -outputdir ./tmp --make -O2 sssp.hs -o sssp.ubuntu \
   -optl-Wl,--whole-archive \
    -optl/usr/lib/x86_64-linux-gnu/libffi.a \
    -optl/usr/lib/x86_64-linux-gnu/libgmp.a \
    -optl/usr/lib/x86_64-linux-gnu/libz.a \
   -optl-Wl,--no-whole-archive

The next great discovery in this area could be an automated, and
general, way of generating the static libraries list. At
present, what I have to do is:

 1. compile the executable once with plain `ghc --make',

 2. use `ldd' to find shared libraries used by this executable
    and correlate these with debs use `dpkg -S',

 3. throw away shared libraries that are part of the `libc'
    Debian package,

 4. find the corresponding `.a' files for each `.so', use find
    and some Sed trickery and

 5. construct the appropriate linker linker before compiling
    everything again.

I could probably skip recompiling everything in step 5 and just
relink. I've made steps 2, 3 and 4 into a shell script that
could be easily adapted to other projects:

  https://github.com/erudify/sssp/blob/master/ubuntu/util

I wonder how much of this we could legitimately ask GHC to do
for us. Statically linking every C dependency is unwise -- it's
not supposed to work to link libc and its immediate dependencies
-- and it does seem odd to ask that GHC have knowledge of this.

--
Jason Dusek
pgp // solidsnack // C1EBC57DC55144F35460C8DF1FD4C6C1FED18A2B


2012/9/24 Jason Dusek :
> 2012/9/19 Brandon Allbery :
>> On Wed, Sep 19, 2012 at 7:06 AM, Jason Dusek  wrote:
>>> What I attempted was building a binary with only some C libraries
>>> statically linked, with this command line:
>>>
>>>   # Build https://github.com/erudify/sssp on Ubunut 12.04
>>>   ghc -outputdir ./tmp -v --make -O2 sssp.hs -o sssp.ubuntu \
>>>     /usr/lib/x86_64-linux-gnu/libffi.a \
>>>     /usr/lib/x86_64-linux-gnu/libgmp.a \
>>>     /usr/lib/x86_64-linux-gnu/libz.a
>>>
>>> However, this really made no difference. Running `ldd' on the
>>> resulting binary reveals that libz and friends are still
>>> dynamically linked:
>>
>> On Linux you probably need -optl--whole-archive for this to do anything;
>> alternately, you would need to get the final ld command line out of ghc and
>> insert the above libraries into it *after* the package .a files.
>>
>> Putting them before the packages (including the GHC runtime) that need them,
>> as will happen by default, will cause them to be ignored because they
>> contain no required symbols *at that point* in the link.  --whole-archive
>> tells to blindly link the whole static archive in instead of ignoring it.
>
> Hi Brandon,
>
> This turned out to be the right ticket. The full command line is
> like this:
>
>   ghc -outputdir ./tmp --make -O2 sssp.hs -o sssp.ubuntu \
>     -optl-Wl,--whole-archive \
>       /usr/lib/x86_64-linux-gnu/libffi.a \
>       /usr/lib/x86_64-linux-gnu/libgmp.a \
>       /usr/lib/x86_64-linux-gnu/libz.a \
>     -optl-Wl,--no-whole-archive
>
> Without the --no-whole-archive at the end, I get errors like:
>
>   (.text+0x880): multiple definition of `__morestack_unblock_signals'
>   /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc.a(generic-morestack.o):(.text+0x880):
> first defined here
>   /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc.a(generic-morestack.o): In
> function `__morestack_allocate_stack_space':
>
> I am not sure why that happens -- libgcc.a wasn't explicitly
> asked for; but it stands to reason that one shouldn't specify
> --whole-archive for everything GHC links, just the archives of
> interest. Life is short and art is long.
>
> --
> Jason Dusek
> pgp // solidsnack // C1EBC57DC55144F35460C8DF1FD4C6C1FED18A2B


From christiaan.baaij at gmail.com  Wed Sep 26 16:43:34 2012
From: christiaan.baaij at gmail.com (Christiaan Baaij)
Date: Wed, 26 Sep 2012 16:43:34 +0200
Subject: [Haskell-cafe] 64-bit vs 32-bit haskell platform on Mac:
	misleading notice on Platform website?
In-Reply-To: 
References: 
	
	
Message-ID: 

Running gloss [1] programs from GHCi only works with the 32bit version of the latest Haskell Platform.
The 64-bit version just shows a black window and GHCi becomes unresponsive.

I use gloss to display trees and graphs in the functional programming course given at our university.
The ability to work within the interpreter, and able to depict the graphs/trees, really enhances the student's understanding of their programs.

I am hence glad that there is still the 32-bit recommendation for OS X.

Cheers,

Christiaan

[1] http://hackage.haskell.org/package/gloss - install with: cabal install gloss --flags="-GLUT GLFW"


On Sep 26, 2012, at 1:16 PM, Bob Hutchison wrote:

> 
> On 2012-09-26, at 1:44 AM, Carter Schonwald  wrote:
> 
>> what can we (the community ) do to address the fact that the haskell platform installer suggestions for os x are sadly completely backwards? (or am I completely wrong in my personal stance on this matter)
>> 
> 
> I'd much prefer the 64 bit myself, unfortunately http://hackage.haskell.org/trac/ghc/ticket/7040 affects the current version of the Haskell Platform. It's fixed in 7.6.x. This bug prevents me from using Yesod with the 64 bit version of 7.4.2, and it's not just Yesod affected?
> 
> Cheers,
> Bob
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



From richard.lyman at parsci.com  Wed Sep 26 22:45:22 2012
From: richard.lyman at parsci.com (Richard Lyman)
Date: Wed, 26 Sep 2012 13:45:22 -0700
Subject: [Haskell-cafe] Haskell Programmers for Distributed Systems
Message-ID: 

Hi folks,

Parallel Scientific is looking for Haskell developers for distributed
systems work.

Parallel Scientific, Inc. is a Boulder, CO based funded startup
company working in the area of scalable parallelization.  We seek
experienced Haskell programmers to build a sophisticated,
ultra-scalable high availability framework to be used in conjunction
with scientific applications, big data applications and I/O systems.
We are primarily seeking candidates in Northern England, central
France and/or Germany but candidates in other locations will be
considered.  Relocation to these places can be discussed.

Parallel Scientific was founded by Dr Peter Braam in 2010. Peter
formerly taught mathematics and computer science at Oxford and
Carnegie Mellon. Then he contributed file systems to Linux and
invented Lustre (which provides storage to 9 of the top 10 systems in
the world). He ran several successful startups, and Parallel
Scientific is run by an very experienced management team and board.

Successful candidates will work in a modern virtual environment in
their homes.  Some travel may be required.  We provide training in
advanced processes for software design and implementation and domain
specific knowledge.

Required skills:
   Capability to design and implement sophisticated distributed
       algorithms (quorum, liveness, lock management, barriers)
   Very strong background in computer science or mathematics
   Experience with Haskell, or network and cluster programming in
      other functional languages (e.g. Erlang)
   Knowledge of systems programming and operating systems functionality

Experience in one or more of the following areas is desirable:
   Experience in high availability clustering projects
   Experience with internals of sophisticated distributed I/O and/or
      database systems

To apply, please send a resume to jobs at parsci.com.

Thanks...

Rich
-- 
Rich Lyman
richard.lyman at parsci.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From carter.schonwald at gmail.com  Wed Sep 26 23:03:00 2012
From: carter.schonwald at gmail.com (Carter Schonwald)
Date: Wed, 26 Sep 2012 17:03:00 -0400
Subject: [Haskell-cafe] 64-bit vs 32-bit haskell platform on Mac:
 misleading notice on Platform website?
In-Reply-To: 
References: 
	
	
	
Message-ID: 

really? does the 64 bit code work correctly when compiled?
if the compiled version works correctly, could you post a repo of some
example codlets that *should work* on ghc 7.6 so i can sort out if its
fixable.   There were some similar problems with gtk / cairo for a while on
OS X, and i was able to sort out reproducible instructions for getting
things to work in that case.





On Wed, Sep 26, 2012 at 10:43 AM, Christiaan Baaij <
christiaan.baaij at gmail.com> wrote:

> Running gloss [1] programs from GHCi only works with the 32bit version of
> the latest Haskell Platform.
> The 64-bit version just shows a black window and GHCi becomes unresponsive.
>
> I use gloss to display trees and graphs in the functional programming
> course given at our university.
> The ability to work within the interpreter, and able to depict the
> graphs/trees, really enhances the student's understanding of their programs.
>
> I am hence glad that there is still the 32-bit recommendation for OS X.
>
> Cheers,
>
> Christiaan
>
> [1] http://hackage.haskell.org/package/gloss - install with: cabal
> install gloss --flags="-GLUT GLFW"
>
>
> On Sep 26, 2012, at 1:16 PM, Bob Hutchison wrote:
>
> >
> > On 2012-09-26, at 1:44 AM, Carter Schonwald 
> wrote:
> >
> >> what can we (the community ) do to address the fact that the haskell
> platform installer suggestions for os x are sadly completely backwards? (or
> am I completely wrong in my personal stance on this matter)
> >>
> >
> > I'd much prefer the 64 bit myself, unfortunately
> http://hackage.haskell.org/trac/ghc/ticket/7040 affects the current
> version of the Haskell Platform. It's fixed in 7.6.x. This bug prevents me
> from using Yesod with the 64 bit version of 7.4.2, and it's not just Yesod
> affected?
> >
> > Cheers,
> > Bob
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From michael at snoyman.com  Wed Sep 26 23:12:19 2012
From: michael at snoyman.com (Michael Snoyman)
Date: Wed, 26 Sep 2012 23:12:19 +0200
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: 
References: 
	
	
	
	
	
Message-ID: 

On Tue, Sep 25, 2012 at 6:21 PM, Heinrich Apfelmus
 wrote:
> Michael Snoyman wrote:
>>
>>
>> Note that I wasn't necessarily advocating such a pragma. And a lot of
>> my XML code actually *does* use two IsString instances at the same
>> time, e.g.:
>>
>>     Element ("img" :: Name) (singleton ("href" :: Name) ("foo.png" ::
>> Text)) [NodeComment ("No content inside an image" :: Text)]
>
>
> In this particular case, would it make sense to use smart constructors
> instead?
>
> The idea is that you can put the polymorphism in two places: either make the
> "output" polymorphic, or make the "input" polymorphic. The latter would
> correspond to a type
>
>    element :: (IsString name, IsString s, IsMap map)
>        => name -> map name s -> [Element]
>    element name map = Element (toName name) (toMap map)
>
> One benefit would be that the function will accept any list as a map, not
> just list literals.

Just to clarify: this would be a *replacement* for OverloadedStrings
usage, right? If used in conjunction with OverloadedStrings, we'd run
into the too-much-polymorphism issue you describe in your initial
email in this thread, since `element "foo'` would become `element
(fromString "foo")` which would become `Element ((toName . fromString)
"foo")`, and `toName . fromString` makes it ambiguous what the
intermediate data type is.

Assuming this is meant are a replacement, I see two downsides.
Firstly, this would work for construction, but not for deconstruction.
Currently, I can do something like:

handleList :: Element -> Element
handleList (Element "ul" _ _) = ...
handleList e = e

The other is that we've only solved one specific case by providing a
replacement function. In order to keep code just as terse as it is
now, we'd have to provide a whole slew of replacement functions. For
example, consider the code:

handleList (Element "ul" attrs _) = case Map.lookup "class" attrs of ....

If we get rid of OverloadedStrings, then we need to either provide a
replacement `lookup` function which performs the conversion from
String to Name, or change all lookup calls to explicitly perform that
lookup.

Michael


From wren at freegeek.org  Thu Sep 27 02:02:00 2012
From: wren at freegeek.org (wren ng thornton)
Date: Wed, 26 Sep 2012 20:02:00 -0400
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: 
References: 
Message-ID: <50639778.4030208@freegeek.org>

On 9/24/12 8:53 AM, George Giorgidze wrote:
> We will release GHC patches for both approaches, meanwhile the
> feedback from the community on the approaches that we took would be
> very much appreciated. Which one those would you prefer? or would you
> suggest a different one.

The first one is much cleaner, and more closely mirrors the other 
overloaded literals. It seems that in most cases the intermediate list 
should be eliminated via build/foldr fusion. Did you do any testing to 
figure out why that fusion wasn't happening? (I.e., *why* is the generic 
approach faster?)

The only other thing I'll mention is that for overloadable strings, part 
of the reason why they're so fast is that string literals are stored a 
la C, and so the conversion to ByteString and Text requires minimal 
work. I wonder if you might be able to leverage a similar technique for 
representing list literals as vectors, which are then inflated to 
lists/vectors/sets/whatever at runtime.

-- 
Live well,
~wren


From wren at freegeek.org  Thu Sep 27 02:07:44 2012
From: wren at freegeek.org (wren ng thornton)
Date: Wed, 26 Sep 2012 20:07:44 -0400
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: <075A3427-67C1-497F-8226-ECCB53039E0B@w3future.com>
References: 
	<59543203684B2244980D7E4057D5FBC1379E81E7@DB3EX14MBXC306.europe.corp.microsoft.com>
	<075A3427-67C1-497F-8226-ECCB53039E0B@w3future.com>
Message-ID: <506398D0.1020902@freegeek.org>

On 9/25/12 1:57 PM, Sjoerd Visscher wrote:
>> Maybe we could make a literal [a,b,c] turn into
>> 	unpack [a,b,c]#
>> where
>> 	[a,b,c]#
>> is a statically-allocated vector?

I'm kinda surprised this isn't already being done. Just doing this seems 
like it'd be a good undertaking, regardless of whether we get overloaded 
list literals. Just storing the literal as a C-like array and inflating 
it to a list/array/vector at runtime seems like it should be a big win 
for code that uses a lot of literals.

-- 
Live well,
~wren


From dstcruz at gmail.com  Thu Sep 27 02:46:12 2012
From: dstcruz at gmail.com (Daniel Santa Cruz)
Date: Wed, 26 Sep 2012 20:46:12 -0400
Subject: [Haskell-cafe] Haskell Weekly News: Issue 245
Message-ID: 

Welcome to issue 245 of the HWN, an issue covering crowd-sourced bits
of information about Haskell from around the web. This issue covers the
week of September 16 to September 22, 2012.

Quotes of the Week

   * dmwit: You have your intuition correct, despite all the pedantry in
     the room.

   * Cale: THIS CODE IS EXCELLENT CODE, I AM AN EXCELLENT ENTERPRISE
     PROGRAMMER ACCOMPLISHING REAL WORLD TASKS USING PATTERNS LIKE I
     READ ABOUT IN ALL THE JAVA BLOGS

   * byorgey: HASKELL is a pure, functional, strongly typed language
     featuring a name with all capitals, so it is suitable for beginners

   * ciaranm: a comonad is just a comonoid in the category of
     endofunctors. what's the coproblem?

   * dmwit: ISAAC -- ignore success at all costs

   * merijn: If you're not gonna use the types [by writing them] you
     might as well just write python

   * Cale: The real reason for the installed size of GHC being so large
     is that in the background it secretly downloads a video of SPJ
     riding a unicycle.

Top Reddit Stories

   * First commercial Haskell-powered (game logic) computer game?
     (Nikki and the Robots Story Episodes)
     Domain: buy.joyridelabs.de, Score: 57, Comments: 27
     On Reddit: [1] http://goo.gl/hngXz
     Original: [2] http://goo.gl/Y5Oax

   * Common misconceptions about Safe Haskell
     Domain: blog.ezyang.com, Score: 49, Comments: 23
     On Reddit: [3] http://goo.gl/NBSx7
     Original: [4] http://goo.gl/43i6n

   * The MonadTrans class is missing a method
     Domain: haskellforall.com, Score: 44, Comments: 32
     On Reddit: [5] http://goo.gl/okxAX
     Original: [6] http://goo.gl/GnvzB

   * The Haskell Implementors' Workshop videos and slides available online
     Domain: haskell.org, Score: 43, Comments: 4
     On Reddit: [7] http://goo.gl/LuORg
     Original: [8] http://goo.gl/pEvww

   * Writing javascript games in haskell : breakout
     Domain: jshaskell.blogspot.com, Score: 39, Comments: 10
     On Reddit: [9] http://goo.gl/Dv8QK
     Original: [10] http://goo.gl/lXxsS

   * HIW 2012. Simon Peyton Jones: GHC Status Update. - YouTube
     Domain: youtube.com, Score: 37, Comments: 12
     On Reddit: [11] http://goo.gl/3GEZK
     Original: [12] http://goo.gl/j7al9

   * Comparing Snap's and Yesod's Template Languages Heist and Hamlet
     Domain: gist.github.com, Score: 36, Comments: 33
     On Reddit: [13] http://goo.gl/AzaVV
     Original: [14] http://goo.gl/StRaF

   * Request: Tutorial on debugging using stack trace features of GHC 7.4
     Domain: self.haskell, Score: 31, Comments: 6
     On Reddit: [15] http://goo.gl/DcR1C
     Original: [16] http://goo.gl/DcR1C

   * A kind for regions
     Domain: monoidal.blogspot.com, Score: 29, Comments: 27
     On Reddit: [17] http://goo.gl/4aBe7
     Original: [18] http://goo.gl/tBDDW

   * [screencast] Quick introduction to Haskell using Gtk and the web
     Domain: vimeo.com, Score: 28, Comments: 4
     On Reddit: [19] http://goo.gl/oi2IB
     Original: [20] http://goo.gl/LOkcf

   * Warp optimization - Sending header and body at once
     Domain: yesodweb.com, Score: 27, Comments: 17
     On Reddit: [21] http://goo.gl/wstwx
     Original: [22] http://goo.gl/opsHb

   * Runtime Codegeneration in Haskell: Harpy vs. LLVM
     Domain: blog.wien.tomnetworks.com, Score: 24, Comments: 10
     On Reddit: [23] http://goo.gl/aD0hE
     Original: [24] http://goo.gl/jU3nf

   * Show off your Vim/Emacs config!
     Domain: self.haskell, Score: 24, Comments: 7
     On Reddit: [25] http://goo.gl/jV6Sa
     Original: [26] http://goo.gl/jV6Sa

   * Elm 0.4: Graphics Upgrade! Markdown, better for games, new
optimizations,
     minification, ...
     Domain: elm-lang.org, Score: 22, Comments: 1
     On Reddit: [27] http://goo.gl/SJW29
     Original: [28] http://goo.gl/2Q5Fg

   * Making your zipper disappear with Zippo
     Domain: brandon.si, Score: 22, Comments: 6
     On Reddit: [29] http://goo.gl/MQg77
     Original: [30] http://goo.gl/Ua8a9

   * [ANNOUNCE] Juicy.Pixels 2.0 - With Gif file decoding
     Domain: hackage.haskell.org, Score: 20, Comments: 12
     On Reddit: [31] http://goo.gl/kEKrE
     Original: [32] http://goo.gl/EVvBh

   * Videos from this the CUFP 2012 in Copenhagen are now up
     Domain: cufp.org, Score: 17, Comments: 2
     On Reddit: [33] http://goo.gl/mpe8Z
     Original: [34] http://goo.gl/aCB9I

   * Haskell developer jobs at StanChart - London, Singapore and Tianjin
     Domain: haskellers.com, Score: 17, Comments: 6
     On Reddit: [35] http://goo.gl/t7axk
     Original: [36] http://goo.gl/wZrV5

   * New GHCJS Hello World (can you find the hidden game?)
     Domain: ghcjs.github.com, Score: 17, Comments: 10
     On Reddit: [37] http://goo.gl/c4BeA
     Original: [38] http://goo.gl/Aqh1i

Top StackOverflow Questions

   * ?What part of Milner-Hindley do you not understand??
     votes: 73, answers: 4
     Read on SO: [39] http://goo.gl/Nossl

   * Matching on type level Nat in GHC 7.6
     votes: 17, answers: 1
     Read on SO: [40] http://goo.gl/YijoA

   * Threading extra state through a parser in Scala
     votes: 16, answers: 1
     Read on SO: [41] http://goo.gl/8cYMQ

   * find all types that are instances of a typeclass
     votes: 13, answers: 1
     Read on SO: [42] http://goo.gl/ywHUN

   * When to use various language pragmas and optimisations?
     votes: 13, answers: 2
     Read on SO: [43] http://goo.gl/qqtID

   * What are these explicit ?forall?s doing?
     votes: 12, answers: 1
     Read on SO: [44] http://goo.gl/fO0kf

   * How does the ST monad work?
     votes: 11, answers: 2
     Read on SO: [45] http://goo.gl/xxntD

   * What are the pros and cons of adding additional functions/combinators
     to a typeclass definition?
     votes: 10, answers: 2
     Read on SO: [46] http://goo.gl/HhDgT

   * Type parameters constraints for instances of typeclasses with kind *
-> *
     votes: 9, answers: 2
     Read on SO: [47] http://goo.gl/bGEQW

   * Theoretically, is this a valid comonad instance for a list?
     votes: 9, answers: 2
     Read on SO: [48] http://goo.gl/z4DI4

   * In haskell how can I uppercase a unicode character with respect
     to current locale
     votes: 9, answers: 1
     Read on SO: [49] http://goo.gl/enNwK

   * Does haskell erase types?
     votes: 8, answers: 2
     Read on SO: [50] http://goo.gl/YP8Nn

   * Is there an Iteratee-like concept which pulls data from multiple
sources?
     votes: 8, answers: 4
     Read on SO: [51] http://goo.gl/AOV0Y

Until next time,
Daniel Santa Cruz

References

   1. http://buy.joyridelabs.de/
   2.
http://www.reddit.com/r/haskell/comments/106ocf/first_commercial_haskellpowered_game_logic/
   3.
http://blog.ezyang.com/2012/09/common-misconceptions-about-safe-haskell/
   4.
http://www.reddit.com/r/haskell/comments/10242c/common_misconceptions_about_safe_haskell/
   5.
http://www.haskellforall.com/2012/09/the-monadtrans-class-is-missing-method.html
   6.
http://www.reddit.com/r/haskell/comments/106xwf/the_monadtrans_class_is_missing_a_method/
   7.
http://www.haskell.org/haskellwiki/HaskellImplementorsWorkshop/2012#Programme
   8.
http://www.reddit.com/r/haskell/comments/102x4p/the_haskell_implementors_workshop_videos_and/
   9. http://jshaskell.blogspot.com/2012/09/breakout.html
  10.
http://www.reddit.com/r/haskell/comments/109hsb/writing_javascript_games_in_haskell_breakout/
  11. http://www.youtube.com/watch?v=2Pucbf8_hGQ&feature=plcp
  12.
http://www.reddit.com/r/haskell/comments/102t49/hiw_2012_simon_peyton_jones_ghc_status_update/
  13. https://gist.github.com/3757918
  14.
http://www.reddit.com/r/haskell/comments/107v79/comparing_snaps_and_yesods_template_languages/
  15.
http://www.reddit.com/r/haskell/comments/104xa2/request_tutorial_on_debugging_using_stack_trace/
  16.
http://www.reddit.com/r/haskell/comments/104xa2/request_tutorial_on_debugging_using_stack_trace/
  17. http://monoidal.blogspot.com/2012/09/a-kind-for-regions.html
  18. http://www.reddit.com/r/haskell/comments/102v1x/a_kind_for_regions/
  19. https://vimeo.com/49918847
  20.
http://www.reddit.com/r/haskell/comments/10az3o/screencast_quick_introduction_to_haskell_using/
  21. http://www.yesodweb.com/blog/2012/09/header-body
  22.
http://www.reddit.com/r/haskell/comments/104sx0/warp_optimization_sending_header_and_body_at_once/
  23.
http://blog.wien.tomnetworks.com/2012/09/17/runtime-codegeneration-in-haskell-harpy-vs-llvm/
  24.
http://www.reddit.com/r/haskell/comments/1014ct/runtime_codegeneration_in_haskell_harpy_vs_llvm/
  25.
http://www.reddit.com/r/haskell/comments/10b20f/show_off_your_vimemacs_config/
  26.
http://www.reddit.com/r/haskell/comments/10b20f/show_off_your_vimemacs_config/
  27. http://elm-lang.org/blog/announce/version-0.4.0.elm
  28.
http://www.reddit.com/r/haskell/comments/102zqr/elm_04_graphics_upgrade_markdown_better_for_games/
  29. http://brandon.si/code/making-your-zipper-disappear-with-zippo/
  30.
http://www.reddit.com/r/haskell/comments/103rhu/making_your_zipper_disappear_with_zippo/
  31. http://hackage.haskell.org/package/JuicyPixels-2.0
  32.
http://www.reddit.com/r/haskell/comments/zziwm/announce_juicypixels_20_with_gif_file_decoding/
  33. http://cufp.org/videos
  34.
http://www.reddit.com/r/haskell/comments/102rer/videos_from_this_the_cufp_2012_in_copenhagen_are/
  35. http://www.haskellers.com/jobs/19
  36.
http://www.reddit.com/r/haskell/comments/106wat/haskell_developer_jobs_at_stanchart_london/
  37. http://ghcjs.github.com/bin/ghcjs-hello.jsexe
  38.
http://www.reddit.com/r/haskell/comments/10b6h3/new_ghcjs_hello_world_can_you_find_the_hidden_game/
  39.
http://stackoverflow.com/questions/12532552/what-part-of-milner-hindley-do-you-not-understand
  40.
http://stackoverflow.com/questions/12463474/matching-on-type-level-nat-in-ghc-7-6
  41.
http://stackoverflow.com/questions/12487827/threading-extra-state-through-a-parser-in-scala
  42.
http://stackoverflow.com/questions/12524034/find-all-types-that-are-instances-of-a-typeclass
  43.
http://stackoverflow.com/questions/12534145/when-to-use-various-language-pragmas-and-optimisations
  44.
http://stackoverflow.com/questions/12519878/what-are-these-explicit-foralls-doing
  45. http://stackoverflow.com/questions/12468622/how-does-the-st-monad-work
  46.
http://stackoverflow.com/questions/12515655/what-are-the-pros-and-cons-of-adding-additional-functions-combinators-to-a-typec
  47.
http://stackoverflow.com/questions/12497542/type-parameters-constraints-for-instances-of-typeclasses-with-kind
  48.
http://stackoverflow.com/questions/12537149/theoretically-is-this-a-valid-comonad-instance-for-a-list
  49.
http://stackoverflow.com/questions/12537377/in-haskell-how-can-i-uppercase-a-unicode-character-with-respect-to-current-local
  50. http://stackoverflow.com/questions/12468722/does-haskell-erase-types
  51.
http://stackoverflow.com/questions/12496654/is-there-an-iteratee-like-concept-which-pulls-data-from-multiple-sources
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From chrisyco+haskell-cafe at gmail.com  Thu Sep 27 08:51:09 2012
From: chrisyco+haskell-cafe at gmail.com (Chris Wong)
Date: Thu, 27 Sep 2012 18:51:09 +1200
Subject: [Haskell-cafe] ANNOUNCE: Sylvia, a lambda calculus visualizer
Message-ID: 

Hello all

Some of you in the audience may have read Dave Keenan's paper, [To
Dissect a Mockingbird][]. A subset of that may have wondered if it was
possible to generate those pretty pictures programmatically. For that
subset, I can answer to you -- yes, yes you can.

[To Dissect a Mockingbird]: http://dkeenan.com/Lambda/

Sylvia is a lambda calculus visualizer. It takes in an expression in
the untyped lambda calculus and spits out a pretty picture.

This is still in very early alpha, but it renders a fair number of
combinators correctly. I plan to add animated reduction (once I figure
out how to do it), and eventually develop this into a sandbox game of
some sort. I'm hoping to get some comments and ideas on how I can take
it from here.


Obligatory links
----------------

Hackage: http://hackage.haskell.org/package/sylvia

Source: https://github.com/lfairy/sylvia

Documentation: https://github.com/lfairy/sylvia/wiki

----------------


From therealkludgy at gmail.com  Thu Sep 27 09:30:04 2012
From: therealkludgy at gmail.com (Darren Grant)
Date: Thu, 27 Sep 2012 00:30:04 -0700
Subject: [Haskell-cafe] ANNOUNCE: Sylvia, a lambda calculus visualizer
In-Reply-To: 
References: 
Message-ID: 

On Wed, Sep 26, 2012 at 11:51 PM, Chris Wong
 wrote:
> Hello all
>
> Some of you in the audience may have read Dave Keenan's paper, [To
> Dissect a Mockingbird][]. A subset of that may have wondered if it was
> possible to generate those pretty pictures programmatically. For that
> subset, I can answer to you -- yes, yes you can.
>
> [To Dissect a Mockingbird]: http://dkeenan.com/Lambda/
>
> Sylvia is a lambda calculus visualizer. It takes in an expression in
> the untyped lambda calculus and spits out a pretty picture.
>
> This is still in very early alpha, but it renders a fair number of
> combinators correctly. I plan to add animated reduction (once I figure
> out how to do it), and eventually develop this into a sandbox game of
> some sort. I'm hoping to get some comments and ideas on how I can take
> it from here.
>
>
> Obligatory links
> ----------------
>
> Hackage: http://hackage.haskell.org/package/sylvia
>
> Source: https://github.com/lfairy/sylvia
>
> Documentation: https://github.com/lfairy/sylvia/wiki
>
> ----------------
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

This is actually a lot of fun, thanks for sharing! I am looking
forward to the animated reductions. :)

Cheers,
Darren


From christiaan.baaij at gmail.com  Thu Sep 27 09:45:48 2012
From: christiaan.baaij at gmail.com (Christiaan Baaij)
Date: Thu, 27 Sep 2012 09:45:48 +0200
Subject: [Haskell-cafe] 64-bit vs 32-bit haskell platform on Mac:
	misleading notice on Platform website?
In-Reply-To: 
References: 
	
	
	
	
Message-ID: 

The behaviour seems to differ between versions of OS X.

A student has OS X 10.8 installed and is observing the described behaviour:
32-bit: interpreted and compiled work correctly
64-bit: only compiled code works correctly

However, I have OS X 10.6, and I'm observing the following behaviour:
32-bit: interpreted and compiled code work correctly
64-bit: interpreted and compiled code work correctly

To test:
cabal install gloss --flags="-GLUT GLFW"
cabal unpack gloss-examples
cd /picture/GameEvent
ghci -fno-ghci-sandbox Main.hs
main

I'll try to find another OS X 10.8 install (I don't want to upgrade) and see if the behaviour still emerges.


On Sep 26, 2012, at 11:03 PM, Carter Schonwald wrote:

> really? does the 64 bit code work correctly when compiled?
> if the compiled version works correctly, could you post a repo of some example codlets that *should work* on ghc 7.6 so i can sort out if its fixable.   There were some similar problems with gtk / cairo for a while on OS X, and i was able to sort out reproducible instructions for getting things to work in that case.


From maydwell at gmail.com  Thu Sep 27 09:49:15 2012
From: maydwell at gmail.com (Lyndon Maydwell)
Date: Thu, 27 Sep 2012 15:49:15 +0800
Subject: [Haskell-cafe] 64-bit vs 32-bit haskell platform on Mac:
 misleading notice on Platform website?
In-Reply-To: 
References: 
	
	
	
	
	
Message-ID: 

I'm experiencing the same issues with compiled 64 bit working
correctly, but interpreted causing all sorts of issues with Scotty.

On Thu, Sep 27, 2012 at 3:45 PM, Christiaan Baaij
 wrote:
> The behaviour seems to differ between versions of OS X.
>
> A student has OS X 10.8 installed and is observing the described behaviour:
> 32-bit: interpreted and compiled work correctly
> 64-bit: only compiled code works correctly
>
> However, I have OS X 10.6, and I'm observing the following behaviour:
> 32-bit: interpreted and compiled code work correctly
> 64-bit: interpreted and compiled code work correctly
>
> To test:
> cabal install gloss --flags="-GLUT GLFW"
> cabal unpack gloss-examples
> cd /picture/GameEvent
> ghci -fno-ghci-sandbox Main.hs
> main
>
> I'll try to find another OS X 10.8 install (I don't want to upgrade) and see if the behaviour still emerges.
>
>
> On Sep 26, 2012, at 11:03 PM, Carter Schonwald wrote:
>
>> really? does the 64 bit code work correctly when compiled?
>> if the compiled version works correctly, could you post a repo of some example codlets that *should work* on ghc 7.6 so i can sort out if its fixable.   There were some similar problems with gtk / cairo for a while on OS X, and i was able to sort out reproducible instructions for getting things to work in that case.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


From s9gf4ult at gmail.com  Thu Sep 27 10:11:29 2012
From: s9gf4ult at gmail.com (s9gf4ult at gmail.com)
Date: Thu, 27 Sep 2012 14:11:29 +0600
Subject: [Haskell-cafe] Can not configure haskell platform
Message-ID: <17762783.6MVAiHnLg2@localhost>

> 13:53 razor at localhost /home/razor/tmp/haskell-platform-2012.2.0.0 % 
./configure --prefix=/home/razor/.haskell
> **************************************************
> *
> *     Haskell Platform Source Installer
> *
> *     For the Haskell Platform 2012.2.0.0 and GHC 7.4.1
> *
> **************************************************
> checking build system type... scripts/config.guess: line 156: 34:LIBC=gnu: 
command not found
> Invalid configuration `x86_64-unknown-linux-': machine `x86_64-unknown-linux' 
not recognized
> configure: error: /bin/sh scripts/config.sub x86_64-unknown-linux- failed
ghc is available in PATH, google does not google. How to fix ?


From s9gf4ult at gmail.com  Thu Sep 27 10:24:17 2012
From: s9gf4ult at gmail.com (s9gf4ult at gmail.com)
Date: Thu, 27 Sep 2012 14:24:17 +0600
Subject: [Haskell-cafe] Can not configure haskell platform
In-Reply-To: <17762783.6MVAiHnLg2@localhost>
References: <17762783.6MVAiHnLg2@localhost>
Message-ID: <4667097.vDORE3hWAF@localhost>

On Thursday 27 September 2012 14:11:29 s9gf4ult at gmail.com wrote:
> 
> > configure: error: /bin/sh scripts/config.sub x86_64-unknown-linux- failed
> 
> ghc is available in PATH, google does not google. How to fix ?

oups, i just figured out, this is because of GREP_OPTIONS in my environment !
script scripts/config.guess must unset it before run.


From spacestation at venussociety.org  Thu Sep 27 18:02:33 2012
From: spacestation at venussociety.org (spacestation at venussociety.org)
Date: Thu, 27 Sep 2012 17:02:33 +0100 (BST)
Subject: [Haskell-cafe] GHC 6.13 and GHC 7.6 in parallel on Linux
Message-ID: <1435555989.375463.1348761754038.JavaMail.open-xchange@webmail.123-reg.co.uk>

Hello to everyone,


First of all sorry if my question posted to this list is maybe OFF TOPIC.
Myself is using Haskell from time to time on WIN XP and OpenSuse system.
So far without a problem using RWH book as reference and 6.12 version with a lot
of modules installed via cabal.
Also a Hugs install from source on my OpenSuse system only caused minor
problems.setting a symlink solved the minor problem.
But what surprised me totally was that Hugs/Cabal and (or ) GHC are using shared
libraries and Hugs install interfered with cabal/ghc.
I thought that both systems are totally independent from each other.Hugs a
Haskell code interpreter GHV a Haskell code compiler.

But now my question :

How is it possible to run 2 different versions of GHC on the same computer ( OS
, in my case OpenSuse  6.1x and hopefully 7.6 )

Any search for "running GHC versions in parallel only  returned results for the
DPH extensions wiki  but not how to run two GHC versions on the same OS.

http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell

http://www.haskell.org/haskellwiki/Parallel


So any feedback welcome

Rgds Gottfried
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From felipe.lessa at gmail.com  Thu Sep 27 18:31:02 2012
From: felipe.lessa at gmail.com (Felipe Almeida Lessa)
Date: Thu, 27 Sep 2012 13:31:02 -0300
Subject: [Haskell-cafe] GHC 6.13 and GHC 7.6 in parallel on Linux
In-Reply-To: <1435555989.375463.1348761754038.JavaMail.open-xchange@webmail.123-reg.co.uk>
References: <1435555989.375463.1348761754038.JavaMail.open-xchange@webmail.123-reg.co.uk>
Message-ID: 

On Thu, Sep 27, 2012 at 1:02 PM, spacestation at venussociety.org
 wrote:
> How is it possible to run 2 different versions of GHC on the same computer (
> OS , in my case OpenSuse  6.1x and hopefully 7.6 )

Just use hsenv [1] (formerly known as virthualenv).

[1] https://github.com/Paczesiowa/hsenv

Cheers,

-- 
Felipe.


From mukeshtiwari.iiitm at gmail.com  Thu Sep 27 18:35:18 2012
From: mukeshtiwari.iiitm at gmail.com (mukesh tiwari)
Date: Thu, 27 Sep 2012 22:05:18 +0530
Subject: [Haskell-cafe] GHC 6.13 and GHC 7.6 in parallel on Linux
In-Reply-To: <1435555989.375463.1348761754038.JavaMail.open-xchange@webmail.123-reg.co.uk>
References: <1435555989.375463.1348761754038.JavaMail.open-xchange@webmail.123-reg.co.uk>
Message-ID: 

On Thu, Sep 27, 2012 at 9:32 PM, spacestation at venussociety.org <
spacestation at venussociety.org> wrote:

> **
>  Hello to everyone,
>
>
> First of all sorry if my question posted to this list is maybe OFF TOPIC.
> Myself is using Haskell from time to time on WIN XP and OpenSuse system.
> So far without a problem using RWH book as reference and 6.12 version with
> a lot of modules installed via cabal.
> Also a Hugs install from source on my OpenSuse system only caused minor
> problems.setting a symlink solved the minor problem.
> But what surprised me totally was that Hugs/Cabal and (or ) GHC are using
> shared libraries and Hugs install interfered with cabal/ghc.
> I thought that both systems are totally independent from each other.Hugs a
> Haskell code interpreter GHV a Haskell code compiler.
>
> But now my question :
>
> How is it possible to run 2 different versions of GHC on the same computer
> ( OS , in my case OpenSuse  6.1x and hopefully 7.6 )
>

It's possible to install two versions of GHC ( see the installation
http://www.haskell.org/ghc/docs/6.10.1/html/users_guide/installing-bin-distrib.html).

The configure script takes a number of flags. The most commonly used is the
--prefix=*/path/to/install/in* flag, which tells the bundle that you want
it to be installed in */path/to/install/in* rather than the default
location (/usr/local). To see all the flags that configure accepts,
run configure
--help.



>
> Any search for "running GHC versions in parallel only  returned results
> for the DPH extensions wiki  but not how to run two GHC versions on the
> same OS.
>
> http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell
>
> http://www.haskell.org/haskellwiki/Parallel
>
>
> So any feedback welcome
>
> Rgds Gottfried
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>

Mukesh Tiwari
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From david.waern at gmail.com  Thu Sep 27 18:37:57 2012
From: david.waern at gmail.com (David Waern)
Date: Thu, 27 Sep 2012 18:37:57 +0200
Subject: [Haskell-cafe] haddock changes between 2.10 and 2.12?
In-Reply-To: 
References: 
Message-ID: 

2012/9/24 Edward Kmett :
> Was there some significant change/bug introduced to haddock made between
> 2.10 and 2.12?
>
> When I look at the haddocks for kan-extensions 3.1: Data.Functor.Yoneda
> which purports to have been built by haddock 2.12 it shows all sorts of
> spurious superclass constraints on almost every instance that should have
> simplified out, but going back to kan-extensions-2.7: Data.Functor.Yoneda
> none of this extra noise is present -- and the code in question hasn't been
> changed in the interim, so I'm pretty sure its not on my end.

I think this is probably due to some change in the GHC internals.
We'll investigate.

Thanks for the report.

David


From mukeshtiwari.iiitm at gmail.com  Thu Sep 27 18:39:15 2012
From: mukeshtiwari.iiitm at gmail.com (mukesh tiwari)
Date: Thu, 27 Sep 2012 22:09:15 +0530
Subject: [Haskell-cafe] GHC 6.13 and GHC 7.6 in parallel on Linux
In-Reply-To: 
References: <1435555989.375463.1348761754038.JavaMail.open-xchange@webmail.123-reg.co.uk>
	
Message-ID: 

I thought you are asking for how to install two versions of GHC on same
system. Sorry for irrelevant answer.

Mukesh Tiwari

On Thu, Sep 27, 2012 at 10:05 PM, mukesh tiwari <
mukeshtiwari.iiitm at gmail.com> wrote:

>
>
> On Thu, Sep 27, 2012 at 9:32 PM, spacestation at venussociety.org <
> spacestation at venussociety.org> wrote:
>
>> **
>>  Hello to everyone,
>>
>>
>> First of all sorry if my question posted to this list is maybe OFF TOPIC.
>> Myself is using Haskell from time to time on WIN XP and OpenSuse system.
>> So far without a problem using RWH book as reference and 6.12 version
>> with a lot of modules installed via cabal.
>> Also a Hugs install from source on my OpenSuse system only caused minor
>> problems.setting a symlink solved the minor problem.
>> But what surprised me totally was that Hugs/Cabal and (or ) GHC are using
>> shared libraries and Hugs install interfered with cabal/ghc.
>> I thought that both systems are totally independent from each other.Hugs
>> a Haskell code interpreter GHV a Haskell code compiler.
>>
>> But now my question :
>>
>> How is it possible to run 2 different versions of GHC on the same
>> computer ( OS , in my case OpenSuse  6.1x and hopefully 7.6 )
>>
>
> It's possible to install two versions of GHC ( see the installation
> http://www.haskell.org/ghc/docs/6.10.1/html/users_guide/installing-bin-distrib.html).
>
> The configure script takes a number of flags. The most commonly used is
> the --prefix=*/path/to/install/in* flag, which tells the bundle that you
> want it to be installed in */path/to/install/in* rather than the default
> location (/usr/local). To see all the flags that configure accepts, run configure
> --help.
>
>
>
>>
>> Any search for "running GHC versions in parallel only  returned results
>> for the DPH extensions wiki  but not how to run two GHC versions on the
>> same OS.
>>
>> http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell
>>
>> http://www.haskell.org/haskellwiki/Parallel
>>
>>
>> So any feedback welcome
>>
>> Rgds Gottfried
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
>>
>
> Mukesh Tiwari
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From strake888 at gmail.com  Fri Sep 28 06:32:30 2012
From: strake888 at gmail.com (Strake)
Date: Thu, 27 Sep 2012 23:32:30 -0500
Subject: [Haskell-cafe] An easy way to represent and modify graphs?
In-Reply-To: 
References: 
	
	
Message-ID: 

On 21/09/2012, Takayuki Muranushi  wrote:
> Yes Pointers. I've forgotten that. I have once dealt with structures,
> with lots of IORefs.  It was smooth and fast. Thank you for reminding
> me!
>
> On the other hand, use of pointers means that our values are not
> algebraic data type any more. We have to derive operations such as
> map, fold, serialize by ourselves. I can do that, but am I right? Or
> is there some systematic way to derive such operations?

If you mean that one can't write "deriving (Class, ...)" then yes, to
my knowledge, one can't, as it would not know to follow the pointers.

I doubt that such a derivation algorithm would be possible in general,
since it wouldn't know whether to compare by value, i.e. follow the
pointer.

> Best regards,
>
> Takayuki
>

Cheers,
Strake


From carter.schonwald at gmail.com  Fri Sep 28 07:56:14 2012
From: carter.schonwald at gmail.com (Carter Schonwald)
Date: Fri, 28 Sep 2012 01:56:14 -0400
Subject: [Haskell-cafe] 64-bit vs 32-bit haskell platform on Mac:
 misleading notice on Platform website?
In-Reply-To: 
References: 
	
	
	
	
	
	
Message-ID: 

do these problems also happen if your'e using the glut backend? (because if
its only glfw that has problems, then its something wrong in the ffi code,
but if its both, that suggests there may be some sort of systematic
problem?)

@Lyndon, that sounds like a bug... especially since scotty seems to have no
C code in package... have you filed a bug report with the maintainers thats
reproducible?

On Thu, Sep 27, 2012 at 3:49 AM, Lyndon Maydwell  wrote:

> I'm experiencing the same issues with compiled 64 bit working
> correctly, but interpreted causing all sorts of issues with Scotty.
>
> On Thu, Sep 27, 2012 at 3:45 PM, Christiaan Baaij
>  wrote:
> > The behaviour seems to differ between versions of OS X.
> >
> > A student has OS X 10.8 installed and is observing the described
> behaviour:
> > 32-bit: interpreted and compiled work correctly
> > 64-bit: only compiled code works correctly
> >
> > However, I have OS X 10.6, and I'm observing the following behaviour:
> > 32-bit: interpreted and compiled code work correctly
> > 64-bit: interpreted and compiled code work correctly
> >
> > To test:
> > cabal install gloss --flags="-GLUT GLFW"
> > cabal unpack gloss-examples
> > cd /picture/GameEvent
> > ghci -fno-ghci-sandbox Main.hs
> > main
> >
> > I'll try to find another OS X 10.8 install (I don't want to upgrade) and
> see if the behaviour still emerges.
> >
> >
> > On Sep 26, 2012, at 11:03 PM, Carter Schonwald wrote:
> >
> >> really? does the 64 bit code work correctly when compiled?
> >> if the compiled version works correctly, could you post a repo of some
> example codlets that *should work* on ghc 7.6 so i can sort out if its
> fixable.   There were some similar problems with gtk / cairo for a while on
> OS X, and i was able to sort out reproducible instructions for getting
> things to work in that case.
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From maydwell at gmail.com  Fri Sep 28 08:06:10 2012
From: maydwell at gmail.com (Lyndon Maydwell)
Date: Fri, 28 Sep 2012 14:06:10 +0800
Subject: [Haskell-cafe] 64-bit vs 32-bit haskell platform on Mac:
 misleading notice on Platform website?
In-Reply-To: 
References: 
	
	
	
	
	
	
	
Message-ID: 

Carter:

Not yet.

I'll get round to it once I'm done with with an Agda presentation I'm
working on. Until then I can't afford to break my environment.

On Fri, Sep 28, 2012 at 1:56 PM, Carter Schonwald
 wrote:
> do these problems also happen if your'e using the glut backend? (because if
> its only glfw that has problems, then its something wrong in the ffi code,
> but if its both, that suggests there may be some sort of systematic
> problem?)
>
> @Lyndon, that sounds like a bug... especially since scotty seems to have no
> C code in package... have you filed a bug report with the maintainers thats
> reproducible?
>
>
> On Thu, Sep 27, 2012 at 3:49 AM, Lyndon Maydwell  wrote:
>>
>> I'm experiencing the same issues with compiled 64 bit working
>> correctly, but interpreted causing all sorts of issues with Scotty.
>>
>> On Thu, Sep 27, 2012 at 3:45 PM, Christiaan Baaij
>>  wrote:
>> > The behaviour seems to differ between versions of OS X.
>> >
>> > A student has OS X 10.8 installed and is observing the described
>> > behaviour:
>> > 32-bit: interpreted and compiled work correctly
>> > 64-bit: only compiled code works correctly
>> >
>> > However, I have OS X 10.6, and I'm observing the following behaviour:
>> > 32-bit: interpreted and compiled code work correctly
>> > 64-bit: interpreted and compiled code work correctly
>> >
>> > To test:
>> > cabal install gloss --flags="-GLUT GLFW"
>> > cabal unpack gloss-examples
>> > cd /picture/GameEvent
>> > ghci -fno-ghci-sandbox Main.hs
>> > main
>> >
>> > I'll try to find another OS X 10.8 install (I don't want to upgrade) and
>> > see if the behaviour still emerges.
>> >
>> >
>> > On Sep 26, 2012, at 11:03 PM, Carter Schonwald wrote:
>> >
>> >> really? does the 64 bit code work correctly when compiled?
>> >> if the compiled version works correctly, could you post a repo of some
>> >> example codlets that *should work* on ghc 7.6 so i can sort out if its
>> >> fixable.   There were some similar problems with gtk / cairo for a while on
>> >> OS X, and i was able to sort out reproducible instructions for getting
>> >> things to work in that case.
>> >
>> > _______________________________________________
>> > Haskell-Cafe mailing list
>> > Haskell-Cafe at haskell.org
>> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>


From christiaan.baaij at gmail.com  Fri Sep 28 13:16:09 2012
From: christiaan.baaij at gmail.com (Christiaan Baaij)
Date: Fri, 28 Sep 2012 13:16:09 +0200
Subject: [Haskell-cafe] 64-bit vs 32-bit haskell platform on Mac:
	misleading notice on Platform website?
In-Reply-To: 
References: 
	
	
	
	
	
	
	
Message-ID: <81A11F9C-A91A-40FD-8948-8AA1B5DCB88E@gmail.com>

The GLUT-backend calls system.exit when the window is closed, because 'exitMainLoop' is only defined within freeglut, which is not by default installed on non-linux platforms.
There is hence no real point in running gloss applications with the GLUT-backend from GHCi.

I'll try to find a mountain lion install, and test if there's a difference between GLUT and GLFW 

On Sep 28, 2012, at 7:56 AM, Carter Schonwald wrote:

> do these problems also happen if your'e using the glut backend? (because if its only glfw that has problems, then its something wrong in the ffi code, 
> but if its both, that suggests there may be some sort of systematic problem?)
> 
> @Lyndon, that sounds like a bug... especially since scotty seems to have no C code in package... have you filed a bug report with the maintainers thats reproducible?



From apfelmus at quantentunnel.de  Fri Sep 28 15:11:47 2012
From: apfelmus at quantentunnel.de (Heinrich Apfelmus)
Date: Fri, 28 Sep 2012 15:11:47 +0200
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: 
References: 					
	
Message-ID: 

Michael Snoyman wrote:
> Heinrich Apfelmus wrote:
>> Michael Snoyman wrote:
>>>
>>> Note that I wasn't necessarily advocating such a pragma. And a lot of
>>> my XML code actually *does* use two IsString instances at the same
>>> time, e.g.:
>>>
>>>     Element ("img" :: Name) (singleton ("href" :: Name) ("foo.png" ::
>>> Text)) [NodeComment ("No content inside an image" :: Text)]
>>
>> In this particular case, would it make sense to use smart constructors
>> instead?
>>
>> The idea is that you can put the polymorphism in two places: either make the
>> "output" polymorphic, or make the "input" polymorphic. The latter would
>> correspond to a type
>>
>>    element :: (IsString name, IsString s, IsMap map)
>>        => name -> map name s -> [Element]
>>    element name map = Element (toName name) (toMap map)
>>
>> One benefit would be that the function will accept any list as a map, not
>> just list literals.
> 
> Just to clarify: this would be a *replacement* for OverloadedStrings
> usage, right? If used in conjunction with OverloadedStrings, we'd run
> into the too-much-polymorphism issue you describe in your initial
> email in this thread, since `element "foo'` would become `element
> (fromString "foo")` which would become `Element ((toName . fromString)
> "foo")`, and `toName . fromString` makes it ambiguous what the
> intermediate data type is.

Yes, indeed, it would be an alternative approach.

> Assuming this is meant are a replacement, I see two downsides.
> Firstly, this would work for construction, but not for deconstruction.
> Currently, I can do something like:
> 
> handleList :: Element -> Element
> handleList (Element "ul" _ _) = ...
> handleList e = e

Good point. On the other hand, there is another extension, ViewPatterns, 
which solves the problem of pattern matching on abstract data types in 
full generality, allowing things like

   handleList (viewAsStrings -> Element "ul" _ _) = ...

While more intrusive, the benefit of this extension is that a lot of 
other code could likely become neater as well.

> The other is that we've only solved one specific case by providing a
> replacement function. In order to keep code just as terse as it is
> now, we'd have to provide a whole slew of replacement functions. For
> example, consider the code:
> 
> handleList (Element "ul" attrs _) = case Map.lookup "class" attrs of ....
> 
> If we get rid of OverloadedStrings, then we need to either provide a
> replacement `lookup` function which performs the conversion from
> String to Name, or change all lookup calls to explicitly perform that
> lookup.

Ah, I see. Since the  Name  type is abstract, I feel it's alright to add 
the polymorphism to functions like  element , but  Map.lookup  is indeed 
a problem.

One option would be to make a new type  NameMap  specifically for  Name 
  as key, but that seems a little overkill. The other option is to bite 
the bullet and add the conversion by hand  Map.lookup (name "class") .

In this case, I think I would go with a lightweight first option and 
simply give a new name to the  Map.lookup  combination and use the 
opportunity to sneak in some polymorphism.

    getAttribute name = Map.lookup (toText name)

In my experience, turning all data types into abstractions works quite 
well, but I can see that you can't avoid an annoying conversion if you 
just want to use a quick  Map.lookup .


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com



From waldmann at imn.htwk-leipzig.de  Fri Sep 28 16:56:33 2012
From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann)
Date: Fri, 28 Sep 2012 14:56:33 +0000 (UTC)
Subject: [Haskell-cafe] ANNOUNCE: Sylvia, a lambda calculus visualizer
References: 
Message-ID: 


> Sylvia is a lambda calculus visualizer. 

Such a thing is certainly nice to have.
I use this one for teaching: 

http://joerg.endrullis.de/lambdaCalculator.html





From waldmann at imn.htwk-leipzig.de  Fri Sep 28 17:01:16 2012
From: waldmann at imn.htwk-leipzig.de (Johannes Waldmann)
Date: Fri, 28 Sep 2012 15:01:16 +0000 (UTC)
Subject: [Haskell-cafe] GHC 6.13 and GHC 7.6 in parallel on Linux
References: <1435555989.375463.1348761754038.JavaMail.open-xchange@webmail.123-reg.co.uk>
Message-ID: 


>    How is it possible to run 2 different versions of GHC

if you installed the binary packages in standard locations,
look in /usr/local/bin/ghc* : you have  ghc-6.12.3, ghc-7.6.1  etc.
and each one knows how to find their libraries.
you can even say "cabal install --with-ghc=ghc-7.6.1 foo"





From f at mazzo.li  Fri Sep 28 18:36:49 2012
From: f at mazzo.li (Francesco Mazzoli)
Date: Fri, 28 Sep 2012 18:36:49 +0200
Subject: [Haskell-cafe] Class constraints with "free" type variables and
	fundeps
Message-ID: <87ehlmgl3y.wl%f@mazzo.li>

I would expect this to work, maybe with some additional notation (a la
ScopedTypeVariables)

    {-# LANGUAGE FunctionalDependencies #-}
    {-# LANGUAGE MultiParamTypeClasses #-}

    class Foo a b | a -> b

    class Foo a b => Bar a where
        foo :: a -> b -> c

The type family equivalent works as expected:

    {-# LANGUAGE TypeFamilies #-}

    class Foo a where
        type T a :: *

    class Bar a where
        foo :: a -> T a -> c

I can't use type families because the `Foo' I'm using is in an external library.
Is there any way to achieve what I want without adding `b' to `Bar'?

--
Francesco * Often in error, never in doubt


From anton.kholomiov at gmail.com  Fri Sep 28 19:20:37 2012
From: anton.kholomiov at gmail.com (Anton Kholomiov)
Date: Fri, 28 Sep 2012 21:20:37 +0400
Subject: [Haskell-cafe] ticketimer - haskell project on Gruender-Garage
	contest!
Message-ID: 

I'd like to announce ticketimer.com -- it's a website
that is not done yet. With ticketimer you can
choose films for your local cinema. People can buy
tickets in advance and promote the films they like.

Do we need to eat this blockbuster stuff all the time?
See how to vote for a change on
http://www.indiegogo.com/ticketimer?a=1301421

We are going to use Yesod as a main weapon.

Anton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From garious at gmail.com  Fri Sep 28 20:01:01 2012
From: garious at gmail.com (Greg Fitzgerald)
Date: Fri, 28 Sep 2012 11:01:01 -0700
Subject: [Haskell-cafe] a parallel mapM?
Message-ID: 

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


From jason at funnelfire.com  Fri Sep 28 20:29:07 2012
From: jason at funnelfire.com (Jason Whittle)
Date: Fri, 28 Sep 2012 14:29:07 -0400
Subject: [Haskell-cafe] Discovery of unnecessary build-depends
Message-ID: 

Is there a tool available that will tell me if the cabal file for my
library or application has any unnecessary build-depends?

I have a habit of developing new modules within an application and then
moving them out to separate libraries. For instance, I might move module
Foo out of my application and into a new or existing library package. If
Foo was the only module in my application to explicitly import any modules
from the Bar package, I would like to know that I can now remove the
dependency on Bar from my application's build-depends in the cabal file.

My strategy right now would be to search my whole application for other
imports of any of the modules from the Bar package, or just remove Bar from
build-depends and check if the application still compiles. Neither solution
is particularly scalable or satisfying.

Cheers,
Jason Whittle
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From mblazevic at stilo.com  Fri Sep 28 20:48:05 2012
From: mblazevic at stilo.com (=?UTF-8?B?TWFyaW8gQmxhxb5ldmnEhw==?=)
Date: Fri, 28 Sep 2012 14:48:05 -0400
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: <506398D0.1020902@freegeek.org>
References: 
	<59543203684B2244980D7E4057D5FBC1379E81E7@DB3EX14MBXC306.europe.corp.microsoft.com>
	<075A3427-67C1-497F-8226-ECCB53039E0B@w3future.com>
	<506398D0.1020902@freegeek.org>
Message-ID: <5065F0E5.1090405@stilo.com>

On 12-09-26 08:07 PM, wren ng thornton wrote:
> On 9/25/12 1:57 PM, Sjoerd Visscher wrote:
>>> Maybe we could make a literal [a,b,c] turn into
>>>     unpack [a,b,c]#
>>> where
>>>     [a,b,c]#
>>> is a statically-allocated vector?
>
> I'm kinda surprised this isn't already being done. Just doing this seems
> like it'd be a good undertaking, regardless of whether we get overloaded
> list literals. Just storing the literal as a C-like array and inflating
> it to a list/array/vector at runtime seems like it should be a big win
> for code that uses a lot of literals.

Why?

	I'm surprised that this is an issue at all. If list literals you are 
talking about are constant, wouldn't GHC apply constant folding and 
construct the list only the first time it's needed?



From haskell at patrickmylund.com  Fri Sep 28 20:58:04 2012
From: haskell at patrickmylund.com (Patrick Mylund Nielsen)
Date: Fri, 28 Sep 2012 13:58:04 -0500
Subject: [Haskell-cafe] a parallel mapM?
In-Reply-To: 
References: 
Message-ID: 

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  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 at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From claude at mathr.co.uk  Fri Sep 28 21:12:07 2012
From: claude at mathr.co.uk (Claude Heiland-Allen)
Date: Fri, 28 Sep 2012 20:12:07 +0100
Subject: [Haskell-cafe] a parallel mapM?
In-Reply-To: 
References: 
	
Message-ID: <5065F687.3030109@mathr.co.uk>

On 28/09/12 19:58, Patrick Mylund Nielsen 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

also

http://hackage.haskell.org/packages/archive/spawn/latest/doc/html/Control-Concurrent-Spawn.html#v:parMapIO

combined with

http://hackage.haskell.org/packages/archive/spawn/latest/doc/html/Control-Concurrent-Spawn.html#v:pool

might be a solution


Claude
-- 
http://mathr.co.uk


From garious at gmail.com  Fri Sep 28 21:17:38 2012
From: garious at gmail.com (Greg Fitzgerald)
Date: Fri, 28 Sep 2012 12:17:38 -0700
Subject: [Haskell-cafe] a parallel mapM?
In-Reply-To: 
References: 
	
Message-ID: 

> 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
 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  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 at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>


From alex.solla at gmail.com  Fri Sep 28 22:48:46 2012
From: alex.solla at gmail.com (Alexander Solla)
Date: Fri, 28 Sep 2012 13:48:46 -0700
Subject: [Haskell-cafe] a parallel mapM?
In-Reply-To: 
References: 
Message-ID: 

On Fri, Sep 28, 2012 at 11:01 AM, Greg Fitzgerald  wrote:
>
>
> 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?
>

That's actually a perfectly fine use for unsafePerformIO, since the IO
action you are performing is pure and therefore safe (modulo your file
handle stuff).

unsafePerformIO is a problem when the IO action being run has side effects
and their order of evaluation matters (since unsafePerformIO will cause
them to be run in an "unpredictable" order)

One common use for unsafePerformIO is to run a query against an external
library.  It has to be done in the IO monad, but it is a "pure" computation
insofar as it has no side-effects that matter.  Doing this lets us promote
values defined in external libraries to bona fide pure Haskell values.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From f at mazzo.li  Sat Sep 29 02:04:51 2012
From: f at mazzo.li (Francesco Mazzoli)
Date: Sat, 29 Sep 2012 02:04:51 +0200
Subject: [Haskell-cafe] Class constraints with "free" type variables and
	fundeps
In-Reply-To: 
References: <87ehlmgl3y.wl%f@mazzo.li>
	
Message-ID: <87d315hexo.wl%f@mazzo.li>

CCing the list back.

At Fri, 28 Sep 2012 13:30:52 -0700,
Alexander Solla wrote:
> What is the problem, exactly?  It looks to me like UndecidableInstances and
> ScopedTypeVariables (on foo, or its arguments) would be enough.

I'm not sure what you mean.  I don't see the need for UndecidableInstances, and
there is no way I can see to bring the `b' into scope in the type sig for foo,
ScopedTypeVariables or not - unless I'm missing something.

> Also note that as stated, foo's type "is a bottom" (more specifically, is a
> function onto bottom, since c is free in the class, and so foo must be
> parametrically polymorphic in its return type, and so is devoid of "real"
> Haskell values).  Hopefully that is just an artefact of the translation to
> Foo's and Bar's.

Yeah the type for `foo' is irrelevant, I just needed to put something there.

--
Francesco * Often in error, never in doubt


From alex.solla at gmail.com  Sat Sep 29 02:19:36 2012
From: alex.solla at gmail.com (Alexander Solla)
Date: Fri, 28 Sep 2012 17:19:36 -0700
Subject: [Haskell-cafe] Class constraints with "free" type variables and
	fundeps
In-Reply-To: <87d315hexo.wl%f@mazzo.li>
References: <87ehlmgl3y.wl%f@mazzo.li>
	
	<87d315hexo.wl%f@mazzo.li>
Message-ID: 

On Fri, Sep 28, 2012 at 5:04 PM, Francesco Mazzoli  wrote:

> CCing the list back.
>
> At Fri, 28 Sep 2012 13:30:52 -0700,
> Alexander Solla wrote:
> > What is the problem, exactly?  It looks to me like UndecidableInstances
> and
> > ScopedTypeVariables (on foo, or its arguments) would be enough.
>
> I'm not sure what you mean.  I don't see the need for
> UndecidableInstances, and
> there is no way I can see to bring the `b' into scope in the type sig for
> foo,
> ScopedTypeVariables or not - unless I'm missing something.


Well, then what exactly is the problem?  Are you getting an error?

You don't need to bring 'b' into scope.  You will already have real types
in scope.

instance Foo A B
instance Bar A where foo A B = C

tryIt = (foo :: A -> B -> C) A B
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From f at mazzo.li  Sat Sep 29 02:36:12 2012
From: f at mazzo.li (Francesco Mazzoli)
Date: Sat, 29 Sep 2012 02:36:12 +0200
Subject: [Haskell-cafe] Class constraints with "free" type variables
	and	fundeps
In-Reply-To: 
References: <87ehlmgl3y.wl%f@mazzo.li>
	
	<87d315hexo.wl%f@mazzo.li>
	
Message-ID: <87bogphdhf.wl%f@mazzo.li>

At Fri, 28 Sep 2012 17:19:36 -0700,
Alexander Solla wrote:
> Well, then what exactly is the problem?  Are you getting an error?

...well yes.  The error I get with the posted class declarations is

   Not in scope: type variable `b'

at the line with

   class Foo a b => Bar a where

Which I get because all the type vars in the LHS must be referenced on the RHS
(or so it seems).

Now, in my case the problem does not stop there, because I also want to
reference the tyvar on the LHS in a type signature of a method, since in that
case there is a fundep on b (`a -> b'), which makes `b' decidable if you have
`a' and `Foo a b'.

> You don't need to bring 'b' into scope.  You will already have real types in
> scope.
>
> instance Foo A B
> instance Bar A where foo A B = C

Again, I'm not sure what you mean here.

--
Francesco * Often in error, never in doubt


From alex.solla at gmail.com  Sat Sep 29 03:33:23 2012
From: alex.solla at gmail.com (Alexander Solla)
Date: Fri, 28 Sep 2012 18:33:23 -0700
Subject: [Haskell-cafe] Class constraints with "free" type variables and
	fundeps
In-Reply-To: <87bogphdhf.wl%f@mazzo.li>
References: <87ehlmgl3y.wl%f@mazzo.li>
	
	<87d315hexo.wl%f@mazzo.li>
	
	<87bogphdhf.wl%f@mazzo.li>
Message-ID: 

On Fri, Sep 28, 2012 at 5:36 PM, Francesco Mazzoli  wrote:

> At Fri, 28 Sep 2012 17:19:36 -0700,
> Alexander Solla wrote:
> > Well, then what exactly is the problem?  Are you getting an error?
>
> ...well yes.  The error I get with the posted class declarations is
>
>    Not in scope: type variable `b'
>
> at the line with
>
>    class Foo a b => Bar a where
>
> Which I get because all the type vars in the LHS must be referenced on the
> RHS
> (or so it seems).
>

Yes, indeed.


>
> Now, in my case the problem does not stop there, because I also want to
> reference the tyvar on the LHS in a type signature of a method, since in
> that
> case there is a fundep on b (`a -> b'), which makes `b' decidable if you
> have
> `a' and `Foo a b'.
>

Only with respect to type inference.


>
> > You don't need to bring 'b' into scope.  You will already have real
> types in
> > scope.
> >
> > instance Foo A B
> > instance Bar A where foo A B = C
>
> Again, I'm not sure what you mean here.


I wouldn't have replied with that line of thought if you had just told us
what the problem was in the first place.  I /was/ saying that you can use
explicit type annotations to disambiguate instances.

Most of us haven't memorized the Haskell 2010 report.  We let the compiler
tell us what's wrong and either learn why, or how to fix it.  So post your
errors.

By the way, it is rather rude to publicly post a private email...

Now, on to your real problem.

Use TypeFamilies instead:

class Foo a where
         type BarThing a :: *

class Foo a => Bar a where
         foo :: a -> BarThing a -> b

This is pretty pointless, since you can just refactor into the nearly
equivalent:

class Foo a

class Foo a => Bar a where
        type BarThing a :: *
        foo :: a -> BarThing a -> c

It may or may not matter to which family the type synonym belongs.

What is the problem you are actually trying to solve?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From f at mazzo.li  Sat Sep 29 10:30:07 2012
From: f at mazzo.li (Francesco Mazzoli)
Date: Sat, 29 Sep 2012 10:30:07 +0200
Subject: [Haskell-cafe] Class constraints with "free" type variables and
	fundeps
In-Reply-To: 
References: <87ehlmgl3y.wl%f@mazzo.li>
	
	<87d315hexo.wl%f@mazzo.li>
	
	<87bogphdhf.wl%f@mazzo.li>
	
Message-ID: <87a9w9grjk.wl%f@mazzo.li>

At Fri, 28 Sep 2012 18:33:23 -0700,
Alexander Solla wrote:
> Only with respect to type inference.

I don't understand this comment.

> I wouldn't have replied with that line of thought if you had just told us
> what the problem was in the first place.  I /was/ saying that you can use
> explicit type annotations to disambiguate instances.
> 
> Most of us haven't memorized the Haskell 2010 report.  We let the compiler
> tell us what's wrong and either learn why, or how to fix it.  So post your
> errors.

Sorry, I posted in a hurry.  Besides, feeding those lines to a compiler before
replying takes 10 seconds.

> By the way, it is rather rude to publicly post a private email...

I thought that you had forgot to reply all, as often happens.  I also want the
discussion to stay on the list, so that people can read in the future.  I'm
sorry if that email was meant to be private, I saw nothing private about it.

> Now, on to your real problem.
> 
> Use TypeFamilies instead:
> 
> class Foo a where
>          type BarThing a :: *
> 
> class Foo a => Bar a where
>          foo :: a -> BarThing a -> b

As I mentioned in the original post, `Foo' is outside my control.

> This is pretty pointless, since you can just refactor into the nearly
> equivalent:
> 
> class Foo a
> 
> class Foo a => Bar a where
>         type BarThing a :: *
>         foo :: a -> BarThing a -> c
> 
> It may or may not matter to which family the type synonym belongs.

Mine was a contrived example to show the issue.  The whole point is to reduce
the number of arguments of a class by referring to another class and its
fundeps.

> What is the problem you are actually trying to solve?

What I actually (would like to) have is something like this:

    class (EditDistance algo sym,  ListLike full sym) =>
          Search container full algo | container -> full, container -> algo where
        

This limitation is annoying even without referencing `sym' (which I can avoid to
do) since is prevents me from putting constraints that express what the purpose
of the class is and will have to be repeated in every instance.

Then I'd also like to have

    newtype TST sym algo = <...>

    instance (Ord sym, ListLike full sym) => Search (TST sym algo) full algo

This one is a different problem - it requires UndecidableInstances and I don't
understand why.  It seems to me that the coverage condition
(,
point 7.6.3.2) is too strict in these cases.  But this is not that important.

--
Francesco * Often in error, never in doubt


From f at mazzo.li  Sat Sep 29 10:56:29 2012
From: f at mazzo.li (Francesco Mazzoli)
Date: Sat, 29 Sep 2012 10:56:29 +0200
Subject: [Haskell-cafe] Class constraints with "free" type variables
	and	fundeps
In-Reply-To: <87a9w9grjk.wl%f@mazzo.li>
References: <87ehlmgl3y.wl%f@mazzo.li>
	
	<87d315hexo.wl%f@mazzo.li>
	
	<87bogphdhf.wl%f@mazzo.li>
	
	<87a9w9grjk.wl%f@mazzo.li>
Message-ID: <878vbtgqbm.wl%f@mazzo.li>

At Sat, 29 Sep 2012 10:30:07 +0200,
Francesco Mazzoli wrote:
> Then I'd also like to have
> 
>     newtype TST sym algo = <...>
> 
>     instance (Ord sym, ListLike full sym) => Search (TST sym algo) full algo
> 
> This one is a different problem - it requires UndecidableInstances and I don't
> understand why.  It seems to me that the coverage condition
> (,
> point 7.6.3.2) is too strict in these cases.  But this is not that important.

This doesn't make sense with the code posted (which would require sensibly
UndecidableInstances), I meant something like this (I don't have "actual" code
to show the problem):

    data Foo a

    class Bar a b | a -> b

    class Quux a b | a -> b

    instance Bar a b => Quux (Foo a) b

--
Francesco * Often in error, never in doubt


From miguelimo38 at yandex.ru  Sat Sep 29 11:04:59 2012
From: miguelimo38 at yandex.ru (MigMit)
Date: Sat, 29 Sep 2012 13:04:59 +0400
Subject: [Haskell-cafe] Class constraints with "free" type variables and
	fundeps
In-Reply-To: <87ehlmgl3y.wl%f@mazzo.li>
References: <87ehlmgl3y.wl%f@mazzo.li>
Message-ID: <5E71A5B5-71EA-4CF6-A1D2-FC473E4595F4@yandex.ru>

Well, it seems that you can't do exactly what you want. So, the simplest way to do this would be not to make Foo a superclass for Bar:

class Bar a where
    foo :: Foo a b => a -> b -> c

Then you would have to mention Foo everywhere.

If you really need, for some reason, to ensure that every Bar instance has a corresponding Foo instance, you can do some oleging this way:

data Void b = Void
data FooEv a where FooEv :: Foo a b => Void b -> FooEv a
class Bar a where
    barFoo :: FooEv a
    bar :: Foo a b => a -> b -> c

Then, whenever you need Foo methods, you can do pattern-matching:

case barFoo :: FooEv a of
  FooEv (Void :: Void b) -> ?

Now some "b" is in scope, and there is an instance of Foo a b.

On Sep 28, 2012, at 8:36 PM, Francesco Mazzoli  wrote:

> I would expect this to work, maybe with some additional notation (a la
> ScopedTypeVariables)
> 
>    {-# LANGUAGE FunctionalDependencies #-}
>    {-# LANGUAGE MultiParamTypeClasses #-}
> 
>    class Foo a b | a -> b
> 
>    class Foo a b => Bar a where
>        foo :: a -> b -> c
> 
> The type family equivalent works as expected:
> 
>    {-# LANGUAGE TypeFamilies #-}
> 
>    class Foo a where
>        type T a :: *
> 
>    class Bar a where
>        foo :: a -> T a -> c
> 
> I can't use type families because the `Foo' I'm using is in an external library.
> Is there any way to achieve what I want without adding `b' to `Bar'?
> 
> --
> Francesco * Often in error, never in doubt
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



From f at mazzo.li  Sat Sep 29 11:17:51 2012
From: f at mazzo.li (Francesco Mazzoli)
Date: Sat, 29 Sep 2012 11:17:51 +0200
Subject: [Haskell-cafe] Class constraints with "free" type variables and
	fundeps
In-Reply-To: <5E71A5B5-71EA-4CF6-A1D2-FC473E4595F4@yandex.ru>
References: <87ehlmgl3y.wl%f@mazzo.li>
	<5E71A5B5-71EA-4CF6-A1D2-FC473E4595F4@yandex.ru>
Message-ID: <877grdgpc0.wl%f@mazzo.li>

At Sat, 29 Sep 2012 13:04:59 +0400,
MigMit wrote:
> Well, it seems that you can't do exactly what you want. So, the simplest way
> to do this would be not to make Foo a superclass for Bar:
> 
> class Bar a where
>     foo :: Foo a b => a -> b -> c
> 
> Then you would have to mention Foo everywhere.

Just to clarify, I already worked my way around that problem.  I want to know
why I can't do it since it seems a useful feature to have.

In fact, I was doing something very similar to what you're proposing before, but
I think having the additional argument is better in my code, for various
reasons.  You can check the actual class here:
,
I've left the old version commented.

> If you really need, for some reason, to ensure that every Bar instance has a
> corresponding Foo instance, you can do some oleging this way:
> 
> data Void b = Void
> data FooEv a where FooEv :: Foo a b => Void b -> FooEv a
> class Bar a where
>     barFoo :: FooEv a
>     bar :: Foo a b => a -> b -> c
> 
> Then, whenever you need Foo methods, you can do pattern-matching:
> 
> case barFoo :: FooEv a of
>   FooEv (Void :: Void b) -> ?
> 
> Now some "b" is in scope, and there is an instance of Foo a b.

Well, I'm sure there are endless ways to get around this, but in cases like this
the resulting mess far outweighs the advantages :).

--
Francesco * Often in error, never in doubt


From f at mazzo.li  Sat Sep 29 11:50:08 2012
From: f at mazzo.li (Francesco Mazzoli)
Date: Sat, 29 Sep 2012 11:50:08 +0200
Subject: [Haskell-cafe] Class constraints with "free" type
	variables	and	fundeps
In-Reply-To: <878vbtgqbm.wl%f@mazzo.li>
References: <87ehlmgl3y.wl%f@mazzo.li>
	
	<87d315hexo.wl%f@mazzo.li>
	
	<87bogphdhf.wl%f@mazzo.li>
	
	<87a9w9grjk.wl%f@mazzo.li> <878vbtgqbm.wl%f@mazzo.li>
Message-ID: <87626xgnu7.wl%f@mazzo.li>

At Sat, 29 Sep 2012 10:56:29 +0200,
Francesco Mazzoli wrote:
> 
> At Sat, 29 Sep 2012 10:30:07 +0200,
> Francesco Mazzoli wrote:
> > Then I'd also like to have
> > 
> >     newtype TST sym algo = <...>
> > 
> >     instance (Ord sym, ListLike full sym) => Search (TST sym algo) full algo
> > 
> > This one is a different problem - it requires UndecidableInstances and I don't
> > understand why.  It seems to me that the coverage condition
> > (,
> > point 7.6.3.2) is too strict in these cases.  But this is not that important.
> 
> This doesn't make sense with the code posted (which would require sensibly
> UndecidableInstances), I meant something like this (I don't have "actual" code
> to show the problem):
> 
>     data Foo a
> 
>     class Bar a b | a -> b
> 
>     class Quux a b | a -> b
> 
>     instance Bar a b => Quux (Foo a) b

Actually I know why this is the case - instances are picked without looking at
the constraints, and there is no backtracking.  I guess my brain just can't
resist from seeing Prolog in type classes...

--
Francesco * Often in error, never in doubt


From ozgurakgun at gmail.com  Sat Sep 29 16:02:49 2012
From: ozgurakgun at gmail.com (Ozgur Akgun)
Date: Sat, 29 Sep 2012 15:02:49 +0100
Subject: [Haskell-cafe] Discovery of unnecessary build-depends
In-Reply-To: 
References: 
Message-ID: 

On 28 September 2012 19:29, Jason Whittle  wrote:

> Is there a tool available that will tell me if the cabal file for my
> library or application has any unnecessary build-depends?
>

FWIW, I felt the need for such a tool many times before too.

The same tool can also report outdated dependencies, maybe?

Cheers,
Ozgur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From illissius at gmail.com  Sat Sep 29 19:49:36 2012
From: illissius at gmail.com (=?ISO-8859-1?Q?G=E1bor_Lehel?=)
Date: Sat, 29 Sep 2012 19:49:36 +0200
Subject: [Haskell-cafe] Class constraints with "free" type variables and
	fundeps
In-Reply-To: <87ehlmgl3y.wl%f@mazzo.li>
References: <87ehlmgl3y.wl%f@mazzo.li>
Message-ID: 

On Fri, Sep 28, 2012 at 6:36 PM, Francesco Mazzoli  wrote:
> I would expect this to work, maybe with some additional notation (a la
> ScopedTypeVariables)
>
>     {-# LANGUAGE FunctionalDependencies #-}
>     {-# LANGUAGE MultiParamTypeClasses #-}
>
>     class Foo a b | a -> b
>
>     class Foo a b => Bar a where
>         foo :: a -> b -> c
>
> The type family equivalent works as expected:
>
>     {-# LANGUAGE TypeFamilies #-}
>
>     class Foo a where
>         type T a :: *
>
>     class Bar a where
>         foo :: a -> T a -> c
>
> I can't use type families because the `Foo' I'm using is in an external library.
> Is there any way to achieve what I want without adding `b' to `Bar'?

I was browsing the GHC bug tracker and accidentally might have found a
solution to your problem:

http://hackage.haskell.org/trac/ghc/ticket/7100

Basically you have to make a type family to recapitulate the
functional dependencies in the instances of Foo:

type family FooFD a

-- for each instance Foo A B, you have to write:
-- type instance FooFD A = B

class Foo a (FooFD a) => Bar a where
    foo :: a -> FooFD a -> c

Anywhere you would use 'b', you use the type family instead.

The example in the ticket also had a 'b ~ FooFD a' superclass
constraint on Foo itself, which you can't add if you don't control
Foo, but I'm not sure what it's necessary for - in my brief tests
removing it didn't cause problems.

A weakness of this approach is that you have to manually add a type
instance for every instance of Foo, which may or may not be a problem
in your situation.


>
> --
> Francesco * Often in error, never in doubt
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



-- 
Your ship was destroyed in a monadic eruption.


From miguelimo38 at yandex.ru  Sat Sep 29 20:08:03 2012
From: miguelimo38 at yandex.ru (MigMit)
Date: Sat, 29 Sep 2012 22:08:03 +0400
Subject: [Haskell-cafe] Class constraints with "free" type variables and
	fundeps
In-Reply-To: 
References: <87ehlmgl3y.wl%f@mazzo.li>
	
Message-ID: 


On Sep 29, 2012, at 9:49 PM, G?bor Lehel  wrote:

> On Fri, Sep 28, 2012 at 6:36 PM, Francesco Mazzoli  wrote:
>> I would expect this to work, maybe with some additional notation (a la
>> ScopedTypeVariables)
>> 
>>    {-# LANGUAGE FunctionalDependencies #-}
>>    {-# LANGUAGE MultiParamTypeClasses #-}
>> 
>>    class Foo a b | a -> b
>> 
>>    class Foo a b => Bar a where
>>        foo :: a -> b -> c
>> 
>> The type family equivalent works as expected:
>> 
>>    {-# LANGUAGE TypeFamilies #-}
>> 
>>    class Foo a where
>>        type T a :: *
>> 
>>    class Bar a where
>>        foo :: a -> T a -> c
>> 
>> I can't use type families because the `Foo' I'm using is in an external library.
>> Is there any way to achieve what I want without adding `b' to `Bar'?
> 
> I was browsing the GHC bug tracker and accidentally might have found a
> solution to your problem:
> 
> http://hackage.haskell.org/trac/ghc/ticket/7100
> 
> Basically you have to make a type family to recapitulate the
> functional dependencies in the instances of Foo:
> 
> type family FooFD a

Actually, I think it's better to use a class here:

class Foo a (FooFD a) => FooProxy a where type FooFD a

> 
> -- for each instance Foo A B, you have to write:
> -- type instance FooFD A = B
> 
> class Foo a (FooFD a) => Bar a where
>    foo :: a -> FooFD a -> c
> 
> Anywhere you would use 'b', you use the type family instead.
> 
> The example in the ticket also had a 'b ~ FooFD a' superclass
> constraint on Foo itself, which you can't add if you don't control
> Foo, but I'm not sure what it's necessary for - in my brief tests
> removing it didn't cause problems.
> 
> A weakness of this approach is that you have to manually add a type
> instance for every instance of Foo, which may or may not be a problem
> in your situation.
> 
> 
>> 
>> --
>> Francesco * Often in error, never in doubt
>> 
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 
> 
> -- 
> Your ship was destroyed in a monadic eruption.
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



From f at mazzo.li  Sat Sep 29 20:47:38 2012
From: f at mazzo.li (Francesco Mazzoli)
Date: Sat, 29 Sep 2012 20:47:38 +0200
Subject: [Haskell-cafe] Class constraints with "free" type variables and
	fundeps
In-Reply-To: 
References: <87ehlmgl3y.wl%f@mazzo.li>
	
Message-ID: <874nmg3bud.wl%f@mazzo.li>

At Sat, 29 Sep 2012 19:49:36 +0200,
G?bor Lehel wrote:
> I was browsing the GHC bug tracker and accidentally might have found a
> solution to your problem:
> 
> http://hackage.haskell.org/trac/ghc/ticket/7100

Thanks, this makes me feel better.  What interested me is not the workarounds,
that I had already partly explored, but why the limitation is there in the first
place.  It turns out that it's because it'd add complexity and type families do
it better.  Fair enough.

> Basically you have to make a type family to recapitulate the functional
> dependencies in the instances of Foo:
> 
> type family FooFD a
> 
> -- for each instance Foo A B, you have to write:
> -- type instance FooFD A = B
> 
> class Foo a (FooFD a) => Bar a where
>     foo :: a -> FooFD a -> c
> 
> Anywhere you would use 'b', you use the type family instead.
> 
> The example in the ticket also had a 'b ~ FooFD a' superclass constraint on
> Foo itself, which you can't add if you don't control Foo, but I'm not sure
> what it's necessary for - in my brief tests removing it didn't cause problems.
> 
> A weakness of this approach is that you have to manually add a type instance
> for every instance of Foo, which may or may not be a problem in your
> situation.

I think this method, while useful to show the already shown relation between
fundeps and type families, is pointless in reality.  The most convenient method
in practice, by far, is just to add the dependent part of the fundep explicitly
to Bar.

Along to the awkwardness you already pointed out of having to declare the family
instance for each type, I'm introducing some unfamiliar and unnecessary type
family to the user.  It adds nothing but confusion.  Not to mention that if I
stick to fundeps I might hope to use my code with something else apart from GHC.

--
Francesco * Often in error, never in doubt


From shumovichy at gmail.com  Sat Sep 29 22:58:28 2012
From: shumovichy at gmail.com (Yuras Shumovich)
Date: Sat, 29 Sep 2012 23:58:28 +0300
Subject: [Haskell-cafe] ANNOUNCE: bindings-gobject-0.4
Message-ID: <1348952308.2548.22.camel@shum-laptop.local>

Hello,

I uploaded new release of bindings-gobject,
low level binding to gobject library:
http://hackage.haskell.org/package/bindings-gobject-0.4
(I maintain it now)

Now it exposes internals of GObject and GObjectClass,
so it is possible to create custom GObject subclasses
from haskell land.
Source repository contains basic example:
https://github.com/Yuras/bindings-gobject/blob/master/examples/custom-object/main.hs

The use case I'm personally is interested in
is implementing custom SourceCompletionProvider
for gtksourceview2.
I hope it will be useful for other applications.

Right now we don't (afaik) have low level bindings to gtk and
gtksourceview. But once we will have them,
it will be possible to create custom controls in haskell
and even expose them to C (C++, python, etc) land.

Thanks,
Yuras



From lgandras at gmail.com  Sat Sep 29 23:56:10 2012
From: lgandras at gmail.com (Andras Gyomrey)
Date: Sat, 29 Sep 2012 17:26:10 -0430
Subject: [Haskell-cafe] HaskellDB Convertible Exception: incompatible types
Message-ID: 

Hi,

I get

*** Exception: Convertible: error converting source data SqlLocalTime
2012-04-27 10:22:15 of type SqlValue to type
Data.Time.LocalTime.LocalTime.ZonedTime: incompatible types

when i try to show a record with a field of type CalendarTime
(automatically generated by Database.HaskellDB.DBDirect, Mysql database
type is "timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
CURRENT_TIMESTAMP"

I already looked forhttp://
haskell.1045720.n5.nabble.com/programmatic-DB-interface-td3120759.html. But
the problem there is about a regexp (not a type). And the incompatible type
problem was caused because of a concatenation. Here, as you can see, i have
no idea what's going on.

Can someone please help me?

Andras
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From kc1956 at gmail.com  Sun Sep 30 02:46:42 2012
From: kc1956 at gmail.com (KC)
Date: Sat, 29 Sep 2012 17:46:42 -0700
Subject: [Haskell-cafe] One of the new buzz phrases is "Event-Sourcing";
 is Haskell suitable for this?
Message-ID: 

http://martinfowler.com/eaaDev/EventSourcing.html

http://martinfowler.com/articles/lmax.html


-- 
--
Regards,
KC


From kc1956 at gmail.com  Sun Sep 30 02:49:11 2012
From: kc1956 at gmail.com (KC)
Date: Sat, 29 Sep 2012 17:49:11 -0700
Subject: [Haskell-cafe] If I want to make a pure Haskell eigenvalue,
 etc. package without calling to LAPACK, etc ...
Message-ID: 

What are some good basis (pun intended) to start from?
e.g. REPA?
or ....?

-- 
--
Regards,
KC


From allbery.b at gmail.com  Sun Sep 30 02:59:07 2012
From: allbery.b at gmail.com (Brandon Allbery)
Date: Sat, 29 Sep 2012 20:59:07 -0400
Subject: [Haskell-cafe] One of the new buzz phrases is "Event-Sourcing";
 is Haskell suitable for this?
In-Reply-To: 
References: 
Message-ID: 

On Sat, Sep 29, 2012 at 8:46 PM, KC  wrote:

> http://martinfowler.com/eaaDev/EventSourcing.html


STM?  And I believe there's work on the debugger in ghci to "run programs
backwards".

-- 
brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From agocorona at gmail.com  Sun Sep 30 03:22:33 2012
From: agocorona at gmail.com (Alberto G. Corona )
Date: Sun, 30 Sep 2012 03:22:33 +0200
Subject: [Haskell-cafe] One of the new buzz phrases is "Event-Sourcing";
 is Haskell suitable for this?
In-Reply-To: 
References: 
Message-ID: 

It??s a very iteresting concept.

The Workflow Monad transformer [1], in Control.Workflow perform
logging and recovery of application istate from the log created.
It has no implementation of roll-back or limited recovery upto a
point, but this is easy to implement.

It also has many inspection and synchronization primitives. It has
been used also for translating the log of a program and recovering the
state in another machine. The log  can be pretty-printed for
debugging.

[1] http://hackage.haskell.org/package/Workflow

2012/9/30 KC :
> http://martinfowler.com/eaaDev/EventSourcing.html
>
> http://martinfowler.com/articles/lmax.html
>
>
> --
> --
> Regards,
> KC
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



-- 
Alberto.


From vigalchin at gmail.com  Sun Sep 30 03:57:59 2012
From: vigalchin at gmail.com (Vasili I. Galchin)
Date: Sat, 29 Sep 2012 18:57:59 -0700
Subject: [Haskell-cafe] Monads
Message-ID: 

Hello,

        I would an examples of monads that are pure, i.e. no side-effects.

Thank you,

Vasili
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From krismicinski at gmail.com  Sun Sep 30 04:11:26 2012
From: krismicinski at gmail.com (Kristopher Micinski)
Date: Sat, 29 Sep 2012 22:11:26 -0400
Subject: [Haskell-cafe] Monads
In-Reply-To: 
References: 
Message-ID: 

You have fallen into the misconception that monads are impure, they are not.

Many monad tutorials begin (erroneously) with the lines "monads allow
you to do impure programming in Haskell."

This is false, monads are pure, it's IO that's impure, not the monadic
programming style.  Monads let you *emulate* an impure style in pure
code, but it's nothing more than this: an emulation.

So in summary you can take any monad you want, and it will be pure,
however it's underlying implementation may not be (such is the case
with IO, for example).  Consider any of:
  -- State,
  -- List,
  -- Cont,
  -- ... literally any monad, some may be more "obviously pure" than
others, but hey, people say that about me all the time.

kris

On Sat, Sep 29, 2012 at 9:57 PM, Vasili I. Galchin  wrote:
> Hello,
>
>         I would an examples of monads that are pure, i.e. no side-effects.
>
> Thank you,
>
> Vasili
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


From kc1956 at gmail.com  Sun Sep 30 04:13:19 2012
From: kc1956 at gmail.com (KC)
Date: Sat, 29 Sep 2012 19:13:19 -0700
Subject: [Haskell-cafe] Monads
In-Reply-To: 
References: 
Message-ID: 

From:

http://www.haskell.org/haskellwiki/Monad


"The computation doesn't have to be impure and can be pure itself as
well. Then monads serve to provide the benefits of separation of
concerns, and automatic creation of a computational "pipeline"."


On Sat, Sep 29, 2012 at 6:57 PM, Vasili I. Galchin  wrote:
> Hello,
>
>         I would an examples of monads that are pure, i.e. no side-effects.
>
> Thank you,
>
> Vasili
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
--
Regards,
KC


From wren at freegeek.org  Sun Sep 30 05:47:11 2012
From: wren at freegeek.org (wren ng thornton)
Date: Sat, 29 Sep 2012 23:47:11 -0400
Subject: [Haskell-cafe] Call for discussion: OverloadedLists extension
In-Reply-To: <5065F0E5.1090405@stilo.com>
References: 
	<59543203684B2244980D7E4057D5FBC1379E81E7@DB3EX14MBXC306.europe.corp.microsoft.com>
	<075A3427-67C1-497F-8226-ECCB53039E0B@w3future.com>
	<506398D0.1020902@freegeek.org> <5065F0E5.1090405@stilo.com>
Message-ID: <5067C0BF.4000002@freegeek.org>

On 9/28/12 2:48 PM, Mario Bla?evi? wrote:
> On 12-09-26 08:07 PM, wren ng thornton wrote:
>> On 9/25/12 1:57 PM, Sjoerd Visscher wrote:
>>>> Maybe we could make a literal [a,b,c] turn into
>>>>     unpack [a,b,c]#
>>>> where
>>>>     [a,b,c]#
>>>> is a statically-allocated vector?
>>
>> I'm kinda surprised this isn't already being done. Just doing this seems
>> like it'd be a good undertaking, regardless of whether we get overloaded
>> list literals. Just storing the literal as a C-like array and inflating
>> it to a list/array/vector at runtime seems like it should be a big win
>> for code that uses a lot of literals.
>
> Why?
>
>      I'm surprised that this is an issue at all. If list literals you
> are talking about are constant, wouldn't GHC apply constant folding and
> construct the list only the first time it's needed?

The problem is: if the list is stored naively in the .data segment (as 
apparently it is), then we have to store all the pointer structure as 
well as the data. This hugely bloats the disk footprint for programs.

That is, all the reasons why String=[Char] is bad at runtime are also 
reasons why this representation is bad at objectcode time. For most 
lists, the pointer structure is a considerable portion of the total 
memory cost. During runtime this overhead is (or at least may be) 
unavoidable due to the dynamic nature of program execution; but there's 
no reason to have this overhead in the compiled format of the program 
since it's trivial to generate it from a compact representation (e.g., 
storing lists as C-style arrays + lengths).

The only conceivable benefit of storing lists on disk using their heap 
representation is to allow treating the .data segment as if it were part 
of the heap, i.e., to have zero-cost inflation and to allow GC to ignore 
that "part of the heap". However, for lists, I can't imagine this 
actually being beneficial in practice. This sort of thing is more 
beneficial for large structures of static data (e.g., sets, maps,...). 
But then for large static data, we still usually want a non-heap 
representation (e.g., cache-oblivious datastructures), since we're 
liable to only look at the data rather than to change it. It's only when 
we have lots of static "mutable" data that it makes sense to take heap 
snapshots.

-- 
Live well,
~wren


From rendel at informatik.uni-marburg.de  Sun Sep 30 13:00:26 2012
From: rendel at informatik.uni-marburg.de (Tillmann Rendel)
Date: Sun, 30 Sep 2012 13:00:26 +0200
Subject: [Haskell-cafe] Monads
In-Reply-To: 
References: 
Message-ID: <5068264A.6070601@informatik.uni-marburg.de>

Vasili I. Galchin wrote:
> I would an examples of monads that are pure, i.e. no side-effects.

One view of programming in monadic style is: You call return and >>= all 
the time. (Either you call it directly, or do notation calls it for 
you). So if you want to understand whether a monad "has side-effects", 
you should look at the implementation of return and >>=. If the 
implementation of return and >>= is written in pure Haskell (without 
unsafePerformIO or calling C code etc.), the monad is pure.

   Tillmann


From trebla at vex.net  Sun Sep 30 16:54:50 2012
From: trebla at vex.net (Albert Y. C. Lai)
Date: Sun, 30 Sep 2012 10:54:50 -0400
Subject: [Haskell-cafe] Monads
In-Reply-To: 
References: 
Message-ID: <50685D3A.5080307@vex.net>

On 12-09-29 09:57 PM, Vasili I. Galchin wrote:
>          I would an examples of monads that are pure, i.e. no side-effects.

What does "side effect" mean, to you? Definition?

Because some people say "State has no side effect", and some other 
people say "State has side effects". The two groups use different 
definitions.


From dipython at gmail.com  Sun Sep 30 18:02:07 2012
From: dipython at gmail.com (Marcelo Sousa)
Date: Sun, 30 Sep 2012 19:02:07 +0300
Subject: [Haskell-cafe] One of the new buzz phrases is "Event-Sourcing";
 is Haskell suitable for this?
In-Reply-To: 
References: 
	
Message-ID: 

Hi,

On Sun, Sep 30, 2012 at 4:22 AM, Alberto G. Corona  wrote:
> It??s a very iteresting concept.
>
> The Workflow Monad transformer [1], in Control.Workflow perform
> logging and recovery of application istate from the log created.
> It has no implementation of roll-back or limited recovery upto a
> point, but this is easy to implement.

Is Control.Workflow similar with acid-state with respect to the way
you recovery the current state?

> It also has many inspection and synchronization primitives. It has
> been used also for translating the log of a program and recovering the
> state in another machine. The log  can be pretty-printed for
> debugging.

Can you "somehow" recover impure (IO) computations?

> [1] http://hackage.haskell.org/package/Workflow

Regards,
Marcelo

> 2012/9/30 KC :
>> http://martinfowler.com/eaaDev/EventSourcing.html
>>
>> http://martinfowler.com/articles/lmax.html
>>
>>
>> --
>> --
>> Regards,
>> KC
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
> --
> Alberto.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


From agocorona at gmail.com  Sun Sep 30 19:15:03 2012
From: agocorona at gmail.com (Alberto G. Corona )
Date: Sun, 30 Sep 2012 19:15:03 +0200
Subject: [Haskell-cafe] One of the new buzz phrases is "Event-Sourcing";
 is Haskell suitable for this?
In-Reply-To: 
References: 
	
	
Message-ID: 

Hi,Marcelo,
No. .Acid state is  explcitly managed by the process by means of state
management primitives

In Control.Workflow the state is managed in a implicit way.

It is a monad transformer mainly  is designed for wrapping IO computations.

the lifting primitive, step, store the intermediate result and recover the
application state.

in acid state the process choose what to write in the state

in workflow the state written is the complete state of the process.

See the example in the documentation. the process ,

http://hackage.haskell.org/packages/archive/Workflow/0.7.0.7/doc/html/Control-Workflow.html


import Control.Workflow
import Control.Concurrent(threadDelay)
import System.IO (hFlush,stdout)

mcount n= do step

$  do
                       putStr (show n ++ " ")
                       hFlush stdout
                       threadDelay 1000000
             mcount (n+1)
             return () -- to disambiguate the return type

main= exec1 
 "count"  $ mcount (0 :: Int)

>>> *runghc demos\sequence.hs*>0 1 2 3
>CTRL-C Pressed>>> *runghc demos\sequence.hs*>3 4 5 6 7
>CTRL-C Pressed>>> *runghc demos\sequence.hs*>7 8 9 10 11
...

in subsequent executions the process start to execute IO computations from
the last point logged:

As the documentation says  some side effect can be re-executed after
recovery if the log is not complete. This may happen after an unexpected
shutdown (in this case Contro-C has been pressed) or due to an asynchronous
log writing policy. (see
syncWrite
) (writing is cached).

Althoug this is not event sourcing, The logging and recovery facilities can
be used for even sourcing.

Alberto

2012/9/30 Marcelo Sousa 

> Hi,
>
> On Sun, Sep 30, 2012 at 4:22 AM, Alberto G. Corona 
> wrote:
> > It??s a very iteresting concept.
> >
> > The Workflow Monad transformer [1], in Control.Workflow perform
> > logging and recovery of application istate from the log created.
> > It has no implementation of roll-back or limited recovery upto a
> > point, but this is easy to implement.
>
> Is Control.Workflow similar with acid-state with respect to the way
> you recovery the current state?
>
> > It also has many inspection and synchronization primitives. It has
> > been used also for translating the log of a program and recovering the
> > state in another machine. The log  can be pretty-printed for
> > debugging.
>
> Can you "somehow" recover impure (IO) computations?
>
> > [1] http://hackage.haskell.org/package/Workflow
>
> Regards,
> Marcelo
>
> > 2012/9/30 KC :
> >> http://martinfowler.com/eaaDev/EventSourcing.html
> >>
> >> http://martinfowler.com/articles/lmax.html
> >>
> >>
> >> --
> >> --
> >> Regards,
> >> KC
> >>
> >> _______________________________________________
> >> Haskell-Cafe mailing list
> >> Haskell-Cafe at haskell.org
> >> http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
> >
> >
> > --
> > Alberto.
> >
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>



-- 
Alberto.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From spam at scientician.net  Sun Sep 30 20:16:45 2012
From: spam at scientician.net (Bardur Arantsson)
Date: Sun, 30 Sep 2012 20:16:45 +0200
Subject: [Haskell-cafe] One of the new buzz phrases is "Event-Sourcing";
 is Haskell suitable for this?
In-Reply-To: 
References: 
Message-ID: 

On 09/30/2012 02:46 AM, KC wrote:
> http://martinfowler.com/eaaDev/EventSourcing.html
> 
> http://martinfowler.com/articles/lmax.html
> 
> 

Sure, why not? See

    http://hackage.haskell.org/package/cqrs-0.8.0
and http://hackage.haskell.org/package/cqrs-example-0.8.0

for an example application.

I should note that the "cqrs" package API is by no means finalized;
there are some limitations(*) to the current implementation, but I've
not had time to actually get rid of those limitations.

(*) The major ones being the requirement for a global version number and
lack of streaming event sourcing.





From wren at freegeek.org  Sun Sep 30 20:40:31 2012
From: wren at freegeek.org (wren ng thornton)
Date: Sun, 30 Sep 2012 14:40:31 -0400
Subject: [Haskell-cafe] Monads
In-Reply-To: <5068264A.6070601@informatik.uni-marburg.de>
References: 
	<5068264A.6070601@informatik.uni-marburg.de>
Message-ID: <5068921F.1090001@freegeek.org>

On 9/30/12 7:00 AM, Tillmann Rendel wrote:
> Vasili I. Galchin wrote:
>> I would an examples of monads that are pure, i.e. no side-effects.
>
> One view of programming in monadic style is: You call return and >>= all
> the time. (Either you call it directly, or do notation calls it for
> you). So if you want to understand whether a monad "has side-effects",
> you should look at the implementation of return and >>=. If the
> implementation of return and >>= is written in pure Haskell (without
> unsafePerformIO or calling C code etc.), the monad is pure.

I'm not sure return and bind will give you the information you seek, 
however. In order to obey the monad laws, return and bind must be (for 
all intents and purposes) pure.

The place to look for "impurities" is the primitive operations of the 
monad; i.e., those which cannot be implemented using return and bind. 
These are the operations which take you out of a free monad and the 
operations which must be given some special semantic interpretation.


-- 
Live well,
~wren