Re: [Haskell-cafe] Approaches to dependent types (DT)

2009-10-09 Thread Ryan Ingram
On Fri, Oct 9, 2009 at 6:11 AM, pat browne wrote:

> class Named object name | object -> name where
> name :: object -> name
>
> instance (Eq name, Named object name) => Eq object where
> object1 == object2 = (name object1) == (name object2)
>

This is a type-indexed type.  On a modern GHC I would write it this way:

class Named a where
   type Name a
   name :: a -> Name a

instance (Named a, Eq (Name a)) => Eq a where
   o1 == o2 = name o1 == name o2

Although to be honest I wouldn't write it this way at all, because your Eq
instance is too general (remember, constraints are not examined when doing
typeclass resolution; you are not saying "every type 'a' that is an instance
of Named with Eq (Name a) is also an instance of Eq", you are saying "EVERY
type 'a' is an instance of Eq, and please add the additional constraints 'Eq
(Name a)' and 'Named a'")


> My questions are:
> Question 1: Is my understanding correct?
> Question 2: What flavour of DT is this does this example exhibit?
>

When you say "Dependent Types", what is usually meant is that types can
depend on *values*; for example:

data Vector :: Integer -> * -> * where
Nil :: Vector 0 a
Cons :: a -> Vector n a -> Vector (n+1) a

Now you might write this function:

zip :: forall a b. (n :: Integer) -> Vector n a -> Vector n b -> Vector n
(a,b)
zip 0 Nil Nil = Nil
zip (n+1) (Cons x xs) (Cons y ys) = Cons (x,y) (zip n xs ys)

Notice that the *type* Vector n a depends on the *value* of the argument 'n'
passed in.  Normally it is only the other way around; values are limited by
what type they are.  Here we have types being affected by some object's
value!

  -- ryan
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Libraries for Commercial Users

2009-10-09 Thread Curt Sampson
On 2009-10-09 20:53 -0600 (Fri), John A. De Goes wrote:

> The vast majority of applications being built today are web apps.

Right, and the vast majority of these are done in PHP, followed by Ruby
and Python. For these languages, the majority of libraries are not native,
but C libraries.

So this makes me wonder, if cross-platform support is so necessary,
why have these PHP, Ruby and Python folks not switched to Java, rather
than remain suffering doing their development on Linux boxes?

And if libraries are the issue, why would not just creating a SWIG for
GHC make all of these people move to Haskell?

On 2009-10-08 09:50 -0600 (Thu), John A. De Goes wrote:

> I don't dismiss Haskell in business. I only maintain it's a niche  
> market.

I agree it's a nich market, too. So I guess our point of disagreement is
that you believe that it's lack of libraries keeping it a nich market,
whereas I believe that even if it had libraries out the wazoo like Java
(and of similar quality) it would still be a nich market. In other
words, having a relatively small quantity of libraries is not a problem.

> There are some domains where the infrastructure in more established  
> languages is minimal, and in such cases, I think Haskell can be more  
> efficient than those languages.

Indeed. I found many domains (including web ones) where I didn't use
that infrastructure (such as it was) in Ruby, either.

Where there are libraries and frameworks that are considered
signficantly better, such as Rails over what's available in PHP, people
switching are switching for incremental improvements in what they
already do; these are not the kind of people who would ever switch to
Haskell. (Rails is beloved basically because it's the bastard spawn
of a PHP programmer and web designer; it's certainly not a framework
that offers any big difference over doing the same thing in PHP in the
traditional style it's always been done there.)

> What has moved [from the agile development moment] into mainstream is
> unfortunately connected chiefly to agile by virtue of the word itself.
> Agile means more than getting software out the door quickly, a fact
> many businesses have yet to learn.

Right. But that practically defines the mainstream: adopting
misinterpretations of truly radical changes so that they don't really
have to change. If you want Haskell to *really* go mainstream, that's
what you want. If you want libraries for Haskell that will help it go
mainstream in that sense, you want bad ones that offer no significant
improvement over the bad ones already out there for Java or whatever,
and thus provide little productivity improvement.

That just seems pointless to me, because those looking for real
improvements can't use that sort of stuff. When I need RDBMS access,
libraries like Hibernate and Active Record are useless to me, because
they force me to work in a stupid manner. For web sites, Rails is
useless because again, it deals with stuff in a stupid, unproductive
way. This is why I say libraries aren't important. True, it is nice to
have good ones that really help you be productive, but not only does
Haskell not have them, neither Java nor Ruby do, either.

cjs
-- 
Curt Sampson   +81 90 7737 2974
   Functional programming in all senses of the word:
   http://www.starling-software.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Libraries for Commercial Users

2009-10-09 Thread John A. De Goes

On Oct 9, 2009, at 10:07 AM, Duncan Coutts wrote:

On Thu, 2009-10-08 at 09:43 -0600, John A. De Goes wrote:

Here's a list of libraries that are quite significant to commercial
software development in 2009,


For the kinds of applications that you would like to build.


The vast majority of applications being built today are web apps.

Certainly having more libs enables more apps and that stuff would  
enable

your applications. Fortunately it's not an all-or-nothing thing. There
are plenty of applications we can do now. For the commercial software
I've developed in Haskell, all the libraries I've needed were  
available

and sufficiently mature: decent data structures, binary serialisation,
fast random numbers, date/time handling, GUI lib.


Sure, there are applications that Haskell is a good fit for. See my  
other message on the subject.


Regards,

John A. De Goes
N-Brain, Inc.
The Evolution of Collaboration

http://www.n-brain.net|877-376-2724 x 101


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] HDBC PostgreSQL

2009-10-09 Thread Patrick Brannan
No, I was running the following:
:module Database.HDBC Database.HDBC.PostgreSQL

and the reply was:
module `Database.HDBC.PostgreSQL' is not loaded

Not sure where to go from here. I'll keep reading.

On Fri, Oct 9, 2009 at 4:58 PM, John Goerzen  wrote:
> Patrick Brannan wrote:
>> Prelude> module HDBC HDBC.PostgreSQL
>>
>> Now I would think that the line "Loading package
>> HDBC-postgresql-2.1.0.0 ... linking ... done." means that the module
>> is installed correctly, but I still can't execute the :module
>> statement.
>>
>> Does anyone have any ideas about where I should start? It's probably
>> something stupid, but I'm a little worn out on searching.
>
> That's because you're confusing package names with module names.
>
> I suspect you meant
>
> :m Database.HDBC Database.HDBC.PostgreSQL
>
> The API docs on Hackage will list the modules that any package provides.
>
> -- John
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How do I get this done in constant mem?

2009-10-09 Thread Luke Palmer
On Fri, Oct 9, 2009 at 2:05 PM,   wrote:
> Hi all,
>
> I think there is something about my use of the IO monad that bites me,
> but I am bored of staring at the code, so here you g.  The code goes
> through a list of records and collects the maximum in each record
> position.
>
>
> -- test.hs
> import Random
> import System.Environment (getArgs)
> import System.IO (putStr)
>
> samples :: Int -> Int -> IO [[Double]]
> samples i j = sequence . replicate i . sequence . replicate j $ randomRIO (0, 
> 1000 ** 3)

Yes, you should not do this in IO.  That requires the entire
computation to finish before the result can be used.  This computation
should be pure and lazy.

It is possible, using split (and I believe not without it, unless you
use mkStdGen), to make a 2D list of randoms where the random
generation matches exactly the structure of the list.

splits :: (RandomGen g) => Int -> g -> [g]
splits 0 _ = []
splits n g = let (g1,g2) = split g in g1 : splits (n-1) g2

samples :: (RandomGen g) => Int -> Int -> g -> [[Double]]
samples i j gen = map row (splits i gen)
where
row g = take j (randomRs (0, 10^9) g)

In fact, we could omit all these counts and make an infinite 2D list,
which you can cull in the client code.

splits :: (RandomGen g) => g -> [g]
splits g = let (g1,g2) = split g in g1 : splits g2

samples :: (RandomGen g) => g -> [[Double]]
samples = map row . splits
where
row = randomRs (0, 10^9)

I find the latter to be more straightforward and obvious.  Maintaining
the laziness here is a fairly subtle thing, so study, perturb, try to
write it yourself in different ways, etc.

> maxima :: [[Double]] -> [Double]
> maxima samples@(_:_) = foldr (\ x y -> map (uncurry max) $ zip x y) (head 
> samples) (tail samples)

FWIW, This function has a beautiful alternate definition:

maxima :: [[Double]] -> [Double]
maxima = map maximum . transpose

> main = do
>  args <- getArgs
>  x <- samples (read (head args)) 5
>  putStr . (++ "\n") . show $ maxima x
>
>
> I would expect this to take constant memory (foldr as well as foldl),
> but this is what happens:
>
>
> $ ghc -prof --make -O9 -o test test.hs
> [1 of 1] Compiling Main             ( test.hs, test.o )
> Linking test ...
> $ ./test 100 +RTS -p
> [9.881155955344708e8,9.910336352165401e8,9.71000686630374e8,9.968532576451201e8,9.996200333115692e8]
> $ grep 'total alloc' test.prof
>        total alloc =     744,180 bytes  (excludes profiling overheads)
> $ ./test 1 +RTS -p
> [9.996199711457872e8,9.998928358545277e8,9.99960283632381e8,9.999707142123885e8,9.998952151508758e8]
> $ grep 'total alloc' test.prof
>        total alloc =  64,777,692 bytes  (excludes profiling overheads)
> $ ./test 100 +RTS -p
> Stack space overflow: current size 8388608 bytes.
> Use `+RTS -Ksize' to increase it.
> $
>
>
> so...
>
> does sequence somehow force the entire list of monads into evaluation
> before the head of the result list can be used?

Yep.  IO is completely strict; in some sense the same as "call by
value" (don't take the analogy too far).  Rule of thumb: keep your
distance from it ;-)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Haskell Weekly News

2009-10-09 Thread Matthias Kilian
On Fri, Oct 09, 2009 at 05:46:15PM +0900, Benjamin L.Russell wrote:
> 2) Instead of posting separately to the Haskell and Haskell-Cafe
> mailing lists, it might be better to cross-post, since that way,
> readers using newsreaders can have the cross-posted article
> automatically marked "read" in the mailing list where it has not been
> read.

That may be my fault -- I suggested to send out the HWN in separate
mails to simplify the sending scripts.

Ciao,
Kili
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] CBN, CBV, Lazy in the same final tagless framework

2009-10-09 Thread Martijn van Steenbergen

Felipe Lessa wrote:

which unfortunately needs {-# LANGUAGE RecursiveDo #-} or
some ugliness from mfix


But mdo/mfix is awesome! :-(

Martijn.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Non-traversable foldables

2009-10-09 Thread Martijn van Steenbergen

Ross Paterson wrote:

On Fri, Oct 09, 2009 at 04:41:05PM +0200, Martijn van Steenbergen wrote:

Can anyone think of datatypes that are Foldable but not Traversable?


Set


Nice! Thank you all for your answers.

Martijn.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Different semantics in "identical" do statement?

2009-10-09 Thread Alexander Dunlap
On Fri, Oct 9, 2009 at 4:25 PM, David Menendez  wrote:
> On Fri, Oct 9, 2009 at 6:47 PM, staafmeister  wrote:
>>
>> Daniel Peebles wrote:
>>>
>>> I vaguely remember on IRC someone pointing out that the Parsec monad
>>> broke one of the laws. I think return _|_ >> x === _|_ which could be
>>> causing your problem. I may be wrong though.
>>>
>>>
>>
>> Confirmed, working in the parsec monad
>>
>> Prelude Text.Parsec> runP (do {x <- return undefined; return 10}) () "" ""
>> *** Exception: Prelude.undefined
>>
>> In the IO Monad
>> Prelude Text.Parsec> do {x <- return undefined; return 10}
>> 10
>>
>> Should be fixed.
>
> It looks like the problem is a strict field in the definition of
> GenParser (specifically in Reply). From what I can tell, Parsec 3.0.1
> should not have this problem.
>
> --
> Dave Menendez 
> 
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>

It works with Parsec 3.0.1 for me.

Alex
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Different semantics in "identical" do statement?

2009-10-09 Thread David Menendez
On Fri, Oct 9, 2009 at 6:47 PM, staafmeister  wrote:
>
> Daniel Peebles wrote:
>>
>> I vaguely remember on IRC someone pointing out that the Parsec monad
>> broke one of the laws. I think return _|_ >> x === _|_ which could be
>> causing your problem. I may be wrong though.
>>
>>
>
> Confirmed, working in the parsec monad
>
> Prelude Text.Parsec> runP (do {x <- return undefined; return 10}) () "" ""
> *** Exception: Prelude.undefined
>
> In the IO Monad
> Prelude Text.Parsec> do {x <- return undefined; return 10}
> 10
>
> Should be fixed.

It looks like the problem is a strict field in the definition of
GenParser (specifically in Reply). From what I can tell, Parsec 3.0.1
should not have this problem.

-- 
Dave Menendez 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What *is* a DSL?

2009-10-09 Thread Colin Paul Adams
> "Gregg" == Gregg Reynolds  writes:

Gregg> On Thu, Oct 8, 2009 at 6:08 AM, Colin Paul Adams
Gregg> wrote:

> > "George" == George Pollard  writes:
>> 
George> I'd also like to note that the canonical pronunciation of
George> DSL ends in "-izzle".
>> 
>> Whose canon?
>> 
>> Interestingly, I have always assumed the canonical
>> pronunciation of DSSSL was diesel, as JADE stands for JAmes's
>> DSSSL Engine.
>> 
>> I don't see why removing extra S-es should shorten the vowel.
>> 
>> Wht vwl?  U mst b Englsh. 2 n Amrcn, DSSSL is "dissel"; all
>> short vowels.

Certainly I am English, and so is James Clark.
-- 
Colin Adams
Preston Lancashire
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Different semantics in "identical" do statement?

2009-10-09 Thread staafmeister



Daniel Peebles wrote:
> 
> I vaguely remember on IRC someone pointing out that the Parsec monad
> broke one of the laws. I think return _|_ >> x === _|_ which could be
> causing your problem. I may be wrong though.
> 
> 

Confirmed, working in the parsec monad

Prelude Text.Parsec> runP (do {x <- return undefined; return 10}) () "" ""
*** Exception: Prelude.undefined

In the IO Monad
Prelude Text.Parsec> do {x <- return undefined; return 10}
10

Should be fixed.

-- 
View this message in context: 
http://www.nabble.com/Different-semantics-in-%22identical%22-do-statement--tp25828319p25829017.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] What *is* a DSL?

2009-10-09 Thread Gregg Reynolds
On Thu, Oct 8, 2009 at 6:08 AM, Colin Paul Adams
wrote:

> > "George" == George Pollard  writes:
>
>George> I'd also like to note that the canonical pronunciation of
>George> DSL ends in "-izzle".
>
> Whose canon?
>
> Interestingly, I have always assumed the canonical pronunciation of
> DSSSL was diesel, as JADE stands for JAmes's DSSSL Engine.
>
> I don't see why removing extra S-es should shorten the vowel.
>
>  Wht vwl?  U mst b Englsh. 2 n Amrcn, DSSSL is "dissel"; all short vowels.
DSL is "dee-ess-ell".  "Dizzle" is a brbrzm.


-grgg
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Different semantics in "identical" do statement?

2009-10-09 Thread staafmeister



Daniel Peebles wrote:
> 
> I vaguely remember on IRC someone pointing out that the Parsec monad
> broke one of the laws. I think return _|_ >> x === _|_ which could be
> causing your problem. I may be wrong though.
> 
> 

This could very well be it. I use lazy eval to construct a function that
returns
its own argument (that is you supply the return value of the func as its
arg).

-- 
View this message in context: 
http://www.nabble.com/Different-semantics-in-%22identical%22-do-statement--tp25828319p25828612.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Different semantics in "identical" do statement?

2009-10-09 Thread Daniel Peebles
I vaguely remember on IRC someone pointing out that the Parsec monad
broke one of the laws. I think return _|_ >> x === _|_ which could be
causing your problem. I may be wrong though.

On Fri, Oct 9, 2009 at 5:59 PM, staafmeister  wrote:
>
>
>
> Ross Mellgren wrote:
>>
>> In what Monad?
>>
>>
>
> Parsec Monad
>
> --
> View this message in context: 
> http://www.nabble.com/Different-semantics-in-%22identical%22-do-statement--tp25828319p25828521.html
> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Re: What *is* a DSL?

2009-10-09 Thread Ben Franksen
Emil Axelsson wrote:
> Ben Franksen skrev:
>> minh thu wrote:
>>> 2009/10/7 Günther Schmidt :
> I've informally argued that a true DSL -- separate from a good API --
> should have semantic characteristics of a language: binding forms,
> control structures, abstraction, composition. Some have type systems.
>
 That is one requirement that confuses me, abstraction.

 I thought of DSLs as "special purpose" languages, ie. you give your DSL
 everything it needs for that purpose.

 Why would it also need the ability to express even further
 abstractions, it is supposed to *be* the abstraction.
>>> Programming abstractions at the DSL level, not to further abstract
>>> what the DSL covers.
>>>
>>> Functions, for instance, are typical abstraction means offered by
>>> programming languages. Even if your language is specific to some
>>> domain, being able to create your own functions, and not only rely on
>>> those provided by the DSL implementation, is important.
>>>
>>> Imagine a (E)DSL for 3D programming (e.g. shading language): the
>>> language is designed to fit well the problem (e.g. in this case, 3D
>>> linear algebra, color operations, ...) but you'll agree it would be a
>>> shame to not be able to provide your own functions.
>> 
>> But isn't one of the advantages of an _E_DSL that we can use the host
>> language (Haskell) as a meta or macro language for the DSL? I would think
>> that this greatly reduces the need to provide abstraction
>> facilities /inside/ the DSL. In fact most existing (and often cited
>> examples of) EDSLs in Haskell do not provide abstraction.
> 
> I would say that the DSL is what the user sees. In this view, I think
> it's correct to say that many (or most) DSLs need function abstraction.
> Whether or not the internal data structure has function abstraction is
> an implementation detail.

If it is a stand-alone DSL (i.e. with its own parser), then yes. But I was
referring to Embedded DSLs, i.e. DSL as a library in a host language (eg
Haskell). In this case the user sees the host language by construction,
which means she has less need of function abstraction /inside/ the DSL.

Cheers
Ben

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Different semantics in "identical" do statement?

2009-10-09 Thread staafmeister



Ross Mellgren wrote:
> 
> In what Monad?
> 
> 

Parsec Monad

-- 
View this message in context: 
http://www.nabble.com/Different-semantics-in-%22identical%22-do-statement--tp25828319p25828521.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] HDBC PostgreSQL

2009-10-09 Thread John Goerzen
Patrick Brannan wrote:
> Prelude> module HDBC HDBC.PostgreSQL
> 
> Now I would think that the line "Loading package
> HDBC-postgresql-2.1.0.0 ... linking ... done." means that the module
> is installed correctly, but I still can't execute the :module
> statement.
> 
> Does anyone have any ideas about where I should start? It's probably
> something stupid, but I'm a little worn out on searching.

That's because you're confusing package names with module names.

I suspect you meant

:m Database.HDBC Database.HDBC.PostgreSQL

The API docs on Hackage will list the modules that any package provides.

-- John
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Different semantics in "identical" do statement?

2009-10-09 Thread Ross Mellgren

In what Monad?

-Ross

On Oct 9, 2009, at 5:43 PM, staafmeister wrote:




In my program

do
 x <- do
   blah <- someFunc
   return blah
 return $ Constructor x

behaves differently from
do
 blah <- someFunc
 return $ Constructor blah

where the dots are identical. I would think that these programs should
behave identically, by the monad laws.
The result of my program is that the second gives correct behaviour,  
while

the first loops forever.

Greetings,
Gerben
--
View this message in context: 
http://www.nabble.com/Different-semantics-in-%22identical%22-do-statement--tp25828319p25828319.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com 
.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Different semantics in "identical" do statement?

2009-10-09 Thread staafmeister


In my program

do
  x <- do
blah <- someFunc
return blah
  return $ Constructor x

behaves differently from
do
  blah <- someFunc
  return $ Constructor blah

where the dots are identical. I would think that these programs should
behave identically, by the monad laws.
The result of my program is that the second gives correct behaviour, while
the first loops forever.

Greetings,
Gerben
-- 
View this message in context: 
http://www.nabble.com/Different-semantics-in-%22identical%22-do-statement--tp25828319p25828319.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Setting environment variables on Windows

2009-10-09 Thread Duncan Coutts
On Fri, 2009-10-09 at 17:37 +0200, Sönke Hahn wrote:
> Hi!
> 
> I need to set an environment variable from Haskell and i would like to do 
> that 
> cross-platform. There is System.Posix.Env.setEnv, which does exactly, what i 
> want on Linux. There is the module System.Environment, which seems to be 
> cross-platform, but it does not contain functions to manipulate the 
> environment (, just to inspect it). At first glance, I didn't find anything 
> relevant in the sub-modules of System.Win32.

Note that often it is enough to set environment variables for the
programs that you invoke, rather than for your own process. If that's
enough then you can do it via the System.Process.createProcess action.

Duncan

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Applicative do?

2009-10-09 Thread Philippa Cowderoy

Nicolas Pouillard wrote:

Excerpts from Edward Kmett's message of Fri Oct 09 20:04:08 +0200 2009:
  

I have idiom brackets in that toy library already, but the ado syntax is
fairly useful if you want to refer to several intermediate results by name.
To work with idiom brackets you need to manually write a big lambda yourself
and them apply it. If you have a lambda that takes several arguments --
which isn't all that uncommon in a parser! -- the names you are binding and
their position in the input can get rather far apart, even using idiom
sugar. Philippa's ado sugar lets you amortize that big binding statement
over several lines and keeps the names closer to the binding.



You can still name intermediate *computations* using local bindings, right?
Then you just have to use the named computations in idioms brackets.

  


Not really good enough, because of all the computations whose results 
aren't used. Being able to tell at a glance which bits of the parser are 
handling data for the abstract syntax and which're structure to guide 
the parser is pretty handy.


--
fli...@flippac.org
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Applicative do?

2009-10-09 Thread Nicolas Pouillard
Excerpts from Edward Kmett's message of Fri Oct 09 20:04:08 +0200 2009:
> I have idiom brackets in that toy library already, but the ado syntax is
> fairly useful if you want to refer to several intermediate results by name.
> To work with idiom brackets you need to manually write a big lambda yourself
> and them apply it. If you have a lambda that takes several arguments --
> which isn't all that uncommon in a parser! -- the names you are binding and
> their position in the input can get rather far apart, even using idiom
> sugar. Philippa's ado sugar lets you amortize that big binding statement
> over several lines and keeps the names closer to the binding.

You can still name intermediate *computations* using local bindings, right?
Then you just have to use the named computations in idioms brackets.

-- 
Nicolas Pouillard
http://nicolaspouillard.fr
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library

2009-10-09 Thread Jeremy Shaw

oops, for the sake of completeness you also need:

textType = mkStringType "Data.Text"

- jeremy

On Oct 9, 2009, at 10:33 AM, Jeremy Shaw wrote:


Sweet!

What are the chances of seeing a, instance Data Text, some day? text  
would be a great type to use with Happstack, because it is far more  
memory efficient than String. But it is difficult to do that with  
out a instance of Data.


For the time being, I have been hacking it with:

instance Data Text where
   toConstr x = mkStringConstr textType (Text.unpack x)
   gunfold _k z c = case constrRep c of
 (StringConstr x) -> z (Text.pack x)
 _ -> error "gunfold for Data.Text"
   dataTypeOf _ = textType

But, packing and unpacking the Text is obviously not that cool..

For what it's worth, ByteString is normally exported abstract, and  
just uses, deriving Data. Perhaps we can do the same for text? (I  
believe there are a number of other examples of types in the  
'standard' libraries which are exported abstract, but have Data  
instances...)


- jeremy
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library

2009-10-09 Thread Bryan O'Sullivan
On Fri, Oct 9, 2009 at 1:08 PM, Paulo Tanimoto  wrote:

> I tried to post a comment to your website, but it may have been lost.
> It seems that the description for unlines is picking up a comment that
> was meant for lines':
>

Thanks, yes, Johan sent a patch in to fix that already. Hooray for open
source and distributed revision control systems!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Happstack + network package issue on the Mac

2009-10-09 Thread Gregory Collins
"Bryan O'Sullivan"  writes:

> On Fri, Oct 9, 2009 at 7:25 AM, Gregory Collins  
> wrote:
>  
>
> There's been an open ticket for months; personally I think this is
> a job for the C preprocessor, but nobody's written a patch yet.
>
> Is there an open ticket against the network package? Can someone write
> a simple standalone repro for me that doesn't require happstack
> (i.e. only depends on network)? I have access to a Mac and Johan and I
> co-maintain the network package, so in principle this shouldn't be
> hard to fix, given enough details and pointers.

No, against Happstack. The offending code:

--
-- find out at compile time if the SockAddr6 / HostAddress6
-- constructors are available

supportsIPv6 :: Bool
supportsIPv6 = $(let c = "Network.Socket.SockAddrInet6"; d = ''SockAddr in
 do TyConI (DataD _ _ _ cs _) <- reify d
if isJust (find (\(NormalC n _) -> show n == c) cs)
   then [| True |]
   else [| False |] )
   
...

-- | alternative implementation of accept to work around EAI_AGAIN errors
acceptLite :: S.Socket -> IO (Handle, S.HostName, S.PortNumber)
acceptLite sock = do
  (sock', addr) <- S.accept sock
  h <- S.socketToHandle sock' ReadWriteMode
  (N.PortNumber p) <- N.socketPort sock'
  
  let peer = $(if supportsIPv6
 then
 return $ CaseE (VarE (mkName "addr")) 
[Match 
 (ConP (mkName "S.SockAddrInet") 
  [WildP,VarP (mkName "ha")]) 
 (NormalB (AppE (VarE (mkName 
"showHostAddress")) 
   (VarE (mkName "ha" []
,Match (ConP (mkName "S.SockAddrInet6") 
[WildP,WildP,VarP (mkName "ha"),WildP])
 (NormalB (AppE (VarE (mkName 
"showHostAddress6")) (VarE (mkName "ha" []
,Match WildP (NormalB (AppE (VarE (mkName 
"error")) (LitE (StringL "Unsupported socket" []]
 -- the above mess is the equivalent of this: 
 {-[| case addr of
   (S.SockAddrInet _ ha)  -> showHostAddress ha
   (S.SockAddrInet6 _ _ ha _) -> showHostAddress6 ha
   _  -> error "Unsupported 
socket"
   |]-}
 else
 [| case addr of
  (S.SockAddrInet _ ha)  -> showHostAddress ha
  _  -> error "Unsupported 
socket"
 |])
 
  return (h, peer, p)
--

Frankly I think this approach is dubious at best.

G
-- 
Gregory Collins 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Happstack + network package issue on the Mac

2009-10-09 Thread Anton van Straaten

Bryan O'Sullivan wrote:
On Fri, Oct 9, 2009 at 7:25 AM, Gregory Collins > wrote:
 


There's been an open ticket for months; personally I think this is a job
for the C preprocessor, but nobody's written a patch yet.


Is there an open ticket against the network package? Can someone write a 
simple standalone repro for me that doesn't require happstack (i.e. only 
depends on network)? I have access to a Mac and Johan and I co-maintain 
the network package, so in principle this shouldn't be hard to fix, 
given enough details and pointers.


I have the impression that the problem is at least partly with TH on the 
Mac, and there may not even be any relevant bug in the network package. 
  It's possible that the network package could provide some additional 
support to help Happstack solve this another way, though.


The main problem that Happstack faces here is to avoid referencing the
SockAddrInet6 constructor if it doesn't exist, i.e. if the network 
package was compiled without IPv6 support.


If Happstack had some reliable/portable way of accessing 
IPV6_SOCKET_SUPPORT, a C #define used by the network package, this could 
easily be done with the C preprocessor.  I don't think Cabal is up to 
that task, though.  Happstack would probably have to use its own 
configure script (it doesn't have one right now) to determine IPv6 
status for itself, and hope that it matches what the network package 
found when it was compiled.


The current solution in Happstack is to use TH to detect IPv6 support in 
the network package, by testing for the existence of the SockAddrInet6 
constructor, as follows (reformatted slightly for email):


-- find out at compile time if the SockAddr6 / HostAddress6 constructors
-- are available
supportsIPv6 :: Bool
supportsIPv6 = $(let c = "Network.Socket.SockAddrInet6"
 d = ''SockAddr in
 do TyConI (DataD _ _ _ cs _) <- reify d
if isJust (find (\(NormalC n _) -> show n == c) cs)
   then [| True |]
   else [| False |] )

If I had access to a Mac, the first thing I'd do is check what 
supportsIPv6 is getting set to, and whether it changes depending on the 
version of the network package being used.


However, some comments many months back seemed to indicate that 
supportsIPv6 might be getting set correctly, and that the problem was 
happening later.  In that case, it would be in 
Happstack/Server/HTTP/Socket.hs, which contains this test:


  let peer = $(if supportsIPv6

If supportsIPv6 is False, or somehow incorrectly treated as False, then 
the error message being reported could happen if the provided socket is 
actually IPv6.


Alternatively, if the True branch is taken, then a TH-encoded case 
expression is used to match the SockAddr value, without having to 
reference the SockAddrInet6 constructor directly in code.  But if this 
the part that executes, then for some mysterious reason, it is failing, 
only on the Mac, to match the appropriate constructor.  That sounds like 
a fascinating bug!  I hope someone with a Mac will track it down and let 
us know what was happening...


Anton
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library

2009-10-09 Thread Paulo Tanimoto
Hi Bryan,

On Fri, Oct 9, 2009 at 2:11 AM, Bryan O'Sullivan  wrote:
> Get it while it's fresh on Hackage, folks! Details of the changes here:
> http://bit.ly/1u4UOT
>

This is superb!

I tried to post a comment to your website, but it may have been lost.
It seems that the description for unlines is picking up a comment that
was meant for lines':

http://hackage.haskell.org/packages/archive/text/0.5/doc/html/Data-Text.html#v%3Aunlines

Take care!

Paulo
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] How do I get this done in constant mem?

2009-10-09 Thread mf-hcafe-15c311f0c


Hi all,

I think there is something about my use of the IO monad that bites me,
but I am bored of staring at the code, so here you g.  The code goes
through a list of records and collects the maximum in each record
position.


-- test.hs
import Random
import System.Environment (getArgs)
import System.IO (putStr)

samples :: Int -> Int -> IO [[Double]]
samples i j = sequence . replicate i . sequence . replicate j $ randomRIO (0, 
1000 ** 3)

maxima :: [[Double]] -> [Double]
maxima samples@(_:_) = foldr (\ x y -> map (uncurry max) $ zip x y) (head 
samples) (tail samples)

main = do
  args <- getArgs
  x <- samples (read (head args)) 5
  putStr . (++ "\n") . show $ maxima x


I would expect this to take constant memory (foldr as well as foldl),
but this is what happens:


$ ghc -prof --make -O9 -o test test.hs
[1 of 1] Compiling Main ( test.hs, test.o )
Linking test ...
$ ./test 100 +RTS -p
[9.881155955344708e8,9.910336352165401e8,9.71000686630374e8,9.968532576451201e8,9.996200333115692e8]
$ grep 'total alloc' test.prof 
total alloc = 744,180 bytes  (excludes profiling overheads)
$ ./test 1 +RTS -p
[9.996199711457872e8,9.998928358545277e8,9.99960283632381e8,9.999707142123885e8,9.998952151508758e8]
$ grep 'total alloc' test.prof 
total alloc =  64,777,692 bytes  (excludes profiling overheads)
$ ./test 100 +RTS -p
Stack space overflow: current size 8388608 bytes.
Use `+RTS -Ksize' to increase it.
$ 


so...

does sequence somehow force the entire list of monads into evaluation
before the head of the result list can be used?  what can i do to
implement this in constant memory?

thanks!
matthias
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Num instances for 2-dimensional types

2009-10-09 Thread Ben Franksen
Joe Fredette wrote:
> A ring is an abelian group in addition, with the added operation (*)
> being distributive over addition, and 0 annihilating under
> multiplication. (*) is also associative. Rings don't necessarily need
> _multiplicative_ id, only _additive_ id.

Yes, this is how I learned it in my Algebra course(*). Though I can imagine
that this is not universally agreed upon; indeed most of the more
interesting results need a multiplicative unit, IIRC, so there's a
justification for authors to include it in the basic definition (so they
don't have to say let-R-be-a-ring-with-multiplicative-unit all the time ;-)

Cheers
Ben

(*) As an aside, this was given by one Gernot Stroth, back then still at the
FU Berlin, of whom I later learned that he took part in the grand effort to
classify the simple finite groups. The course was extremely tight but it
was fun and I never again learned so much in one semester.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library

2009-10-09 Thread Jeremy Shaw

Based on section 5.2 of this paper:

http://www.cs.vu.nl/boilerplate/gmap2.pdf

I wonder if the Data instance I provided is the best possible option  
with out modifying SYB. And that the optimal solution would be to  
extend ConstrRep to support Text as a primitive:


data ConstrRep
= AlgConstr ConIndex
| IntConstr Integer
| FloatConstr Double
| StringConstr String
| TextConstr Text -- does not really exist
-- Defined in Data.Data

With the unfortunate side-effect of making syb depend on text.

- jeremy

On Oct 9, 2009, at 2:17 PM, Bryan O'Sullivan wrote:

On Fri, Oct 9, 2009 at 8:33 AM, Jeremy Shaw   
wrote:


What are the chances of seeing a, instance Data Text, some day?

I might as well follow up here, since I've sent Jeremy a couple of  
messages on this subject.


I think maybe someone else will have to take a crack at a Data  
instance for Text, because the documentation for Data.Data is not  
written in English. In its syntax and structure, it closely hews to  
what we think of as English, but it is the kind of documentation  
that can only be understood by someone who already knows what it is  
going to say.


This is an exemplar of my experience with the cottage industry of  
generic programming in Haskell: I'd really quite like to use the  
stuff, but for goodness's sake, o beloved researchers, please aim  
your expository papers at non-specialists once in a while. An  
endless chain of papers of the form "my technique, which you won't  
understand, is better than this other technique, which you haven't  
read about and won't anyway understand, in subtle ways that you  
won't understand" does not feel to me like progress.


Yours in some misery and frustration,
Bryan.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] HDBC PostgreSQL

2009-10-09 Thread Patrick Brannan
Hello,

I'm getting back into Haskell after an absence of a few years. I'm in
the process of trying to connect to postgresql with hdbc-postgresql on
a Windows XP box.

Seemingly, things installed without  a problem, but at the command
prompt I get the following:

Prelude> :module Database.HDBC Database.HDBC.PostgreSQL
module `Database.HDBC.PostgreSQL' is not loaded

If I run ghci this way with package options here's what I get:

C:\work\haskell\HDBC-postgresql-2.1.0.0>ghci -package HDBC -package
HDBC-postgresql
GHCi, version 6.10.4: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Loading package HUnit-1.2.0.3 ... linking ... done.
Loading package syb ... linking ... done.
Loading package base-3.0.3.1 ... linking ... done.
Loading package old-locale-1.0.0.1 ... linking ... done.
Loading package old-time-1.0.0.2 ... linking ... done.
Loading package random-1.0.0.1 ... linking ... done.
Loading package QuickCheck-1.2.0.0 ... linking ... done.
Loading package bytestring-0.9.1.4 ... linking ... done.
Loading package array-0.2.0.0 ... linking ... done.
Loading package containers-0.2.0.1 ... linking ... done.
Loading package mtl-1.1.0.2 ... linking ... done.
Loading package Win32-2.2.0.0 ... linking ... done.
Loading package time-1.1.4 ... linking ... done.
Loading package convertible-1.0.5 ... linking ... done.
Loading package filepath-1.1.0.2 ... linking ... done.
Loading package directory-1.0.0.3 ... linking ... done.
Loading package process-1.0.1.1 ... linking ... done.
Loading package haskell98 ... linking ... done.
Loading package testpack-1.0.2 ... linking ... done.
Loading package utf8-string-0.3.5 ... linking ... done.
Loading package HDBC-2.1.1 ... linking ... done.
Loading package parsec-2.1.0.1 ... linking ... done.
Loading package HDBC-postgresql-2.1.0.0 ... linking ... done.
Prelude> module HDBC HDBC.PostgreSQL

Now I would think that the line "Loading package
HDBC-postgresql-2.1.0.0 ... linking ... done." means that the module
is installed correctly, but I still can't execute the :module
statement.

Does anyone have any ideas about where I should start? It's probably
something stupid, but I'm a little worn out on searching.

Thank you,
Patrick
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Happstack + network package issue on the Mac

2009-10-09 Thread Bryan O'Sullivan
On Fri, Oct 9, 2009 at 7:25 AM, Gregory Collins wrote:


> There's been an open ticket for months; personally I think this is a job
> for the C preprocessor, but nobody's written a patch yet.


Is there an open ticket against the network package? Can someone write a
simple standalone repro for me that doesn't require happstack (i.e. only
depends on network)? I have access to a Mac and Johan and I co-maintain the
network package, so in principle this shouldn't be hard to fix, given enough
details and pointers.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library

2009-10-09 Thread Bryan O'Sullivan
On Fri, Oct 9, 2009 at 8:33 AM, Jeremy Shaw  wrote:

>
> What are the chances of seeing a, instance Data Text, some day?


I might as well follow up here, since I've sent Jeremy a couple of messages
on this subject.

I think maybe someone else will have to take a crack at a Data instance for
Text, because the documentation for Data.Data is not written in English. In
its syntax and structure, it closely hews to what we think of as English,
but it is the kind of documentation that can only be understood by someone
who already knows what it is going to say.

This is an exemplar of my experience with the cottage industry of generic
programming in Haskell: I'd really quite like to use the stuff, but for
goodness's sake, o beloved researchers, please aim your expository papers at
non-specialists once in a while. An endless chain of papers of the form "my
technique, which you won't understand, is better than this other technique,
which you haven't read about and won't anyway understand, in subtle ways
that you won't understand" does not feel to me like progress.

Yours in some misery and frustration,
Bryan.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: ANNOUNCE: htzaar-0.0.1

2009-10-09 Thread Jose A. Ortega Ruiz
Tom Hawkins  writes:

> Sorry, I forgot to add the other modules to the cabal file.  Try
> htzaar-0.0.2.

Thank you, it's working now.

jao
-- 
The reasonable man adapts himself to the world; the unreasonable
one persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man. - George Bernard Shaw

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] CBN, CBV, Lazy in the same final tagless framework

2009-10-09 Thread David Menendez
On Fri, Oct 9, 2009 at 1:39 PM, Felipe Lessa  wrote:
> On Fri, Oct 09, 2009 at 01:27:57PM -0400, David Menendez wrote:
>> On Fri, Oct 9, 2009 at 11:12 AM, Felipe Lessa  wrote:
>> > That's really nice, Oleg, thanks!  I just wanted to comment that
>> > I'd prefer to write
>> >
>> > share :: IO a -> IO (IO a)
>> > share m = mdo r <- newIORef (do x <- m
>> >                                writeIORef r (return x)
>> >                                return x)
>> >              return (readIORef r >>= id)
>> >
>> > which unfortunately needs {-# LANGUAGE RecursiveDo #-} or
>> > some ugliness from mfix
>> >
>> > share :: IO a -> IO (IO a)
>> > share m = do r <- mfix $ \r -> newIORef (do x <- m
>> >                                            writeIORef r (return x)
>> >                                            return x)
>> >             return (readIORef r >>= id)
>> >
>>
>> Alternatively,
>>
>> share m = do
>>     r <- newIORef undefined
>>     writeIORef r $ do
>>         x <- m
>>         writeIORef r (return x)
>>         return x
>>     return $ readIORef r >>= id
>>
>> Which is basically the same as your version, but only needs one IORef.
>
> Hmmm, but my version also needs only one IORef, right?  In fact I
> first wrote the same code as yours but I've frowned upon the need
> of having that 'undefined' and an extra 'writeIORef'.

It's in the implementation of mfix for IO. From System.IO,

fixIO :: (a -> IO a) -> IO a
fixIO k = do
ref <- newIORef (throw NonTermination)
ans <- unsafeInterleaveIO (readIORef ref)
result <- k ans
writeIORef ref result
return result

If we inline that into your definition, we get

share m = do
ref <- newIORef (throw NonTermination)
ans <- unsafeInterleaveIO (readIORef ref)
r <- newIORef $ do { x <- m; writeIORef ans (return x); return x }
writeIORef ref r
return (readIORef r >>= id)

So behind the scenes, the mfix version still creates an IORef with
undefined and has an extra writeIORef.

It also has that unsafeInterleaveIO, but I don't think there's any way
that can cause a problem.


Incidentally, none of the versions of share discussed so far are
thread-safe. Specifically, if a second thread starts to evaluate the
result of share m while the first thread is still evaluating m, we end
up with the effects of m happening twice. Here's a version that avoids
this by using a semaphore.

share m = do
r <- newIORef undefined
s <- newMVar False
writeIORef r $ do
b <- takeMVar s
if b
then do
putMVar s True
readIORef r >>= id
else do
x <- m
writeIORef r (return x)
putMVar s True
return x
return $ readIORef r >>= id

In the worst case, MVar will get read at most once per thread, so the
overhead is limited. Under normal circumstances, the MVar will be read
once and then discarded.

-- 
Dave Menendez 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library

2009-10-09 Thread Bryan O'Sullivan
On Fri, Oct 9, 2009 at 8:33 AM, Jeremy Shaw  wrote:

>
> What are the chances of seeing a, instance Data Text, some day? text would
> be a great type to use with Happstack, because it is far more memory
> efficient than String. But it is difficult to do that with out a instance of
> Data.


Ask, and you shall receive :-)

I'll take a look.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Applicative do?

2009-10-09 Thread Edward Kmett
I have idiom brackets in that toy library already, but the ado syntax is
fairly useful if you want to refer to several intermediate results by name.
To work with idiom brackets you need to manually write a big lambda yourself
and them apply it. If you have a lambda that takes several arguments --
which isn't all that uncommon in a parser! -- the names you are binding and
their position in the input can get rather far apart, even using idiom
sugar. Philippa's ado sugar lets you amortize that big binding statement
over several lines and keeps the names closer to the binding.

Not sure that it warrants a syntax extension in the Haskell case, but it is
pretty convenient. =)

-Edward Kmett

On Fri, Oct 9, 2009 at 1:52 PM, Daniel Peebles  wrote:

> I'd prefer "idiom brackets" over something do-ish for Applicatives.
> Conor McBride's SHE already supports them, if you're willing to use a
> custom preprocessor.
>
> On Fri, Oct 9, 2009 at 1:45 PM, Joe Fredette  wrote:
> > The only issue I would have with such a notation is not being able to
> > visually tell the difference between a monadic function (say, without a
> > explicit type sig, which is how I write parsers), and an applicative one.
> >
> > I'd prefer something like
> >
> > foo = app
> >blah blah
> >
> > If only for some visual distinction, I think it also resolves the "do
> > knowing about types" issue.
> >
> > Plus, this is a good case for some kind of custom-do syntax facility. So
> we
> > could make do syntax for everything. :)
> >
> > /Joe
> >
> > On Oct 9, 2009, at 1:11 PM, Robert Atkey wrote:
> >
> >> On Fri, 2009-10-09 at 18:06 +0100, Philippa Cowderoy wrote:
> >>
> >>> This leads us to the bikeshed topic: what's the concrete syntax?
> >>
> >> I implemented a simple Camlp4 syntax extension for Ocaml to do this. I
> >> chose the syntax:
> >>
> >>  applicatively
> >>  let x = foo
> >>  let y = bar
> >>  in 
> >>
> >> I quite like the word "applicatively".
> >>
> >> Your overloading suggestion sounds to me like it would require the
> >> desugaring process to know something about types, but I'm not sure.
> >>
> >> Bob
> >>
> >>
> >> --
> >> The University of Edinburgh is a charitable body, registered in
> >> Scotland, with registration number SC005336.
> >>
> >> ___
> >> Haskell-Cafe mailing list
> >> Haskell-Cafe@haskell.org
> >> http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
> > ___
> > Haskell-Cafe mailing list
> > Haskell-Cafe@haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
> >
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Applicative do?

2009-10-09 Thread Daniel Peebles
I'd prefer "idiom brackets" over something do-ish for Applicatives.
Conor McBride's SHE already supports them, if you're willing to use a
custom preprocessor.

On Fri, Oct 9, 2009 at 1:45 PM, Joe Fredette  wrote:
> The only issue I would have with such a notation is not being able to
> visually tell the difference between a monadic function (say, without a
> explicit type sig, which is how I write parsers), and an applicative one.
>
> I'd prefer something like
>
> foo = app
>        blah blah
>
> If only for some visual distinction, I think it also resolves the "do
> knowing about types" issue.
>
> Plus, this is a good case for some kind of custom-do syntax facility. So we
> could make do syntax for everything. :)
>
> /Joe
>
> On Oct 9, 2009, at 1:11 PM, Robert Atkey wrote:
>
>> On Fri, 2009-10-09 at 18:06 +0100, Philippa Cowderoy wrote:
>>
>>> This leads us to the bikeshed topic: what's the concrete syntax?
>>
>> I implemented a simple Camlp4 syntax extension for Ocaml to do this. I
>> chose the syntax:
>>
>>  applicatively
>>  let x = foo
>>  let y = bar
>>  in 
>>
>> I quite like the word "applicatively".
>>
>> Your overloading suggestion sounds to me like it would require the
>> desugaring process to know something about types, but I'm not sure.
>>
>> Bob
>>
>>
>> --
>> The University of Edinburgh is a charitable body, registered in
>> Scotland, with registration number SC005336.
>>
>> ___
>> Haskell-Cafe mailing list
>> Haskell-Cafe@haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Applicative do?

2009-10-09 Thread Joe Fredette
The only issue I would have with such a notation is not being able to  
visually tell the difference between a monadic function (say, without  
a explicit type sig, which is how I write parsers), and an applicative  
one.


I'd prefer something like

foo = app
blah blah

If only for some visual distinction, I think it also resolves the "do  
knowing about types" issue.


Plus, this is a good case for some kind of custom-do syntax facility.  
So we could make do syntax for everything. :)


/Joe

On Oct 9, 2009, at 1:11 PM, Robert Atkey wrote:


On Fri, 2009-10-09 at 18:06 +0100, Philippa Cowderoy wrote:


This leads us to the bikeshed topic: what's the concrete syntax?


I implemented a simple Camlp4 syntax extension for Ocaml to do this. I
chose the syntax:

  applicatively
  let x = foo
  let y = bar
  in 

I quite like the word "applicatively".

Your overloading suggestion sounds to me like it would require the
desugaring process to know something about types, but I'm not sure.

Bob


--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] CBN, CBV, Lazy in the same final tagless framework

2009-10-09 Thread Felipe Lessa
On Fri, Oct 09, 2009 at 01:27:57PM -0400, David Menendez wrote:
> On Fri, Oct 9, 2009 at 11:12 AM, Felipe Lessa  wrote:
> > That's really nice, Oleg, thanks!  I just wanted to comment that
> > I'd prefer to write
> >
> > share :: IO a -> IO (IO a)
> > share m = mdo r <- newIORef (do x <- m
> >                                writeIORef r (return x)
> >                                return x)
> >              return (readIORef r >>= id)
> >
> > which unfortunately needs {-# LANGUAGE RecursiveDo #-} or
> > some ugliness from mfix
> >
> > share :: IO a -> IO (IO a)
> > share m = do r <- mfix $ \r -> newIORef (do x <- m
> >                                            writeIORef r (return x)
> >                                            return x)
> >             return (readIORef r >>= id)
> >
>
> Alternatively,
>
> share m = do
> r <- newIORef undefined
> writeIORef r $ do
> x <- m
> writeIORef r (return x)
> return x
> return $ readIORef r >>= id
>
> Which is basically the same as your version, but only needs one IORef.

Hmmm, but my version also needs only one IORef, right?  In fact I
first wrote the same code as yours but I've frowned upon the need
of having that 'undefined' and an extra 'writeIORef'.

Thanks,

--
Felipe.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Applicative do?

2009-10-09 Thread Edward Kmett
Good trick. I just added 'ado' to my little scheme monad library. ;)

-Edward Kmett

On Fri, Oct 9, 2009 at 1:06 PM, Philippa Cowderoy wrote:

> I do a lot of work with parsers, and want to do more using Applicatives.
> That said, I'm finding it a little tedious being forced to use pointless
> style for a task that's well-suited to having a few names around. The idea
> of an applicative do notation's been kicked around on #haskell a few times
> (I can't find any trace of it on the mailing list, but I confess to not
> having searched too hard), so I thought I'd propose it here.
>
> The basic idea is to turn this:
>
> do a <- f
>  g
>  b <- h
>  pure $ foo a b
>
> into this:
>
> (\a b -> pure $ foo a b) <*> (f <*> g *> h)
>
> Aside from changing >>= and >> into <*> and *>, the most significant
> difference from monadic do is that all the generated lambda abstractions go
> in front of the final "return" statement which is then fmapped across the
> rest of the code. Bindings are thus only in scope in the "return" statement.
> I believe sugared let statements can be handled similarly so long as they
> respect the binding discipline.
>
> This leads us to the bikeshed topic: what's the concrete syntax? The
> obvious way is to replace do with a new keyword - for example, ado for
> "applicative do". There's a nice alternative though: we can check whether a
> do statement meets the binding rules for an applicative block and treat it
> as one if so, or a monadic one if not. While not all Monads are
> Applicatives, code can readily be changed back using the WrappedMonad
> newtype - whereas existing code needn't turn on the appropriate extension in
> the first place.
>
> Thoughts, comments?
>
> --
> fli...@flippac.org
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Applicative do?

2009-10-09 Thread Philippa Cowderoy

Robert Atkey wrote:

On Fri, 2009-10-09 at 18:06 +0100, Philippa Cowderoy wrote:

  
This leads us to the bikeshed topic: what's the concrete syntax? 



I implemented a simple Camlp4 syntax extension for Ocaml to do this. I
chose the syntax:

   applicatively
   let x = foo
   let y = bar
   in 

I quite like the word "applicatively".

  


In an ML context I rather like it! It doesn't really feel haskelly to me 
though, partly because code that looks like ANF in Haskell is normally 
in a do block and failing that a single let block instead of a series of 
nested lets.



Your overloading suggestion sounds to me like it would require the
desugaring process to know something about types, but I'm not sure.

  


It doesn't the way I've suggested it, whereas doing it perfectly would 
do because not all Monads are directly Applicatives. I just reckon the 
imperfection isn't too big a burden applied to new code when you can 
newtype Monads into Applicatives on demand and get sensible code.


--
fli...@flippac.org
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] CBN, CBV, Lazy in the same final tagless framework

2009-10-09 Thread David Menendez
On Fri, Oct 9, 2009 at 11:12 AM, Felipe Lessa  wrote:
> On Thu, Oct 08, 2009 at 12:54:14AM -0700, o...@okmij.org wrote:
>> Actually it is possible to implement all three evaluation orders
>> within the same final tagless framework, using the same interpretation
>> of types and reusing most of the code save the semantics of lam. That
>> is where the three orders differ, by their own definition.
>
> That's really nice, Oleg, thanks!  I just wanted to comment that
> I'd prefer to write
>
> share :: IO a -> IO (IO a)
> share m = mdo r <- newIORef (do x <- m
>                                writeIORef r (return x)
>                                return x)
>              return (readIORef r >>= id)
>
> which unfortunately needs {-# LANGUAGE RecursiveDo #-} or
> some ugliness from mfix
>
> share :: IO a -> IO (IO a)
> share m = do r <- mfix $ \r -> newIORef (do x <- m
>                                            writeIORef r (return x)
>                                            return x)
>             return (readIORef r >>= id)
>

Alternatively,

share m = do
r <- newIORef undefined
writeIORef r $ do
x <- m
writeIORef r (return x)
return x
return $ readIORef r >>= id

Which is basically the same as your version, but only needs one IORef.

-- 
Dave Menendez 

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Setting environment variables on Windows

2009-10-09 Thread Peter Verswyvelen
Mmm, that seems like a shortcoming.

Well, you could just wrap the C functions yourself, like this (two
possibilities, no error checking yet, quick hack):
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=10565#a10565

Note that using SetEnvironmentVariable does not seem to be compatible with
getEnv, but calling _putenv does work.

So I guess someone should add this setEnv wrapper to the System.Environment
module? Ticket?


On Fri, Oct 9, 2009 at 5:37 PM, Sönke Hahn  wrote:
> Hi!
>
> I need to set an environment variable from Haskell and i would like to do
that
> cross-platform. There is System.Posix.Env.setEnv, which does exactly, what
i
> want on Linux. There is the module System.Environment, which seems to be
> cross-platform, but it does not contain functions to manipulate the
> environment (, just to inspect it). At first glance, I didn't find
anything
> relevant in the sub-modules of System.Win32.
>
> Is this just not implemented? How could i implement it myself?
>
> Grateful for any comment,
>
> Sönke
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Applicative do?

2009-10-09 Thread Robert Atkey
On Fri, 2009-10-09 at 18:06 +0100, Philippa Cowderoy wrote:

> This leads us to the bikeshed topic: what's the concrete syntax? 

I implemented a simple Camlp4 syntax extension for Ocaml to do this. I
chose the syntax:

   applicatively
   let x = foo
   let y = bar
   in 

I quite like the word "applicatively".

Your overloading suggestion sounds to me like it would require the
desugaring process to know something about types, but I'm not sure.

Bob


-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Applicative do?

2009-10-09 Thread Philippa Cowderoy
I do a lot of work with parsers, and want to do more using Applicatives. 
That said, I'm finding it a little tedious being forced to use pointless 
style for a task that's well-suited to having a few names around. The 
idea of an applicative do notation's been kicked around on #haskell a 
few times (I can't find any trace of it on the mailing list, but I 
confess to not having searched too hard), so I thought I'd propose it here.


The basic idea is to turn this:

do a <- f
  g
  b <- h
  pure $ foo a b

into this:

(\a b -> pure $ foo a b) <*> (f <*> g *> h)

Aside from changing >>= and >> into <*> and *>, the most significant 
difference from monadic do is that all the generated lambda abstractions 
go in front of the final "return" statement which is then fmapped across 
the rest of the code. Bindings are thus only in scope in the "return" 
statement. I believe sugared let statements can be handled similarly so 
long as they respect the binding discipline.


This leads us to the bikeshed topic: what's the concrete syntax? The 
obvious way is to replace do with a new keyword - for example, ado for 
"applicative do". There's a nice alternative though: we can check 
whether a do statement meets the binding rules for an applicative block 
and treat it as one if so, or a monadic one if not. While not all Monads 
are Applicatives, code can readily be changed back using the 
WrappedMonad newtype - whereas existing code needn't turn on the 
appropriate extension in the first place.


Thoughts, comments?

--
fli...@flippac.org
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Libraries for Commercial Users

2009-10-09 Thread Duncan Coutts
On Thu, 2009-10-08 at 09:43 -0600, John A. De Goes wrote:
> Here's a list of libraries that are quite significant to commercial  
> software development in 2009,

For the kinds of applications that you would like to build.

> but which either do not exist in Haskell, or if they exist, are hard
> to find, undocumented, unstable, or perhaps uncompilable:

Certainly having more libs enables more apps and that stuff would enable
your applications. Fortunately it's not an all-or-nothing thing. There
are plenty of applications we can do now. For the commercial software
I've developed in Haskell, all the libraries I've needed were available
and sufficiently mature: decent data structures, binary serialisation,
fast random numbers, date/time handling, GUI lib.

Duncan

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Haskell Weekly News

2009-10-09 Thread Joe Fredette
Mostly it's been issues with sendmail, I think I have them fixed for  
this week. (I think...)


Thanks for the input!

/Joe


On Oct 9, 2009, at 4:46 AM, Benjamin L.Russell wrote:


Thank you for including my quote (by "dekudekuplex"), and great work
so far!

Just a couple of minor comments:

1) It might be useful for referencing by subject if you could include
the issue number and date in the subject line (e.g., " Haskell Weekly
News: Issue 131 - September 25, 2009") instead of only "Haskell Weekly
News."

2) Instead of posting separately to the Haskell and Haskell-Cafe
mailing lists, it might be better to cross-post, since that way,
readers using newsreaders can have the cross-posted article
automatically marked "read" in the mailing list where it has not been
read.

Other than that, hope that you get over your sinus infection, and keep
up the good work!

Benjamin L. Russell

On Sat, 03 Oct 2009 09:46:25 -0700 (PDT), Joe Fredette
 wrote:



---
Haskell Weekly News
http://sequence.complete.org/hwn/20091003
Issue 134 - October 03, 2009
---
 Welcome to issue 134 of HWN, a newsletter covering developments in  
the

 [1]Haskell community.

 I have a nasty sinus infection this week, so we're somewhat light on
 content. Lots of good discussion about DSL related stuff this week.
 Bryan O'Sullivan also release 'Criterion' this week, a new  
benchmarking

 library that Don Stewart described (on reddit) as 'awesome and game
 changing.' A new TMR editor -- someone familiar -- was announced.  
Also,
 there was some talk about homework policies on the mailinglists  
and in

 the irc channels. There is a [2]page on the Haskell wiki about this,
 but to sum it up in a maxim, remember, 'Help, don't do'. Until next
 week, the Haskell Weekly News!

Announcements

 New TMR editor. Wouter Swierstra [3]announced that he would be  
stepping
 down from the editorship of 'The Monad Reader', with former HWN  
editor
 Brent Yorgey taking his place. Much thanks for Wouter's hard work  
and

 good luck to Brent on his new editor job!

 SourceGraph 0.5.{0,1,2}.0. Ivan Lazar Miljenovic [4]announced  
three new
 releases of the SourceGraph packages, this links to the latest  
release.


 json-b-0.0.4. Jason Dusek [5]announced a new version of the json-b
 package, which fixes defective handling of empty objects and arrays.

 rss2irc 0.4 released. Simon Michael [6]announced a new release of
 rss2irc, with many new improvements and features.

 vty-ui 0.1. Jonathan Daugherty [7]announced vty-ui, which is an
 extensible library of user interface widgets for composing and  
laying

 out Vty user interfaces.

 atom-0.1.1. Tom Hawkins [8]announced Atom, a Haskell DSL for  
designing

 hard real-time embedded applications.

 Graphalyze-0.7.0.0. Ivan Lazar Miljenovic [9]announced (in an  
apparent
 effort to take over hackage by submitting dozens of quality  
packages at
 absurdly high speed), Graphalyze, a library for using graph- 
theoretic
 techniques to analyse the relationships inherent within discrete  
data.


 Criterion. Bryan O'Sullivan [10]announced (without tacking on an  
'ANN'

 tag, I might add, I almost missed it!) Criterion, a benchmarking
 library he describes [11]here.

 ListTree 0.1. yair...@gmail.com [12]announced ListTree, a package  
for

 combinatorial search and pruning of trees.

 usb-0.1. Bas van Dijk [13]announced a library for interacting with  
usb

 modules from userspace.

 (Deadline extended to October 5th) APLAS 2009 Call for Posters.
 Kiminori Matsuzaki [14]announced a deadline extension to the call  
for

 posters for the APLAS conference.

 graphviz-2999.6.0.0. Ivan Lazar Miljenovic [15]announced a new  
version
 of the graphviz library, which features various new features and  
small

 changes.

Discussion

 Testing polymorphic properties with QuickCheck. Jean-Philippe  
Bernardy

 [16]gave an excellent overview about how to use QuickCheck to test
 polymorphic properties.

 Designing a DSL? Gunther Schmidt [17]asked about different methods
 employed for designing a DSL.

 DSL and GUI Toolkits. Gunther Schmidt [18]also asked about different
 DSLs for working with GUIs

 error on "--++ bla bla bla". Hong Yang [19]asked about why '--++'
 wasn't being parsed in the way he thought it was.

 Haskell for Physicists. edgar [20]requested name suggestions for the
 talk he is giving about Physics and Haskell.

Blog noise

 [21]Haskell news from the [22]blogosphere. Blog posts from people  
new
 to the Haskell community are marked with >>>, be sure to welcome  
them!
   * Sean Leather: [23]'Extensibility and type safety in  
formatting: the

 design of xformat' at the Dutch HUG.
   * Martijn van Steenbergen: [24]let 5 = 6.
   * Lee Pike: [25]Writer's unblock.
   * Manuel M T Chakravarty: [26]NVIDIAs next generation GPU
 architecture has a lot for HPC to love.
   * David A

[Haskell-cafe] Setting environment variables on Windows

2009-10-09 Thread Sönke Hahn
Hi!

I need to set an environment variable from Haskell and i would like to do that 
cross-platform. There is System.Posix.Env.setEnv, which does exactly, what i 
want on Linux. There is the module System.Environment, which seems to be 
cross-platform, but it does not contain functions to manipulate the 
environment (, just to inspect it). At first glance, I didn't find anything 
relevant in the sub-modules of System.Win32.

Is this just not implemented? How could i implement it myself? 

Grateful for any comment,

Sönke
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library

2009-10-09 Thread Jeremy Shaw

Sweet!

What are the chances of seeing a, instance Data Text, some day? text  
would be a great type to use with Happstack, because it is far more  
memory efficient than String. But it is difficult to do that with out  
a instance of Data.


For the time being, I have been hacking it with:

instance Data Text where
toConstr x = mkStringConstr textType (Text.unpack x)
gunfold _k z c = case constrRep c of
  (StringConstr x) -> z (Text.pack x)
  _ -> error "gunfold for Data.Text"
dataTypeOf _ = textType

But, packing and unpacking the Text is obviously not that cool..

For what it's worth, ByteString is normally exported abstract, and  
just uses, deriving Data. Perhaps we can do the same for text? (I  
believe there are a number of other examples of types in the  
'standard' libraries which are exported abstract, but have Data  
instances...)


- jeremy
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] CBN, CBV, Lazy in the same final tagless framework

2009-10-09 Thread Felipe Lessa
On Thu, Oct 08, 2009 at 12:54:14AM -0700, o...@okmij.org wrote:
> Actually it is possible to implement all three evaluation orders
> within the same final tagless framework, using the same interpretation
> of types and reusing most of the code save the semantics of lam. That
> is where the three orders differ, by their own definition.

That's really nice, Oleg, thanks!  I just wanted to comment that
I'd prefer to write

share :: IO a -> IO (IO a)
share m = mdo r <- newIORef (do x <- m
writeIORef r (return x)
return x)
  return (readIORef r >>= id)

which unfortunately needs {-# LANGUAGE RecursiveDo #-} or
some ugliness from mfix

share :: IO a -> IO (IO a)
share m = do r <- mfix $ \r -> newIORef (do x <- m
writeIORef r (return x)
return x)
 return (readIORef r >>= id)

Thanks,

--
Felipe.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Non-traversable foldables

2009-10-09 Thread Ross Paterson
On Fri, Oct 09, 2009 at 04:45:01PM +0200, Henning Thielemann wrote:
> Recently I wondered, why Foldable is superclass of Traversable,
> since I have examples where 'traverse' makes sense, but 'fold' not.
> 
> http://www.haskell.org/pipermail/libraries/2009-February/011361.html

That would be surprising, since fold can be defined in terms of traverse.
The link doesn't seem to contain any such examples.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Non-traversable foldables

2009-10-09 Thread Edward Kmett
On Fri, Oct 9, 2009 at 10:45 AM, Henning Thielemann <
lemm...@henning-thielemann.de> wrote:

>
> On Fri, 9 Oct 2009, Martijn van Steenbergen wrote:
>
> Hallo café,
>>
>> Can anyone think of datatypes that are Foldable but not Traversable?
>
>
Data.Set.Set is a good example. The values contained in the Set are critical
to the well-formedness of the data structure. Foldables let you iterate over
a container while preserving structure, Traversables allow you to swap out
the contents, but preserve the existing structure. Since you can do that you
get fmap for free.


>  If not, what is the purpose of having a separate Foldable class?
>>
>
> Recently I wondered, why Foldable is superclass of Traversable, since I
> have examples where 'traverse' makes sense, but 'fold' not.
>
> http://www.haskell.org/pipermail/libraries/2009-February/011361.html
>

The superclass is there simply because there is a free implementation of
foldMap (and fmap) given a Traversable instance, and it is useful to have
access to all of those methods without building up a big long dictionary
list, or having to clone them to make Traversable-specific versions)

-Edward



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


Re: [Haskell-cafe] Non-traversable foldables

2009-10-09 Thread Ross Paterson
On Fri, Oct 09, 2009 at 04:41:05PM +0200, Martijn van Steenbergen wrote:
> Can anyone think of datatypes that are Foldable but not Traversable?

Set
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Non-traversable foldables

2009-10-09 Thread Henning Thielemann


On Fri, 9 Oct 2009, Martijn van Steenbergen wrote:


Hallo café,

Can anyone think of datatypes that are Foldable but not Traversable?

If not, what is the purpose of having a separate Foldable class?


Recently I wondered, why Foldable is superclass of Traversable, since I 
have examples where 'traverse' makes sense, but 'fold' not.


http://www.haskell.org/pipermail/libraries/2009-February/011361.html___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Non-traversable foldables

2009-10-09 Thread Martijn van Steenbergen

Hallo café,

Can anyone think of datatypes that are Foldable but not Traversable?

If not, what is the purpose of having a separate Foldable class?

Thanks,

Martijn.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Happstack + network package issue on the Mac

2009-10-09 Thread Anton van Straaten

Gregory Collins wrote:

Sean Leather  writes:


On Thu, Oct 8, 2009 at 16:35, Gregory Collins wrote:

Sean Leather  writes:



Do you know if it's possible to permanently patch happstack-server?
I'm guessing the TH in the patch is used to support multiple versions
of the network package. Can we just change the minimum supported
version?


There's been an open ticket for months; personally I think this is a job
for the C preprocessor, but nobody's written a patch yet. I'm not sure
but I think IPv6 template Haskell stuff is there not to support old
versions of network, but to support platforms where IPv6 may not be
available.


I don't recall whether there was some objection to this suggestion 
previously, but assuming IPv6 support is available might work on more 
platforms.  Then special action would only need to be taken on platforms 
that lack IPv6.


Anton

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: ANNOUNCE: htzaar-0.0.1

2009-10-09 Thread Tom Hawkins
On Fri, Oct 9, 2009 at 2:24 PM, Jose A. Ortega Ruiz  wrote:
>
> Hi,
>
> When i try to cabal install htzaar i get the following error:
>
> src/Main.hs:11:7:
>    Could not find module `Play':
>      Use -v to see a list of the files searched for.
> cabal: Error: some packages failed to install:
> htzaar-0.0.1 failed during the building phase. The exception was:
> exit: ExitFailure 1
>
> Any idea about what's going on?


Sorry, I forgot to add the other modules to the cabal file.  Try htzaar-0.0.2.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Happstack + network package issue on the Mac

2009-10-09 Thread Gregory Collins
Sean Leather  writes:

> On Thu, Oct 8, 2009 at 16:35, Gregory Collins wrote:
>
> Sean Leather  writes:
>
> > We have run into an issue that it seems other people have already
> > found but has apparently not been resolved, yet. It manifests as with
> > the error "HTTP request failed with: Unsupported socket". The problem
> > is described in two places with different workarounds.
> >
> >   http://code.google.com/p/happstack/issues/detail?id=88
> >   http://groups.google.com/group/HAppS/msg/0c9a0d0fd7c6aff0
> >
> > One workaround is to rewrite part of the network package, and the
> > other is to downgrade the package. It could be the case that the
> > rewrite came from the older version, though I'm not sure.
> >
> > I'm curious if it is possible to fix this, either in Happstack or the
> > network package, once and for all. The workarounds are rather painful
> > when so many things depend on the network package.
>
> The following patch to happstack works for me:
>
> This worked for us as well. Thanks, Gregory.
>
> Do you know if it's possible to permanently patch happstack-server?
> I'm guessing the TH in the patch is used to support multiple versions
> of the network package. Can we just change the minimum supported
> version?

There's been an open ticket for months; personally I think this is a job
for the C preprocessor, but nobody's written a patch yet. I'm not sure
but I think IPv6 template Haskell stuff is there not to support old
versions of network, but to support platforms where IPv6 may not be
available.

G
-- 
Gregory Collins 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: ANNOUNCE: htzaar-0.0.1

2009-10-09 Thread Khudyakov Alexey
В сообщении от 09 октября 2009 16:24:49 Jose A. Ortega Ruiz написал:
> Hi,
> 
> When i try to cabal install htzaar i get the following error:
> 
> src/Main.hs:11:7:
> Could not find module `Play':
>   Use -v to see a list of the files searched for.
> cabal: Error: some packages failed to install:
> htzaar-0.0.1 failed during the building phase. The exception was:
> exit: ExitFailure 1
> 
> Any idea about what's going on?
> 
Modules AI, Play and Board are missing I believe
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Can HXT and Parsec 3 be used in the same library?

2009-10-09 Thread Duncan Coutts
On Sun, 2009-10-04 at 10:32 -0700, John Millikin wrote:

> I'm writing a library that needs to parse both plain text (with Parsec)
> and XML (with HXT). HXT's .cabal file specifies that it only works with
> parsec (>= 2.1 && < 3), but it still builds when I depend on parsec >=
> 3. It's only during "cabal install" that the following error is displayed:
> 
> - 
> Resolving dependencies...
> cabal-1.7.3: cannot configure hxt-8.3.1. It requires parsec >=2.1 && <3
> For the dependency on parsec >=2.1 && <3 there are these packages:
> parsec-2.1.0.0 and parsec-2.1.0.1. However none of them are available.
> parsec-2.1.0.0 was excluded because dbus-core-0.5 requires parsec >=3.0.0
> parsec-2.1.0.1 was excluded because dbus-core-0.5 requires parsec >=3.0.0
> - 
> 
> Is there a good solution to this?

Not really. Not at the moment.

We have this restriction because of the dreaded diamond dependency
problem:

http://blog.well-typed.com/2008/04/the-dreaded-diamond-dependency-problem/

It's likely that this problem would not actually occur in your example
because presumably HXT does not re-export types from the parsec package.
However cabal does not have enough information to know that it does not,
so it takes the conservative view.

We could do rather better if we could declare private or public
dependencies. The point with private ones being that you'd not be
allowed to use types from the private package in your public API. In
your example parsec would probably be a private dependency of HXT and
thus we would not care what version of parsec it was using, it couldn't
cause any problems.

> I was thinking about changing my library to use Parsec 2, but that
> just pushes the problem to my users, it doesn't really solve it.

Right.

Duncan

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Approaches to dependent types (DT)

2009-10-09 Thread pat browne
Hi,
I am trying to understand the concept of dependent types as described in
Haskell literature (Hallgren 2001),(Hinze,Jeuring et al. 2006). I am
particularly interested in understanding two flavours of dependency
mentioned by Hinze et al:
1) Types depending on values called dependent types
2) Types depending on types called parametric and type-indexed types

I think that ascending levels of abstraction are important here: values
- types - classes (Hallgren 2001). Here is a Haskell example of the use
of DT:

class Named object name | object -> name where
name :: object -> name

instance (Eq name, Named object name) => Eq object where
object1 == object2 = (name object1) == (name object2)

I think that the intended semantics are:
1) Objects have names  and can be compared for equality using these names.
2) Two objects are considered equal (identical) if they have the same name.
3) The type of a name depends on the type of the object, which gets
expressed as a type dependency (object -> name).
I am not sure about the last semantic it might be interpreted as "the
named object depends on..". This may indicate a flaw in my understanding
of DT.

I am aware that dependent types can be used to express constraints on
the size of lists and other collections. My understanding of Haskell's
functional dependency is that object -> name indicates that fixing the
type object should fix the type name (equivalently we could say that
type name depends on type object). The class definition seems to show a
*type-to-type* dependency (object to name), while the instance
definition shows how a name value is used to define equality for objects
which could be interpreted as a *value-to-type* dependency (name to
object) in the opposite direction to that of the class.

My questions are:
Question 1: Is my understanding correct?
Question 2: What flavour of DT is this does this example exhibit?

Best regards,
Pat


Hallgren, T. (2001). Fun with Functional Dependencies. In the
Proceedings of the Joint CS/CE Winter Meeting, Varberg, Sweden, January
2001.
Hinze, R., J. Jeuring, et al. (2006). Comparing Approaches to Generic
Programming in Haskell. Datatype-generic programming: international
spring school, SSDGP 2006.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: ANNOUNCE: htzaar-0.0.1

2009-10-09 Thread Jose A. Ortega Ruiz

Hi,

When i try to cabal install htzaar i get the following error:

src/Main.hs:11:7:
Could not find module `Play':
  Use -v to see a list of the files searched for.
cabal: Error: some packages failed to install:
htzaar-0.0.1 failed during the building phase. The exception was:
exit: ExitFailure 1

Any idea about what's going on?

Thanks!
jao
-- 
Editing is a rewording activity.
  - Alan Perlis, Epigrams in Programing

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] type inference question

2009-10-09 Thread minh thu
2009/10/9 wren ng thornton :
> Cristiano Paris wrote:
>>
>> On Thu, Oct 8, 2009 at 12:48 PM, Lennart Augustsson wrote:
>>>
>>> The reason a gets a single type is the monomorphism restriction (read
>>> the report).
>>> Using NoMonomorphismRestriction your example with a works fine.
>>
>> Could you explain why, under NoMonomorphismRestriction, this typechecks:
>>
>> let a = 1 in (a + (1 :: Int),a + (1 :: Float))
>>
>> while this not:
>>
>> foo :: Num a => a -> (Int,Float)
>> foo k = (k + (1 :: Int), k + (1.0 :: Float))
>
>
> Because lambda-binding is always[1] monomorphic, whereas let-binding can be
> polymorphic. This distinction is the reason for introducing let-binding in
> the first place. If let-bindings weren't allowed to be polymorphic (or if
> lambda-bindings were allowed to be) then we could desugar "let x = e in f"
> into "(\x -> f) $ e" and simplify the core language.[2]

As it turns out, section 31.6 Why Let and not Lambda of PLAI [*]
explains why lambda-bindings are treated monomorphically.

[*] http://www.cs.brown.edu/~sk/Publications/Books/ProgLangs/

> Milner's original paper[3] on the topic is still a good introduction to the
> field. He couldn't take advantage of subsequent work, so his notation is a
> bit outdated (though still understandable). If you're familiar with the
> details behind System F, etc. then you should be able to massage the paper
> into more modern notation in order to discuss issues like where and how
> Rank-2 polymorphism fits in.
>
>
>
> [1] That is, under the Hindley--Milner type system. If we add Rank-2 (or
> Rank-N) polymorphism then lambdas can bind polymorphic values.
>
> [2] There's a wrinkle with simplifying the core here. Let-binding is often
> introduced in tandem with a special form for declaring recursive values and
> mutually recursive groups. Usually this form is simplified somewhat as in
> ML's "let rec" or Haskell's invisible laziness recursion. If we remove "let"
> then we'll want to use the general version of "rec" and will need to be
> explicit about it.
>
> [3] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.67.5276
>
> --
> Live well,
> ~wren
> ___
> Haskell-Cafe mailing list
> Haskell-Cafe@haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Happstack + network package issue on the Mac

2009-10-09 Thread Sean Leather
On Thu, Oct 8, 2009 at 16:35, Gregory Collins wrote:

> Sean Leather  writes:
>
> > We have run into an issue that it seems other people have already
> > found but has apparently not been resolved, yet. It manifests as with
> > the error "HTTP request failed with: Unsupported socket". The problem
> > is described in two places with different workarounds.
> >
> >   http://code.google.com/p/happstack/issues/detail?id=88
> >   http://groups.google.com/group/HAppS/msg/0c9a0d0fd7c6aff0
> >
> > One workaround is to rewrite part of the network package, and the
> > other is to downgrade the package. It could be the case that the
> > rewrite came from the older version, though I'm not sure.
> >
> > I'm curious if it is possible to fix this, either in Happstack or the
> > network package, once and for all. The workarounds are rather painful
> > when so many things depend on the network package.
>
> The following patch to happstack works for me:
>

This worked for us as well. Thanks, Gregory.

Do you know if it's possible to permanently patch happstack-server? I'm
guessing the TH in the patch is used to support multiple versions of the
network package. Can we just change the minimum supported version?

Sean
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE: htzaar-0.0.1

2009-10-09 Thread Roel van Dijk
On Thu, Oct 8, 2009 at 12:56 AM, Tom Hawkins  wrote:
> Known bugs: Occasionally HTZAAR throws a Prelude.head: empty list.
> I'm still trying to track this down.

I used the following function to track down a similar problem:

myhead :: String -> [a] -> a
myhead msg [] = error msg
myhead _ (x:_) = x

Then you can replace your calls to head with myhead "bla". This way it
is faster to pin-point which head is applied to an empty list.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] type inference question

2009-10-09 Thread wren ng thornton

Cristiano Paris wrote:

On Thu, Oct 8, 2009 at 12:48 PM, Lennart Augustsson wrote:

The reason a gets a single type is the monomorphism restriction (read
the report).
Using NoMonomorphismRestriction your example with a works fine.


Could you explain why, under NoMonomorphismRestriction, this typechecks:

let a = 1 in (a + (1 :: Int),a + (1 :: Float))

while this not:

foo :: Num a => a -> (Int,Float)
foo k = (k + (1 :: Int), k + (1.0 :: Float))



Because lambda-binding is always[1] monomorphic, whereas let-binding can 
be polymorphic. This distinction is the reason for introducing 
let-binding in the first place. If let-bindings weren't allowed to be 
polymorphic (or if lambda-bindings were allowed to be) then we could 
desugar "let x = e in f" into "(\x -> f) $ e" and simplify the core 
language.[2]


Milner's original paper[3] on the topic is still a good introduction to 
the field. He couldn't take advantage of subsequent work, so his 
notation is a bit outdated (though still understandable). If you're 
familiar with the details behind System F, etc. then you should be able 
to massage the paper into more modern notation in order to discuss 
issues like where and how Rank-2 polymorphism fits in.




[1] That is, under the Hindley--Milner type system. If we add Rank-2 (or 
Rank-N) polymorphism then lambdas can bind polymorphic values.


[2] There's a wrinkle with simplifying the core here. Let-binding is 
often introduced in tandem with a special form for declaring recursive 
values and mutually recursive groups. Usually this form is simplified 
somewhat as in ML's "let rec" or Haskell's invisible laziness recursion. 
If we remove "let" then we'll want to use the general version of "rec" 
and will need to be explicit about it.


[3] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.67.5276

--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Any example of concurrent haskell application?

2009-10-09 Thread Heinrich Apfelmus
Daryoush Mehrtash wrote:
> I am trying to learn more about concurrent applications in Haskell by
> studying an existing a real application source code.   I would very much
> appreciate if you can recommend an application that you feel has done a good
> job in implementing a real time application in Haskell.

It doesn't really use much concurrency, but the web server
implementation detailed in

  Simon Marlow.
  Writing High-Performance Server Applications in Haskell
Case Study: A Haskell Web Server
  http://www.haskell.org/~simonmar/papers/web-server.ps.gz

is a simple and well documented example.


Regards,
apfelmus

--
http://apfelmus.nfshost.com

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Haskell Weekly News

2009-10-09 Thread Benjamin L . Russell
Thank you for including my quote (by "dekudekuplex"), and great work
so far!

Just a couple of minor comments:

1) It might be useful for referencing by subject if you could include
the issue number and date in the subject line (e.g., " Haskell Weekly
News: Issue 131 - September 25, 2009") instead of only "Haskell Weekly
News."

2) Instead of posting separately to the Haskell and Haskell-Cafe
mailing lists, it might be better to cross-post, since that way,
readers using newsreaders can have the cross-posted article
automatically marked "read" in the mailing list where it has not been
read.

Other than that, hope that you get over your sinus infection, and keep
up the good work!

Benjamin L. Russell

On Sat, 03 Oct 2009 09:46:25 -0700 (PDT), Joe Fredette
 wrote:

>
>---
>Haskell Weekly News
>http://sequence.complete.org/hwn/20091003
>Issue 134 - October 03, 2009
>---
>   Welcome to issue 134 of HWN, a newsletter covering developments in the
>   [1]Haskell community.
>
>   I have a nasty sinus infection this week, so we're somewhat light on
>   content. Lots of good discussion about DSL related stuff this week.
>   Bryan O'Sullivan also release 'Criterion' this week, a new benchmarking
>   library that Don Stewart described (on reddit) as 'awesome and game
>   changing.' A new TMR editor -- someone familiar -- was announced. Also,
>   there was some talk about homework policies on the mailinglists and in
>   the irc channels. There is a [2]page on the Haskell wiki about this,
>   but to sum it up in a maxim, remember, 'Help, don't do'. Until next
>   week, the Haskell Weekly News!
>
>Announcements
>
>   New TMR editor. Wouter Swierstra [3]announced that he would be stepping
>   down from the editorship of 'The Monad Reader', with former HWN editor
>   Brent Yorgey taking his place. Much thanks for Wouter's hard work and
>   good luck to Brent on his new editor job!
>
>   SourceGraph 0.5.{0,1,2}.0. Ivan Lazar Miljenovic [4]announced three new
>   releases of the SourceGraph packages, this links to the latest release.
>
>   json-b-0.0.4. Jason Dusek [5]announced a new version of the json-b
>   package, which fixes defective handling of empty objects and arrays.
>
>   rss2irc 0.4 released. Simon Michael [6]announced a new release of
>   rss2irc, with many new improvements and features.
>
>   vty-ui 0.1. Jonathan Daugherty [7]announced vty-ui, which is an
>   extensible library of user interface widgets for composing and laying
>   out Vty user interfaces.
>
>   atom-0.1.1. Tom Hawkins [8]announced Atom, a Haskell DSL for designing
>   hard real-time embedded applications.
>
>   Graphalyze-0.7.0.0. Ivan Lazar Miljenovic [9]announced (in an apparent
>   effort to take over hackage by submitting dozens of quality packages at
>   absurdly high speed), Graphalyze, a library for using graph-theoretic
>   techniques to analyse the relationships inherent within discrete data.
>
>   Criterion. Bryan O'Sullivan [10]announced (without tacking on an 'ANN'
>   tag, I might add, I almost missed it!) Criterion, a benchmarking
>   library he describes [11]here.
>
>   ListTree 0.1. yair...@gmail.com [12]announced ListTree, a package for
>   combinatorial search and pruning of trees.
>
>   usb-0.1. Bas van Dijk [13]announced a library for interacting with usb
>   modules from userspace.
>
>   (Deadline extended to October 5th) APLAS 2009 Call for Posters.
>   Kiminori Matsuzaki [14]announced a deadline extension to the call for
>   posters for the APLAS conference.
>
>   graphviz-2999.6.0.0. Ivan Lazar Miljenovic [15]announced a new version
>   of the graphviz library, which features various new features and small
>   changes.
>
>Discussion
>
>   Testing polymorphic properties with QuickCheck. Jean-Philippe Bernardy
>   [16]gave an excellent overview about how to use QuickCheck to test
>   polymorphic properties.
>
>   Designing a DSL? Gunther Schmidt [17]asked about different methods
>   employed for designing a DSL.
>
>   DSL and GUI Toolkits. Gunther Schmidt [18]also asked about different
>   DSLs for working with GUIs
>
>   error on "--++ bla bla bla". Hong Yang [19]asked about why '--++'
>   wasn't being parsed in the way he thought it was.
>
>   Haskell for Physicists. edgar [20]requested name suggestions for the
>   talk he is giving about Physics and Haskell.
>
>Blog noise
>
>   [21]Haskell news from the [22]blogosphere. Blog posts from people new
>   to the Haskell community are marked with >>>, be sure to welcome them!
> * Sean Leather: [23]'Extensibility and type safety in formatting: the
>   design of xformat' at the Dutch HUG.
> * Martijn van Steenbergen: [24]let 5 = 6.
> * Lee Pike: [25]Writer's unblock.
> * Manuel M T Chakravarty: [26]NVIDIAs next generation GPU
>   architecture has a lot for HPC to love.
> * David Amos: [27]Finite geometries, p

Re: [Haskell-cafe] Any example of concurrent haskell application?

2009-10-09 Thread Martijn van Steenbergen

Daryoush Mehrtash wrote:
I am trying to learn more about concurrent applications in Haskell by 
studying an existing a real application source code.   I would very much 
appreciate if you can recommend an application that you feel has done a 
good job in implementing a real time application in Haskell.


Yogurt[1], a MUD client, uses two threads: one to process input from the 
server and one to process input from the client. It uses an MVar to 
synchronize. All concurrency is located in module Network.Yogurt.Readline.


Custard[2], a MUD server, uses several threads:
* Server, maintaining MUD state
* one that listens for incoming connections
* per client, one that listens for client input
* per client, one that listens for messages from Server
It uses channels and message passing to synchronize. All concurrency is 
located in module Engine.


[1] http://hackage.haskell.org/package/Yogurt
[2] http://code.google.com/p/custard/

Hope this helps,

Martijn.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: text 0.5, a major revision of the Unicode text library

2009-10-09 Thread Bryan O'Sullivan
Get it while it's fresh on Hackage, folks! Details of the changes here:
http://bit.ly/1u4UOT
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe