Re: [Haskell-cafe] catamorphisms and attribute grammars

2013-01-27 Thread Petr P
-cafe/2012-May/101460.html [4] http://hackage.haskell.org/packages/archive/pipes/2.0.0/doc/html/Control-Pipe-Common.html Chris On Sun, Jan 27, 2013 at 11:03 AM, Petr P petr@gmail.com wrote: Dear Haskellers, I read some stuff about attribute grammars recently [1] and how UUAGC [2

Re: [Haskell-cafe] catamorphisms and attribute grammars

2013-01-27 Thread Petr P
Roman, this is interesting. Is this arrow generalization in some library already? And does it have a name? Best regards, Petr Pudlak 2013/1/27 Roman Cheplyaka r...@ro-che.info * Petr P petr@gmail.com [2013-01-26 23:03:51+0100] Dear Haskellers, I read some stuff about attribute

Re: [Haskell-cafe] Suggestiong for inter-thread communication

2013-01-26 Thread Petr P
Hi Erik, there seem to be several options. Tie simplest one is that you'll call getEvent with some reasonable timeout in a loop and check some communication channel an update from the calculation thread. Probably the correct way how to handle it involves three threads: (1) The computation

[Haskell-cafe] catamorphisms and attribute grammars

2013-01-26 Thread Petr P
Dear Haskellers, I read some stuff about attribute grammars recently [1] and how UUAGC [2] can be used for code generation. I felt like this should be possible inside Haskell too so I did some experiments and I realized that indeed catamorphisms can be represented in such a way that they can be

Re: [Haskell-cafe] Data.Sequence and replicateM

2013-01-25 Thread Petr P
2013/1/25 Daniel Díaz Casanueva dhelta.d...@gmail.com Yes, you're right about the type context. I always forget that Functor is not a superclass of Monad. Anyway, the `fmap` can be done only with `Monad` in the context. Instead of adding `Functor m` constraint you could write just f n

[Haskell-cafe] The Coverage Condition of functional dependencies

2013-01-23 Thread Petr P
Hi, trying to understand UndecidableInstances (and to find and answer to http://stackoverflow.com/q/14476230/1333025), I was trying to find out why mtl needs UndecidableInstances. The reason is that instances like instance MonadState s m = MonadState s (ContT r m) where don't satisfy the

Re: [Haskell-cafe] ANN: monad-bool 0.1

2013-01-23 Thread Petr P
2013/1/23 John Wiegley jo...@fpcomplete.com John Wiegley jo...@fpcomplete.com writes: Never mind, when/unless + left work just fine for this. You know, it's been a humorous day. ... Don't take it so hard. Trying to reinvent something is always a great exercise and makes you really

[Haskell-cafe] Why should we write a `par` b `pseq` (f a b) instead of a `par` b `par` (f a b)?

2013-01-19 Thread Petr P
Dear Haskellers, I've been playing with par and pseq, and I wonder: Is there any reason to use a `par` b `pseq` (a + b) instead of a `par` b `par` (a + b) except that the second version sparks twice instead of just once (which probably degrades performance a bit)? It seems to me that the

[Haskell-cafe] resources for learning Hindley-Milner type inference for undergraduate students

2013-01-18 Thread Petr P
Dear Haskellers, could somebody recommend me study materials for learning Hindley-Milner type inference algorithm I could recommend to undergraduate students? The original paper is harder to understand, I'm looking for something more didactic. The students are familiar with the lambda calculus,

[Haskell-cafe] How to properly optimize MArray functions for speed?

2013-01-14 Thread Petr P
Dear Haskellers, I'm working on a sorting library for MArrays. Speed is important, so I want to optimize it as much as possible. Currently, I simply INLINE the sorting function. This speeds up the code more than 10 times. However this can easily explode code size if the function is used in

[Haskell-cafe] cabal sdist warns about optimization levels

2013-01-13 Thread Petr P
Hi all, I'm working on a library for fast sorting of MArrays. The library is primarily about speed, so I added ghc-options: -O2 to the cabal file. Now cabal sdist complains with: 'ghc-options: -O2' is rarely needed. Check that it is giving a real benefit and not just imposing longer

Re: [Haskell-cafe] lambda case (was Re: A big hurray for lambda-case (and all the other good stuff))

2012-12-30 Thread Petr P
Hi, I also support Jon's proposal for standalone of { ... }. Seems to me clearer and more useful than the special \case construct. I suppose 'of { ... }' could be generalized to multiple arguments, so that of (Just x) (Just y) - x ++ y would create an anonymous function of type 'Maybe String

Re: [Haskell-cafe] Substituting values

2012-12-22 Thread Petr P
Hi Alvaro, I think you need something wha Scala has - the ability to create a partial function from a case expression. In Scala you could write def update[A](f: PartialFunction[A,A])(v: A): A = f.orElse({ case x = x } : PartialFunction[A,A]).apply(v); and then use it like update[Int]({

[Haskell-cafe] MPTC or functional dependencies?

2012-12-21 Thread Petr P
Dear Haskellers, I'm working on a small library for representing semigroup (or monoid) actions on a set http://hackage.haskell.org/package/semigroups-actions. The MultiParamTypeClasses extension seems to be best suited for the task, as a group can act on many sets, and a set can be acted on by

Re: [Haskell-cafe] MPTC or functional dependencies?

2012-12-21 Thread Petr P
. -- Kim-Ee On Fri, Dec 21, 2012 at 7:38 PM, Petr P petr@gmail.com wrote: Dear Haskellers, I'm working on a small library for representing semigroup (or monoid) actions on a set http://hackage.haskell.org/package/semigroups-actions. The MultiParamTypeClasses extension seems to be best

Re: [Haskell-cafe] Categories (cont.)

2012-12-20 Thread Petr P
Hi Christopher, a data type can be an instance of Category only if it has kind * - * - *. It must have 2 type parameters so that you could have types like 'cat a a'. Some simple examples: import Prelude hiding (id, (.)) import Control.Category import Data.Monoid -- See

Re: [Haskell-cafe] Hoogle index completeness

2012-12-19 Thread Petr P
Hi Alvaro, by default Hoogle only searches some standard set of packages, which is only a relatively small subset of all Hackage content. From http://www.haskell.org/haskellwiki/Hoogle#Scope_of_Web_Searches : Using the standard web interface, Hoogle searches: array, arrows, base, bytestring,

Re: [Haskell-cafe] efficient data structure: column with repeating values

2012-12-18 Thread Petr P
Hi, just an idea (using Seq from Data.Seq and Map from Data.Map): newtype DataTable a b = DataTable (Map b (Seq a)) or if you know you won't have repeated values, you could have newtype DataTable a b = DataTable (Map b (Set a)) Both those ideas sort the data (partially or fully). If you

Re: [Haskell-cafe] Hackage suggestion: Gather the list of the licenses of all dependencies of a package

2012-12-15 Thread Petr P
2012/12/15 Brent Yorgey byor...@seas.upenn.edu On Sat, Dec 15, 2012 at 08:13:44AM +0100, Petr P wrote: This is strange, I thought that cpphs should be specified in build-tools:, not in build-depends:. http://www.haskell.org/cabal/users-guide/developing-packages.html#build-information

[Haskell-cafe] ANNOUNCE: timeout-with-results

2012-12-15 Thread Petr P
A small library that extends System.Timeout.timeout. It adds the possibility of saving partial results. Useful for AI-like algorithms that should return the best result found within a time limit. It comes in two variants: (1) Simple, which only allows computations to save partial results, not

Re: [Haskell-cafe] Hackage suggestion: Gather the list of the licenses of all dependencies of a package

2012-12-14 Thread Petr P
This is strange, I thought that cpphs should be specified in build-tools:, not in build-depends:. http://www.haskell.org/cabal/users-guide/developing-packages.html#build-information Best regards, Petr 2012/12/13 Michael Snoyman mich...@snoyman.com On Thu, Dec 13, 2012 at 9:51 PM, Daniel

Re: [Haskell-cafe] LGPL and Haskell (Was: Re: ANNOUNCE: tie-knot library)

2012-12-13 Thread Petr P
both sides have a horse in this race :) - Clark On Wed, Dec 12, 2012 at 9:51 AM, kudah kudahkuka...@gmail.com wrote: On Wed, 12 Dec 2012 10:06:23 +0100 Petr P petr@gmail.com wrote: 2012/12/12 David Thomas davidleotho...@gmail.com Yet another solution would be what

[Haskell-cafe] Hackage suggestion: Gather the list of the licenses of all dependencies of a package

2012-12-13 Thread Petr P
Dear Haskellers, following up the recent discussion about copyleft licenses, I'd suggest a (hopefully minor) improvement of Hackage: For each package, gather the list of the licenses of everything it depends on. I think this would help considerably people who don't want or can't use software

[Haskell-cafe] LGPL and Haskell (Was: Re: ANNOUNCE: tie-knot library)

2012-12-12 Thread Petr P
2012/12/12 David Thomas davidleotho...@gmail.com IANAL, but reviewing what others have written, it sounds like it may be possible to maintain *some* distinction between LGPL and GPL in Haskell, but it's a different distinction than with an LGPL shared library, so even if applicable it's

Re: [Haskell-cafe] (L)GPL libraries Haskell/GHC (was: Re: ANNOUNCE: tie-knot library)

2012-12-12 Thread Petr P
I asked that on SO: http://programmers.stackexchange.com/q/179084/61231 So far the best answer is wxWidget's license (LGPL + linking exception) which at least has been approved by OSI (although FSF approval would have been better). Best regards, Petr 2012/12/12 Ivan Lazar Miljenovic

[Haskell-cafe] ANNOUNCE: tie-knot library

2012-12-10 Thread Petr P
Dear Haskellers, I'd like to announce a small library tie-knot: Ties the knot on a given set of structures that reference each other by keys - replaces the keys with their respective values. Takes Map k (v k) and converts into Map k v' where v' is the fixed point of v. Motivation: I

Re: [Haskell-cafe] mtl: Why there is Monoid w constraint in the definition of class MonadWriter?

2012-12-09 Thread Petr P
Hi all, I'd say that a type class declares functions and specifies laws (in the docs) what its implementations must adhere to. It's not the job of a type class to fulfill the laws, it's the job of its implementations. So the reason for 'Monoid w' in 'MonadWriter' cannot be that then

Re: [Haskell-cafe] mtl: Why there is Monoid w constraint in the definition of class MonadWriter?

2012-12-09 Thread Petr P
An additional thought: I'd say 'contained' is sort of inverse to 'writer': writer = contained = id contained . writer = return Petr Pudlak 2012/12/9 Petr P petr@gmail.com Hi all, I'd say that a type class declares functions and specifies laws (in the docs) what its

[Haskell-cafe] mtl: Why there is Monoid w constraint in the definition of class MonadWriter?

2012-12-08 Thread Petr P
The class is defined as class (Monoid w, Monad m) = MonadWriter w m | m - w where ... What is the reason for the Monoid constrait? It seems superfluous to me. I recompiled the whole package without it, with no problems. Of course, the Monoid constraint is necessary for most _instances_,

Re: [Haskell-cafe] Maintainer of fixpoint

2012-12-07 Thread Petr P
Thanks Brent, that's just what I needed. I'm switching to recursion-schemes immediately. Best regards, Petr 2012/12/6 Brent Yorgey byor...@seas.upenn.edu On Wed, Dec 05, 2012 at 08:22:32PM +0100, Petr P wrote: Dear Haskellers, I've made some minor improvements of fixpoint package

[Haskell-cafe] Maintainer of fixpoint

2012-12-05 Thread Petr P
Dear Haskellers, I've made some minor improvements of fixpoint package http://hackage.haskell.org/package/fixpoint. I tried to contact the original maintainer twice, but without success. The package hasn't been updated for 4 years. How should I proceed? Should I start a new fork of the

Re: [Haskell-cafe] Why doesn't GHC optimize recursive functions by converting them into `let`?

2012-11-09 Thread Petr P
, 2012 at 10:00 AM, Petr P petr@gmail.com wrote: Hi, recently I found out that some recursive functions can be greatly optimized just by rewriting them using `let` so that they're not recursive themselves any more (only the inner let is). To give an example: fix :: (a - a) - a fix f

[Haskell-cafe] Why doesn't GHC optimize recursive functions by converting them into `let`?

2012-11-08 Thread Petr P
Hi, recently I found out that some recursive functions can be greatly optimized just by rewriting them using `let` so that they're not recursive themselves any more (only the inner let is). To give an example: fix :: (a - a) - a fix f = f (fix f) isn't optimized, because it's a recursive

Re: [Haskell-cafe] Safe lens?

2012-10-29 Thread Petr P
Hi I believe the reason is that it uses TemplateHaskell for automatic derivation of labels. And TemplateHaskell is of course unsafe, since it could convert your code into something entirely different. Best regards, Petr Pudlak 2012/10/29 Greg Fitzgerald gari...@gmail.com: Why are getters

Re: [Haskell-cafe] [Security] Put haskell.org on https

2012-10-28 Thread Petr P
2012/10/28 Francesco Mazzoli f...@mazzo.li: At Sun, 28 Oct 2012 00:20:16 +0100, Niklas Hambüchen wrote: (I have mentioned this several times on #haskell, but nothing has happened so far.) Are you aware that all haskell.org websites (hackage, HaskellWiki, ghc trac) allow unencrypted http

Re: [Haskell-cafe] [Security] Put haskell.org on https

2012-10-28 Thread Petr P
Erik, does cabal need to do any authenticated stuff? For downloading packages I think HTTP is perfectly fine. So we could have HTTP for cabal download only and HTTPS for everything else. Best regards, Petr Pudlak 2012/10/28 Erik Hesselink hessel...@gmail.com: While I would love to have

Re: [Haskell-cafe] [Security] Put haskell.org on https

2012-10-28 Thread Petr P
2012/10/28 Iustin Pop iu...@k1024.org: On Sun, Oct 28, 2012 at 01:38:46PM +0100, Petr P wrote: does cabal need to do any authenticated stuff? For downloading packages I think HTTP is perfectly fine. So we could have HTTP for cabal download only and HTTPS for everything else. Kindly disagree

Re: [Haskell-cafe] [Security] Put haskell.org on https

2012-10-28 Thread Petr P
2012/10/28 Changaco chang...@changaco.net: It doesn't matter what kind of certificate the server uses since the client generally doesn't know about it, especially on first connection. Some programs remember the certificate between uses and inform you when it changes, but that's not perfect

[Haskell-cafe] pragma to request tail recursion optimization (and perhaps [co]inductive recursion)

2012-10-25 Thread Petr P
Hi, Haskell compilers optimize tail recursive functions as cycles, which improves both memory and CPU complexity. However, it's easy to make a mistake and break the conditions under which a function can be tail recursive and thus optimized. Is there a way to tell a Haskell compiler that a

Re: [Haskell-cafe] generalizing the writer monad

2012-10-24 Thread Petr P
2012/10/18 Strake strake...@gmail.com: On 17/10/2012, Petr P petr@gmail.com wrote: Hi, (this is a literate Haskell post.) lately I was playing with the Writer monad and it seems to me that it is too tightly coupled with monoids. Currently, MonadWriter makes the following assumptions

[Haskell-cafe] generalizing the writer monad

2012-10-17 Thread Petr P
Hi, (this is a literate Haskell post.) lately I was playing with the Writer monad and it seems to me that it is too tightly coupled with monoids. Currently, MonadWriter makes the following assumptions: (1) The written value can be read again later. (2) For that to be possible it has to be