Re: [Haskell-cafe] circular imports

2010-09-07 Thread Mathew de Detrich
That definitely makes more sense

On 07/09/2010 3:06 PM, Daniel Peebles pumpkin...@gmail.com wrote:

I was under the impression that the main reason GHC requires .hs-boot files
is that nobody has had the time or inclination to make it resolve circular
dependencies automatically, and not an intentional design decision to
encourage good design.



On Tue, Sep 7, 2010 at 6:51 AM, Mathew de Detrich dete...@gmail.com wrote:

 I had the same is...
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] circular imports

2010-09-07 Thread Ivan Lazar Miljenovic
On 7 September 2010 16:09, Mathew de Detrich dete...@gmail.com wrote:
 That definitely makes more sense

Well, the report (section 5.7) says you're allowed to request extra
info for mutually recursive modules...

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] circular imports

2010-09-07 Thread Simon Peyton-Jones
I was under the impression that the main reason GHC requires .hs-boot files is 
that nobody has had the time or inclination to make it resolve circular 
dependencies automatically, and not an intentional design decision to encourage 
good design.
Indeed.  I’ve added some notes here 
http://hackage.haskell.org/trac/ghc/ticket/1409#comment:37

Simon

From: haskell-cafe-boun...@haskell.org 
[mailto:haskell-cafe-boun...@haskell.org] On Behalf Of Daniel Peebles
Sent: 07 September 2010 06:06
To: Mathew de Detrich
Cc: Ivan Lazar Miljenovic; haskell
Subject: Re: [Haskell-cafe] circular imports

I was under the impression that the main reason GHC requires .hs-boot files is 
that nobody has had the time or inclination to make it resolve circular 
dependencies automatically, and not an intentional design decision to encourage 
good design.
On Tue, Sep 7, 2010 at 6:51 AM, Mathew de Detrich 
dete...@gmail.commailto:dete...@gmail.com wrote:
I had the same issue zonks ago, and I resorted to using the hs-boot file method 
as well (which worked fine)

Which I guess brings me to my second point, is this something that GHC should 
do automatically when it sees circular dependencies? When I asked about it 
earlier on #haskell, I was told that its better that way because it discourages 
making bad design through circular dependencies (yet in my case and I assume 
the other cases as well, not using the hs-boot method would have made the 
design much worse). Are there any cases in particular where people would be 
encouraged to make interface design with circular dependencies (and that design 
be deemed as horrible) as opposed to what seems to be more realistic case where 
circular dependencies rarely crop up, and when they do they actually make the 
design better?

On Tue, Sep 7, 2010 at 1:48 PM, Ivan Lazar Miljenovic 
ivan.miljeno...@gmail.commailto:ivan.miljeno...@gmail.com wrote:
On 7 September 2010 03:44, Edward Z. Yang 
ezy...@mit.edumailto:ezy...@mit.edu wrote:
 Excerpts from Evan Laforge's message of Mon Sep 06 13:30:43 -0400 2010:
 I feel like the circular imports problem is worse in haskell than
 other languages.  Maybe because there is a tendency to centralize all
 state, since you need to define it along with your state monad.  But
 the state monad module must be one of the lower level ones, since all
 modules that use it must import it.  However, the tendency for bits of
 typed data to migrate into the state means it's easy for it to
 eventually want to import one of its importers.  And the state monad
 module gets larger and larger (the largest modules in my system are
 those that define state monads: 1186 lines, 706 lines, 1156
 lines---the rest tend to be 100--300 lines).

 I have used hs-boot files to this effect.  I separated data and functionality,
 and typeclasses, which must be in the same module as data or are considered
 orphaned, get definitions via a circular import.
I'm just getting to the point where I have a similar problem.  I was
thinking about splitting instances off from the classes (and telling
GHC to not worry about orphaned instances for the instance-only
modules) but then realised that some instance declarations would be
circular as well, so I have to either use hs-boot files, define
everything in one big module and then re-export them in ways that make
sense or define all instances in one big module (at least for those
types which have circular deps among instances) and re-export
accordingly.

--
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.commailto:ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.comhttp://IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.orgmailto:Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.orgmailto: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: Paralelism and Distribution in Haskell

2010-09-07 Thread Johannes Waldmann
Mathew de Detrich deteego at gmail.com writes:

 Haskell is still by far one of the best languages 
 to deal with concurrency/parallelism. 

Sure, I fully agree.

I am using concurrency (with explicit forkIO, communication via Chan) 
a lot (my Haskell application controls several external constraint solvers).

For parallelism, I'm just missing some benchmark code
that I can run on my machine (i7 CPU, GTX 295 GPU, ghc-6.12.3)
more or less out-of-the-box and that will impress my students and myself.
(That is, get a speed-up of 8, or 480, without the program
looking 8 times (or 480 times) more ugly...)

- Johannes.


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


Re: RE: [Haskell-cafe] circular imports

2010-09-07 Thread Mathew de Detrich
Thanks for the clarification

On 07/09/2010 5:30 PM, Simon Peyton-Jones simo...@microsoft.com wrote:

 I was under the impression that the main reason GHC requires .hs-boot files
is that nobody has had t...

Indeed.  I’ve added some notes here
http://hackage.haskell.org/trac/ghc/ticket/1409#comment:37



Simon



*From:* haskell-cafe-boun...@haskell.org [mailto:
haskell-cafe-boun...@haskell.org] *On Behalf Of *Daniel Peebles
*Sent:* 07 September 2010 06:06
*To:* Mathew de Detrich
*Cc:* Ivan Lazar Miljenovic; haskell
*Subject:* Re: [Haskell-cafe] circular imports





I was under the impression that the main reason GHC requires .hs-boot files
is that nobody has ...
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Restricted type classes

2010-09-07 Thread Daniel Fischer
On Tuesday 07 September 2010 05:22:55, David Menendez wrote:
 On Mon, Sep 6, 2010 at 10:22 PM, wren ng thornton w...@freegeek.org 
wrote:
  On 9/6/10 1:33 PM, David Menendez wrote:
  For that matter, can you even describe what pure is intended to do
  without reference to*  or join?
 
  As already stated: fmap f . pure = pure . f

 That's pretty general. For lists, the functions having that property
 include const [], \x - [x,x], and repeat.

 In fact, I think *every* appropriately-typed function satisfies that
 law. Does anyone know of a counter-example?

class Functor f = Pointed f where
point :: a - f a
 -- satisfying fmap f . point = point . f

notQuitePure :: Pointed f = a - f a
notQuitePure _ = point undefined

fmap (const True) . notQuitePure = point . const True

But I don't see how to violate that law without introducing undefined on 
the RHS.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANNOUNCE: Grempa 0.1.0, Embedded grammar DSL and LALR parser generator

2010-09-07 Thread Olle Fredriksson

 Looks like Applicative style.  This is good, even while I don't really
 know why we are seeing @ and # instead of $ and *.

 How does Grempa compare with other parsing libraries/tools, such as
 Parsec, Attoparsec and Happy, with regard to ease of use and
 performance?

 Cheers! =)

 --
 Felipe.


Yes, it is indeed in applicative style. The reason for @ and # is that
the functions have slightly different constraints to them, compared to the
Applicative equivalents. The arguments passed to the function have to be
instances of the ToSym class, which converts terminals and non-terminals to
symbols. This allows writing the grammars in the way seen above (Plus @ e
# '+' # t) instead of something like Plus @ nont e # tok '+' #
nont t.

I have yet to do any library comparisons on performance, but it should be
faster than monadic combinator style libraries, as it does not have the
exponential corner-cases that those parsers can have. It is also easier to
write the grammars in Grempa's BNF-like syntax where left-recursion is
permitted. Some comparison benchmarks would be interesting though, and I
will look into it in the future. I have already done some profiling to
eliminate the worst deficiencies of Grempa, but there is definitely room for
improvements still.

The library does not do lexing for you, which some of the other libraries
have support for, which can make it harder to use. A plus for me (compared
to Happy) is that you do not have to run an external program every time your
grammar has changed, but can instead just recompile your project.

I'm glad to see some interest in the project!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Paralelism and Distribution in Haskell

2010-09-07 Thread Ben Lippmeier

On 07/09/2010, at 6:11 PM, Johannes Waldmann wrote:

 Mathew de Detrich deteego at gmail.com writes:
 
 Haskell is still by far one of the best languages 
 to deal with concurrency/parallelism. 
 
 Sure, I fully agree.
 
 I am using concurrency (with explicit forkIO, communication via Chan) 
 a lot (my Haskell application controls several external constraint solvers).
 
 For parallelism, I'm just missing some benchmark code
 that I can run on my machine (i7 CPU, GTX 295 GPU, ghc-6.12.3)
 more or less out-of-the-box and that will impress my students and myself.
 (That is, get a speed-up of 8, or 480, without the program
 looking 8 times (or 480 times) more ugly...)
 

The matrix-matrix multiplication benchmark from the Repa library does this.

Check out 
  http://www.cse.unsw.edu.au/~benl/papers/repa/repa-icfp2010.pdf
  http://hackage.haskell.org/package/repa
  http://hackage.haskell.org/package/repa-examples

Though be warned you must use a recent GHC head build to get good performance. 
After GHC 7.0 is out (in a few weeks) we'll be able to release a properly 
stable version.

Note that speedup is an important consideration, but not the end of the 
story. It's harder to find a benchmark that displays all of nice code + speedup 
+ good absolute performance. The first and last of these tend not to be friends.

Ben.

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


Re: [Haskell-cafe] Re: Paralelism and Distribution in Haskell

2010-09-07 Thread David Virebayre
2010/9/7 Ben Lippmeier b...@ouroborus.net:
 Though be warned you must use a recent GHC head build to get good 
 performance. After GHC 7.0 is out (in a few weeks) we'll be able to release a 
 properly stable version.

Pardon a probably stupid question, but did I miss something ?

http://hackage.haskell.org/trac/ghc/roadmap

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


Re: [Haskell-cafe] Re: Paralelism and Distribution in Haskell

2010-09-07 Thread Vo Minh Thu
2010/9/7 David Virebayre dav.vire+hask...@gmail.com:
 2010/9/7 Ben Lippmeier b...@ouroborus.net:
 Though be warned you must use a recent GHC head build to get good 
 performance. After GHC 7.0 is out (in a few weeks) we'll be able to release 
 a properly stable version.

 Pardon a probably stupid question, but did I miss something ?

 http://hackage.haskell.org/trac/ghc/roadmap

This is not stupid, but yes you missed something :)
http://www.reddit.com/r/haskell/comments/dad6j/unless_theres_a_major_hiccup_itll_be_in_ghc_70/

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


Re: [Haskell-cafe] Re: Paralelism and Distribution in Haskell

2010-09-07 Thread David Virebayre
 This is not stupid, but yes you missed something :)
 http://www.reddit.com/r/haskell/comments/dad6j/unless_theres_a_major_hiccup_itll_be_in_ghc_70/

Oh, I saw that thread, but at the time it had vrey few comments, so I
definately missed something !

Thanks !

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


Re: [Haskell-cafe] Restricted type classes

2010-09-07 Thread John Lato
2010/9/7 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com

 2010/9/7 Gábor Lehel illiss...@gmail.com:
  *That said*, I actually have nothing at all against splitting the 'a
  - f a' method out into a separate class if you think it's useful,
  whether you call it Pointed or something else. (And `class (Pointed f,
  Functor f) = PointedFunctor f` is sort of cute.)

 It might be cute, but until we get class aliases [1] this results in
 yet another class to make your data type an instance of, and what's
 more it's one that doesnt' even give you anything.

 I think it makes much more sense to have Functor, Pointed and
 (Functor f, Pointed f) = Applicative f rather than a useless
 intermediary class.  If, however, we could get class aliases _for
 free_ (i.e. something like class alias PointedFunctor f = (Functor f,
 Pointed f) for which all instances of Functor and Pointed are
 automatically instanced of PointedFunctor), then I can see that as
 being something nice to have.


I agree completely.

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


[Haskell-cafe] Oracle stored procedures

2010-09-07 Thread Peter Marks
Are there any Haskell libraries that can call stored procedures in Oracle?
I've been looking at Takusen which I like, but I can't find a way to call a
stored procedure.

Thanks

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


Re: [Haskell-cafe] Oracle stored procedures

2010-09-07 Thread David Virebayre
2010/9/7 Peter Marks pe...@indigomail.net:
 Are there any Haskell libraries that can call stored procedures in Oracle?
 I've been looking at Takusen which I like, but I can't find a way to call a
 stored procedure.

Don't you need to execute a SELECT query that calls the procedure, as in

select my_procedure(parameter)

Not sure though, I've never used stored procedures.

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


Re: [Haskell-cafe] Restricted type classes

2010-09-07 Thread John Lato

 From: Stephen Tetley stephen.tet...@gmail.com

 On 6 September 2010 20:18, John Lato jwl...@gmail.com wrote:

  Can you give an example of a Functor that doesn't have pure?  I think
 it's
  Pointed Functors which are useful; not Functor by itself.

 Strictly speaking is Pair one? The current implementation tacks on monoid.


Interesting example.  I tend not to like implementations which rely on
bottoms, so I think I'd agree.

In a similar spirit, I would propose Data.Vector.Unboxed.Vector as a Pointed
Functor (modulo element restrictions) which is not Applicative, since the
necessary element restrictions mean * can't be defined.

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


Re: [Haskell-cafe] Restricted type classes

2010-09-07 Thread Neil Brown

On 07/09/10 05:24, wren ng thornton wrote:
that other class would (most likely) be a subclass of pointed 
functors. In
any case, it does mean there's something of a mismatch between 
singleton vs

return/pure/point/unit.


Not quite sure what you mean by a mis-match

Of course, I'd expect singleton to obey the pointed law as well, so

Just that they're not the same thing. For example, ZipList supports 
pure but it has no meaningful instance of singleton since every 
ZipList is infinite.


I don't believe that every ZipList is infinite (if this should be the 
case, the constructor shouldn't be exposed!), just that ZipLists created 
by pure are infinite -- that's the obvious definition to meet the 
Applicative laws.  You can quite happily use:


(+) $ ZipList [1,2,3] * ZipList [4,5] == ZipList [5,7]

So ZipList does have a meaningful definition of singleton (singleton x = 
ZipList [x]; I'm sure there are other pointed functors that don't have a 
good definition for singleton), and a meaningful definition of pure, but 
they're not the same definition.


Thanks,

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


Re: [Haskell-cafe] Re: Fwd: Semantics of iteratees, enumerators, enumeratees?

2010-09-07 Thread John Lato
At first I regarded this as simply a bug in the Iteratee.map definition, but
like Ben, it's started to bother me a lot.  I think this is precisely the
sort of issue a proper denotational semantics would fix.

Unfortunately the only general solution I see is to abandon chunking and
work strictly element-wise.  I say unfortunately because my current best
implementation is about 5 times slower than the main tree.  I'm open to
ideas.

John


 From: Ben midfi...@gmail.com

 Sorry to be late coming into this conversation.

 Something that has bothered me (which I have mentioned to John Lato
 privately) is that it is very easy to write non-compositional code due
 to the chunking.  For example, there is a standard function

 map :: (a - b) - Enumeratee a b c

 whose meaning I hope is clear : use the function to transform the type
 of a stream and pass it to an iteratee.  However last I checked the
 versions provided in both the iteratee and enumerator packages fail to
 satisfy the equation

 map f (it1  it2) == (map f it1)  (map f it 2)

 because of chunking, essentially.  You can check this with f == id and
 it1 and it2 are head:

 let r = runIdentity . runIteratee

 runIdentity $ run $ enumList 10 [1..100] $ r $ joinI $ map id $ r (head 
 head)
 -- Right (Just 2)

 runIdentity $ run $ enumList 10 [1..100] $ r $ joinI $ (map id $ r
 head)  (map id $ r head)
 -- Right (Just 11)

 It is possible to fix this behavior, but it complicates the obvious
 definitions a lot.

 B

 On Wed, Sep 1, 2010 at 5:10 AM, Heinrich Apfelmus
 apfel...@quantentunnel.de wrote:
  Tilo Wiklund wrote:
 
  Daniel Fischer wrote:
 
  [...]
  Well, I just gave an example where one would want chunking for reasons
  other than performance. That iteratees don't provide the desired
  functionality is a different matter.
  [...]
 
  In the case of hashing, wouldn't it be more reasonable to consider
  iterators over streams of fixed (or at least predictable) sized chunks
  (where a set of chunks can themselves be chunked), with the chunking
  behaviour being given by another iteratee over the original stream?
 
  It seems to me that one of the major points of iteratees is to provide
  an abstraction from the kind of chunking irrelevant to the parsing
  logic, otherwise I fail to see any difference (at least relevant to
  chunking) to plain strict IO.
 
  I thought so, too, but I was informed[1] that iteratees are just a small
  step up the abstraction ladder. The difference compared to an ordinary
 file
   Handle  is that you can now reuse one and the same iteratee for reading
  from a  String , for instance, without changing the source code of the
  iteratee.
 
  Furthermore, iteratees can be suspended, which facilities resource
  management like closing files handles after they've been read.
 
   [1]:
 
 http://www.reddit.com/r/haskell/comments/ar4wb/understanding_iteratees/c0j0f3r
 
 
 
  Regards,
  Heinrich Apfelmus
 
  --
  http://apfelmus.nfshost.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


Re: [Haskell-cafe] circular imports

2010-09-07 Thread corentin . dupont
Hello,
I had recently a really hard time splitting up my program into parts!
The natural, business-oriented split up drove me into a deadly circular
dependency.
I tried to solve it with:
- .hs-boot: It adds a lot of duplicated code and unecessary files, so I
gave up
- type variables: that too complifies the code with no obvious reasons

Finally, i ended up with putting all my types into a file names Types.hs.
It's not very satisfatory, since I like to keep the types next to their
related code and functions (like it is in the libraries).
But I founded this is the way that adds the less burden to the code.

Cheers,
Corentin





   
 Mathew de 
 Detrich   
 dete...@gmail.c Pour
 om   Ivan Lazar Miljenovic   
 Envoyé par :  ivan.miljeno...@gmail.com   
 haskell-cafe-bou   cc
 n...@haskell.org  haskell haskell-cafe@haskell.org
 Objet
   Re: [Haskell-cafe] circular imports
 07/09/2010 06:52  
   
   
   
   
   




I had the same issue zonks ago, and I resorted to using the hs-boot file
method as well (which worked fine)

Which I guess brings me to my second point, is this something that GHC
should do automatically when it sees circular dependencies? When I asked
about it earlier on #haskell, I was told that its better that way because
it discourages making bad design through circular dependencies (yet in my
case and I assume the other cases as well, not using the hs-boot method
would have made the design much worse). Are there any cases in particular
where people would be encouraged to make interface design with
circular dependencies (and that design be deemed as horrible) as opposed to
what seems to be more realistic case where circular dependencies rarely
crop up, and when they do they actually make the design better?


On Tue, Sep 7, 2010 at 1:48 PM, Ivan Lazar Miljenovic 
ivan.miljeno...@gmail.com wrote:
  On 7 September 2010 03:44, Edward Z. Yang ezy...@mit.edu wrote:
   Excerpts from Evan Laforge's message of Mon Sep 06 13:30:43 -0400
  2010:
   I feel like the circular imports problem is worse in haskell than
   other languages.  Maybe because there is a tendency to centralize
  all
   state, since you need to define it along with your state monad.
  But
   the state monad module must be one of the lower level ones, since
  all
   modules that use it must import it.  However, the tendency for
  bits of
   typed data to migrate into the state means it's easy for it to
   eventually want to import one of its importers.  And the state
  monad
   module gets larger and larger (the largest modules in my system
  are
   those that define state monads: 1186 lines, 706 lines, 1156
   lines---the rest tend to be 100--300 lines).
  
   I have used hs-boot files to this effect.  I separated data and
  functionality,
   and typeclasses, which must be in the same module as data or are
  considered
   orphaned, get definitions via a circular import.

  I'm just getting to the point where I have a similar problem.  I was
  thinking about splitting instances off from the classes (and telling
  GHC to not worry about orphaned instances for the instance-only
  modules) but then realised that some instance declarations would be
  circular as well, so I have to either use hs-boot files, define
  everything in one big module and then re-export them in ways that
  make
  sense or define all instances in one big module (at least for those
  types which have circular deps among instances) and re-export
  accordingly.

  --
  Ivan Lazar Miljenovic
  ivan.miljeno...@gmail.com
  IvanMiljenovic.wordpress.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 mailing list

[Haskell-cafe] Re: circular imports

2010-09-07 Thread Johannes Waldmann
 corentin.dupont at ext.mpsa.com writes:

 I had recently a really hard time splitting up my program into parts!
 The natural, business-oriented split up drove me into a deadly circular
 dependency.

perhaps you could post your code (enough of it to understand the problem)?

J.W.


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


[Haskell-cafe] generating foreign Code (Java, C++, PHP)?

2010-09-07 Thread Günther Schmidt

Hi list,

I noticed that there are some libs / packages like atom and HJscript 
which allow you to write a program in a haskell EDSL and that then 
actually generates valid source code in another language. In the above 
example that would be JavaScript and C.


I sure would love to be able to write PHP for instance like that but I 
cannot even fathom how a EDSL would have to be designed for it.


Could someone here point me to literature on the topic?

Günther

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


Re: [Haskell-cafe] random-fu confusion

2010-09-07 Thread James Andrew Cook
A PureMT generator is immutable, so must be threaded through the monad in which 
you are sampling.  There are RandomSource instances provided for a few special 
cases, including IORef PureMT in the IO monad.  For example:

main = do
mt - newPureMT
src - newIORef mt
flips - runRVar (replicateM 20 flipCoin) src
print flips

Alternatively, the functions in the module you mentioned can be used to define 
additional instances, such as:

instance MonadRandom (State PureMT) where
supportedPrims _ _ = True
getSupportedRandomPrim = getRandomPrimFromPureMTState

And RandomSource instances look almost the same.  See the 
Data.Random.Source.PureMT source for examples.  (I thought I had included this 
particular instance in the distribution but I apparently missed it.  The next 
release will probably include this as well as corresponding instances for the 
'transformers' package, possibly separated out into 'random-fu-mtl' and 
'random-fu-transformers' packages).

The StdRandom type is a convenient RandomSource designating this instance 
in the State PureMT monad.  Personally, I prefer to use the sample function 
for this purpose, as well as the sampleFrom function in place of 
runRVar/runRVarT.  GHCi does not display the sample functions' types properly 
- they are defined for RVarT as well as for all Distribution instances.

Sorry it took so long responding.

-- James

On Sep 2, 2010, at 10:01 AM, Alex Rozenshteyn wrote:

 I seem to be having confusion at the runRVar level of random-fu.
 
 I can't figure out how to use the Data.Random.Source.PureMT module to get a 
 meaningful random source (I can't get my code to type-check).
 
 I wrote a [trivial] flipCoin function
  flipCoin = uniform False True
 and am trying to fill in the final place of runRVar
  :t runRVar (replicateM 20 flipCoin)
 runRVar (replicateM 20 flipCoin)
   :: (RandomSource m s) = s - m [Bool]
 
 
 -- 
   Alex R
 
 ___
 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] generating foreign Code (Java, C++, PHP)?

2010-09-07 Thread Vo Minh Thu
2010/9/7 Günther Schmidt gue.schm...@web.de:
 Hi list,

 I noticed that there are some libs / packages like atom and HJscript which
 allow you to write a program in a haskell EDSL and that then actually
 generates valid source code in another language. In the above example that
 would be JavaScript and C.

 I sure would love to be able to write PHP for instance like that but I
 cannot even fathom how a EDSL would have to be designed for it.

Hi,

Probably, the very first thing is to know what purpose the EDSL would
serve. For instance, Atom is not meant as a general purpose
replacement for C. Do you have something specific in mind?

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


Re: [Haskell-cafe] circular imports

2010-09-07 Thread Henning Thielemann
Mathew de Detrich schrieb:

 I had the same issue zonks ago, and I resorted to using the hs-boot file
 method as well (which worked fine)
 
 Which I guess brings me to my second point, is this something that GHC
 should do automatically when it sees circular dependencies? When I asked
 about it earlier on #haskell, I was told that its better that way
 because it discourages making bad design through
 circular dependencies (yet in my case and I assume the other cases as
 well, not using the hs-boot method would have made the design much
 worse). Are there any cases in particular where people would be
 encouraged to make interface design with circular dependencies (and that
 design be deemed as horrible) as opposed to what seems to be more
 realistic case where circular dependencies rarely crop up, and when they
 do they actually make the design better?

I like to compare it with Modula-3 where cyclic imports are strictly
forbidden. There it is solved by dividing a module into an interface
file and an implementation file. The interface can be compared with
.hs-boot files: You can define types there, but you can also simply
declare a type without its precise structure. Two mutually depending
types in distinct modules could be defined as follows:

A.i3:
INTERFACE A;
TYPE T : REFANY; (* declare T to be a subtype of a general pointer *)
END A.

A.m3:
MODULE A; (* the implementation part automatically imports the
corresponding interface A without qualification *)
IMPORT B; (* import the interface of module B *)
REVEAL T = POINTER TO RECORD b : B.T END;
END A.


B.i3:
INTERFACE B;
TYPE T : REFANY;
END B.

B.m3:
MODULE B;
IMPORT A;
REVEAL T = POINTER TO RECORD a : A.T END;
END B.


Thus the circular dependency graph
A - B, B - A
is split into the non-circular dependency graph
Ai - Am, Ai - Bm, Bi - Am, Bi - Bm

Obviously this only works for pointers, but this is no problem since
embedding a record in itself is not possible. Haskell cannot embed a
record in another one, it uses pointers by default.

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


Réf. : [Haskell-cafe] Re: circular imports

2010-09-07 Thread corentin . dupont
That sort of code (stripped out):

In Game.hs:

data Game = Game { ...
   activeRules :: [Rule]}

applyTo :: Rule - Game - Game
applyTo r gs = ...


In Rule.hs:

data Rule = Cond (Obs) Rule Rule
  | many others..
  deriving (Read, Show, Eq, Typeable)

data NamedRule = NamedRule { ...,
 rule :: Rule }

isRuleLegal :: Rule - NamedRule - Game - Bool
isRuleLegal = ...


In Obs.hs:

data Obs a where
 ProposedBy :: Obs Int   -- The player that proposed the tested rule
 ...


evalObs :: Obs - NamedRule - Game - EvalObsType
evalObs = ...


Corentin




   
 Johannes  
 Waldmann  
 waldm...@imn.ht Pour
 wk-leipzig.dehaskell-cafe@haskell.org
 Envoyé par :   cc
 haskell-cafe-bou  
 n...@haskell.orgObjet
   [Haskell-cafe] Re: circular imports
   
 07/09/2010 14:00  
   
   
   
   




 corentin.dupont at ext.mpsa.com writes:

 I had recently a really hard time splitting up my program into parts!
 The natural, business-oriented split up drove me into a deadly circular
 dependency.

perhaps you could post your code (enough of it to understand the problem)?

J.W.


___
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] circular imports

2010-09-07 Thread Henning Thielemann
Simon Peyton-Jones schrieb:
 I was under the impression that the main reason GHC requires .hs-boot
 files is that nobody has had the time or inclination to make it resolve
 circular dependencies automatically, and not an intentional design
 decision to encourage good design.
 
 Indeed.  I’ve added some notes here
 http://hackage.haskell.org/trac/ghc/ticket/1409#comment:37

When reading this, I'm afraid adding this feature will cause more bugs
than features. For me, generally working hs-boot-files would be enough,
that is, hs-boot files that support all situations of mutually depending
classes and instances. I still prefer non-circular modules, because I
understand their relationship more easily. I prefer to explicitly state
when I want cyclic imports, as I currently do with hs-boot files. As
time went by, I become familiar with the discussed methods of avoiding
import cycles and actually, all packages I have written so far do not
contain any circular import and thus no hs-boot file.


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


Re: [Haskell-cafe] How to catch exception within the Get monad (the Binary package)

2010-09-07 Thread Dimitry Golubovsky
Hi,

Thanks to everybody who replied.

I see another solution: are there any hidden problems?

I found an interesting package, ChasingBottoms which contains a
function testing a value to be bottom and returning a Boolean (of
course it cannot be done without unsafePerformIO).

I borrowed the idea from that package, and wrote two functions:

unThrow :: (Exception e) = a - Either e a

unThrow a = unsafePerformIO $ (E.evaluate a = return . Right) `E.catch`
   (\e - return $ Left e)

-- or perhaps the right argument of catch could be just (return . Left)?

bm2mb :: a - Maybe a

bm2mb a = case unThrow a of
   Left (e::SomeException) - Nothing
   Right a - Just a

So, if there is a value inside the lazy list which is a bottom (binary
parse failure of the last received object in this case, catching any
possible exception) then the value can be converted to Nothing within
pure code, and then excluded from the result using catMaybes.

This solution seems to be working for me.

PS Maybe the way I am using the serialized data needs to be changed by
implementing some kind of an iterator over the binary stream, and then
by taking one object at a time and consuming it right there the
problem might be eliminated entirely...

Thanks again.

-- 
Dimitry Golubovsky

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


[Haskell-cafe] ghc HEAD

2010-09-07 Thread Johannes Waldmann
I was compiling  ghc-6.13.20100831 from source (*)
and then compiling repa-examples with that,
and the generated executable says (when called with +RTS -N2):

  Most RTS options are disabled. Link with -rtsopts to enable them.

Where? How? When? (Did I make some error earlier?)

(*) that's the latest available src snapshot?
(Sadly, it does not contain containers-0.4)
How come there are binaries without sources at:
http://www.haskell.org/ghc/dist/current/dist/

While cabal install repa-examples works nicely,
it is still way too easy to break the system, since cabal install 
will happily (and silently) destroy ghc's libraries.
(e.g. happens for me after installing syb)

unfortunately, this means I cannot easily test
ghc HEAD and/or containers-0.4 on my sources.

J.W.

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


Re: Réf. : [Haskell-cafe] Re: circular imports

2010-09-07 Thread Henning Thielemann
corentin.dup...@ext.mpsa.com schrieb:
 That sort of code (stripped out):
 
 In Game.hs:
 
 data Game = Game { ...
activeRules :: [Rule]}
 
 applyTo :: Rule - Game - Game
 applyTo r gs = ...
 
 
 In Rule.hs:
 
 data Rule = Cond (Obs) Rule Rule
   | many others..
   deriving (Read, Show, Eq, Typeable)
 
 data NamedRule = NamedRule { ...,
  rule :: Rule }
 
 isRuleLegal :: Rule - NamedRule - Game - Bool
 isRuleLegal = ...
 
 
 In Obs.hs:
 
 data Obs a where
  ProposedBy :: Obs Int   -- The player that proposed the tested rule
  ...
 
 
 evalObs :: Obs - NamedRule - Game - EvalObsType
 evalObs = ...

As I see there is no cycle in the types. How about defining Game, Rule,
Obs in private modules, like Private.Game, Private.Rule, Private.Obs,
and implementing the functions in public modules like Game, Rule, Obs ?

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


Re: [Haskell-cafe] ghc HEAD

2010-09-07 Thread Yuras Shumovich
2010/9/7 Johannes Waldmann waldm...@imn.htwk-leipzig.de:
 I was compiling  ghc-6.13.20100831 from source (*)
 and then compiling repa-examples with that,
 and the generated executable says (when called with +RTS -N2):

  Most RTS options are disabled. Link with -rtsopts to enable them.

 Where? How? When? (Did I make some error earlier?)


AFAIK RTS options are disabled by default now due to security problems.
see
http://hackage.haskell.org/trac/ghc/ticket/3910
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] random-fu confusion

2010-09-07 Thread Alex Rozenshteyn
Okay, I figured the immutability bit out and I got the IORef example
working, but I can't get it to work with state.

 put (pureMT 0) = runRVar flipCoin

gives me two type errors: No instance for (MonadState PureMT m) and No
instance for (RandomSource m ())

 runState $ put (pureMT 0) = runRVar flipCoin
 runState $ put (pureMT 0)  get = runRVar flipCoin
 put (pureMT 0)  get = runRVar flipCoin

and other desperate attempts, some of which in hindsight are too
embarrassing to list give me similar errors.  I'm trying to do figure out
how to do this without going to the IO monad (so I can run it with the same
seed to replicate results).

On Tue, Sep 7, 2010 at 3:14 PM, James Andrew Cook mo...@deepbondi.netwrote:

 A PureMT generator is immutable, so must be threaded through the monad in
 which you are sampling.  There are RandomSource instances provided for a few
 special cases, including IORef PureMT in the IO monad.  For example:

 main = do
mt - newPureMT
src - newIORef mt
flips - runRVar (replicateM 20 flipCoin) src
print flips

 Alternatively, the functions in the module you mentioned can be used to
 define additional instances, such as:

 instance MonadRandom (State PureMT) where
supportedPrims _ _ = True
getSupportedRandomPrim = getRandomPrimFromPureMTState

 And RandomSource instances look almost the same.  See the
 Data.Random.Source.PureMT source for examples.  (I thought I had included
 this particular instance in the distribution but I apparently missed it.
  The next release will probably include this as well as corresponding
 instances for the 'transformers' package, possibly separated out into
 'random-fu-mtl' and 'random-fu-transformers' packages).

 The StdRandom type is a convenient RandomSource designating this
 instance in the State PureMT monad.  Personally, I prefer to use the
 sample function for this purpose, as well as the sampleFrom function in
 place of runRVar/runRVarT.  GHCi does not display the sample functions'
 types properly - they are defined for RVarT as well as for all Distribution
 instances.

 Sorry it took so long responding.

 -- James

 On Sep 2, 2010, at 10:01 AM, Alex Rozenshteyn wrote:

  I seem to be having confusion at the runRVar level of random-fu.
 
  I can't figure out how to use the Data.Random.Source.PureMT module to get
 a meaningful random source (I can't get my code to type-check).
 
  I wrote a [trivial] flipCoin function
   flipCoin = uniform False True
  and am trying to fill in the final place of runRVar
   :t runRVar (replicateM 20 flipCoin)
  runRVar (replicateM 20 flipCoin)
:: (RandomSource m s) = s - m [Bool]
 
 
  --
Alex R
 
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe




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


Re: Réf. : [Haskell-cafe] Re: circular imports

2010-09-07 Thread Johannes Waldmann
Henning Thielemann schlepptop at henning-thielemann.de writes:

 As I see there is no cycle in the types. How about defining Game, Rule,
 Obs in private modules, like Private.Game, Private.Rule, Private.Obs,
 and implementing the functions in public modules like Game, Rule, Obs ?

I guess that conflicts with the advice of putting the
functions (behaviour) close to the data that it concerns.

But if a function mentions two types (and the types are separate),
it requires a decision -  in OO as well: you would (arbitrarily) 
make them a method of one class or the other.

J.W.


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


[Haskell-cafe] Re: ghc HEAD

2010-09-07 Thread Johannes Waldmann
Yuras Shumovich shumovichy at gmail.com writes:

 http://hackage.haskell.org/trac/ghc/ticket/3910

So what is the magic link-time flag to en/disable the RTS options?

It seems it would be needed for all things multi-core,
since you'd want to modify +RTS -Nx 

J.W.


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


Re: Réf. : [Haskell-cafe] Re: circular imports

2010-09-07 Thread Henning Thielemann


On Tue, 7 Sep 2010, Johannes Waldmann wrote:


Henning Thielemann schlepptop at henning-thielemann.de writes:


As I see there is no cycle in the types. How about defining Game, Rule,
Obs in private modules, like Private.Game, Private.Rule, Private.Obs,
and implementing the functions in public modules like Game, Rule, Obs ?


I guess that conflicts with the advice of putting the
functions (behaviour) close to the data that it concerns.


Of course, the public module Game shall export the Game type from 
Private.Game and so on. That is from the perspective of the Game package 
user, the Game type and related functions can be imported from the same 
module. The inconvenience of defining the Game type and its functions in 
distinct modules exists only for corentin.dupont but not for the user of 
his library.

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


Re: [Haskell-cafe] Re: ghc HEAD

2010-09-07 Thread Edward Z. Yang
Excerpts from Johannes Waldmann's message of Tue Sep 07 10:38:47 -0400 2010:
 Yuras Shumovich shumovichy at gmail.com writes:
 
  http://hackage.haskell.org/trac/ghc/ticket/3910
 
 So what is the magic link-time flag to en/disable the RTS options?

As you mentioned earlier, -rtsopts.

 It seems it would be needed for all things multi-core,
 since you'd want to modify +RTS -Nx 

This is a good point: if RTS options are disabled, there should probably
be a mechanism for specifying what RTS options should be baked in.

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


Re: Searching for Haskell (was: [Haskell-cafe] Slightly humorous: Headhunters toolbox (example for Germany))

2010-09-07 Thread James Andrew Cook
On Aug 31, 2010, at 1:57 PM, Alberto G. Corona wrote:

 
 What happened in the first half of 2006? monads were high there!.
 

Wasn't that about the time Microsoft was previewing the Power Shell, 
codenamed Monad?

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


[Haskell-cafe] local-search

2010-09-07 Thread R Senington
I was recently at IFL2010, where I gave a short presentation on my the 
attempts to put together a local search library for Haskell.
This was reasonably well received, and I had a couple of requests for a 
library.


After a couple of days sanitizing the code, and learning a bit about how 
to package libraries for Hackage I am now announcing that the library
has been uploaded, version 0.0.1. Of course I managed to make an error 
in the summary so it start AA first rather than just A first.

I hope that people find this interesting and I look forward to feedback.

http://hackage.haskell.org/package/local-search

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


Re: [Haskell-cafe] Re: Paralelism and Distribution in Haskell

2010-09-07 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/7/10 05:08 , David Virebayre wrote:
 2010/9/7 Ben Lippmeier b...@ouroborus.net:
 Though be warned you must use a recent GHC head build to get good 
 performance. After GHC 7.0 is out (in a few weeks) we'll be able to release 
 a properly stable version.
 
 Pardon a probably stupid question, but did I miss something ?
 http://hackage.haskell.org/trac/ghc/roadmap

I think the change is because there's a new type inference engine coming,
which justifies the major version bump.

- -- 
brandon s. allbery [linux,solaris,freebsd,perl]  allb...@kf8nh.com
system administrator  [openafs,heimdal,too many hats]  allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon university  KF8NH
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkyGYi4ACgkQIn7hlCsL25UwXgCdHCeZezzttZe+RHJxeQCDQ3Gx
JFcAoMeQcbnaQWoGutTcpAH8EnnxVZ2V
=O6U3
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: ghc HEAD

2010-09-07 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/7/10 10:51 , Edward Z. Yang wrote:
 Excerpts from Johannes Waldmann's message of Tue Sep 07 10:38:47 -0400 2010:
 It seems it would be needed for all things multi-core,
 since you'd want to modify +RTS -Nx 
 
 This is a good point: if RTS options are disabled, there should probably
 be a mechanism for specifying what RTS options should be baked in.

I'd call this incomplete because programs compiled with RTS options enabled
are still insecure.

The correct fix is to ignore GHCRTS and die on +RTS *when setuid*.  Since
this isn't something that can be changed in a running process (well, not
without some fairly evil kernel memory poking) there are no race conditions
to watch out for; just ignore the RTS options when getuid() != geteuid() and
getuid() != 0 (and similar for setgid/setegid, although those are less
critical because gid is really only useful for filesystem permissions).

A better fix would be to identify safe settings and only allow those (and
only via +RTS) when setuid.  OTOH that's pretty much the system
configuration version of the Halting Problem :)

- -- 
brandon s. allbery [linux,solaris,freebsd,perl]  allb...@kf8nh.com
system administrator  [openafs,heimdal,too many hats]  allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon university  KF8NH
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkyGakwACgkQIn7hlCsL25UjmgCghMw4kmTsTxcCTYKYYLxGU8Yl
6HQAoIGA9axL8zqCwDpaR2PL/BGTEnpk
=XlOo
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to catch exception within the Get monad (the Binary package)

2010-09-07 Thread Henning Thielemann
Dimitry Golubovsky schrieb:
 Hi,
 
 Thanks to everybody who replied.
 
 I see another solution: are there any hidden problems?
 
 I found an interesting package, ChasingBottoms which contains a
 function testing a value to be bottom and returning a Boolean (of
 course it cannot be done without unsafePerformIO).
 
 I borrowed the idea from that package, and wrote two functions:
 
 unThrow :: (Exception e) = a - Either e a
 
 unThrow a = unsafePerformIO $ (E.evaluate a = return . Right) `E.catch`
(\e - return $ Left e)
 
 -- or perhaps the right argument of catch could be just (return . Left)?
 
 bm2mb :: a - Maybe a
 
 bm2mb a = case unThrow a of
Left (e::SomeException) - Nothing
Right a - Just a
 
 So, if there is a value inside the lazy list which is a bottom (binary
 parse failure of the last received object in this case, catching any
 possible exception) then the value can be converted to Nothing within
 pure code, and then excluded from the result using catMaybes.
 
 This solution seems to be working for me.

This solution looks very ugly to me. Catching 'error's is debugging, but
parser failure is kind of exception handling. I guess, the errors you
want to catch are caused by non-supported fail method, right? Can't you
use a monad transformer like explicit-exception:Synchronous.Exception or
transformers:ErrorT around the Binary parser?

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


Re[2]: [Haskell-cafe] Re: ghc HEAD

2010-09-07 Thread Bulat Ziganshin
Hello Brandon,

Tuesday, September 7, 2010, 8:37:32 PM, you wrote:

 I'd call this incomplete because programs compiled with RTS options enabled
 are still insecure.

 The correct fix is to ignore GHCRTS and die on +RTS *when setuid*.  Since

i strongly agree


-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

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


Re: [Haskell-cafe] random-fu confusion

2010-09-07 Thread James Andrew Cook
On Sep 7, 2010, at 10:21 AM, Alex Rozenshteyn wrote:

 Okay, I figured the immutability bit out and I got the IORef example working, 
 but I can't get it to work with state.
 
  put (pureMT 0) = runRVar flipCoin
 
 gives me two type errors: No instance for (MonadState PureMT m) and No 
 instance for (RandomSource m ())
 

The first error is because put has the general type: put :: (MonadState s m) 
= s - m () and GHC doesn't know what monad you want to evaluate it in.  Just 
off the bat there are 2 possibilities provided by Control.Monad.State: State 
and StateT.
The second is because runRVar requires an additional argument specifying the 
source from which to sample.  In your case, you want to sample from the 
standard source, the MonadRandom instance.  The type StdRandom with a 
single constructor of the same name designates the MonadRandom instance.  So 
for your example, a working incantation would be:

 put (pureMT 0) = runRVar flipCoin StdRandom :: State PureMT Bool

To actually run this action you would then use runState or evalState, in which 
case the type annotation would no longer be necessary because the use of 
runState or evalState would give the compiler enough information to know what 
you want.  These functions both also accept an initial state as an argument, so 
you don't actually need put either:

 evalState (runRVar flipCoin StdRandom) (pureMT 0)

Using the sample function I mentioned earlier you can leave off the mention 
of StdRandom:

 evalState (sample flipCoin) (pureMT 0)

  I'm trying to do figure out how to do this without going to the IO monad (so 
 I can run it with the same seed to replicate results).

Incidentally, you can use the 'pureMT' function to seed your generator in the 
IO monad just as easily:

 newIORef (pureMT 0) = \src - runRVar flipCoin src
 
or

 do src - newIORef (pureMT 0); runRVar flipCoin src

A large part of the point of the RVar monad as its own independent construct is 
to allow you to use random variables such as flipCoin in any monad that can 
support them while at the same time guaranteeing all the same purity / safety 
as if you had used something obviously pure such as State.

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


Re: Réf. : [Haskell-cafe] Re: circular imports

2010-09-07 Thread Claus Reinke

That sort of code (stripped out):

In Game.hs:

data Game = Game { ...
  activeRules :: [Rule]}

applyTo :: Rule - Game - Game
applyTo r gs = ...


Often, it helps to parameterize the types/functions (instead
of using recursive  modules to hardcode the parameters).

Would something like this work for your case (taking the
Game module out of the loop)?

data Game rule = Game { ...
 activeRules :: [rule]}

applyTo :: rule - Game rule - Game rule
applyTo r gs = ...


In Rule.hs:
.. 
isRuleLegal :: Rule - NamedRule - Game Rule - Bool

isRuleLegal = ...

In Obs.hs:

evalObs :: Obs - NamedRule - Game Rule - EvalObsType
evalObs = ...


For the record, I'd like to have recursive modules without
having to go outside the language (some standardized
notion of Haskell module interfaces would be nicer than
implementation-specific boot files). 


But I'd like to have parameterized modules even more,
as that would allow me to avoid many use cases of
recursive modules (again, that would seem to require
module interfaces).

Claus

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


Re: [Haskell-cafe] Pointed (was: Re: Restricted type classes)

2010-09-07 Thread Sebastian Fischer


On Sep 7, 2010, at 5:23 AM, wren ng thornton wrote:

In particular, one of the primary complaints against the Monad class  
is precisely the fact that it *fails* to mention the Functor class  
as a (transitive) dependency. Why should we believe that making unit  
independent from fmap will fare any better?


A noteworthy difference is that fmap can be defined in terms of return  
and = but not in terms of point. IMHO, this is a good reason why  
fmap should be defined for every Monad and may be missing for some  
Pointed.


Sebastian


--
Underestimating the novelty of the future is a time-honored tradition.
(D.G.)



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


Re: [Haskell-cafe] help me evangelize haskell.

2010-09-07 Thread C K Kashyap
Hi Dan,
This presentation is really nice.
I went over it a couple of times and I think this ppt will help me try
to use Haskell for things that I usually use Perl for :)

A quick question - import Process bombs on my GHCI(The Glorious
Glasgow Haskell Compilation System, version 6.12.3) -what do I need to
do for that?


On Sun, Sep 5, 2010 at 11:12 PM, Don Stewart d...@galois.com wrote:
 Gaius:
 My usual rhetoric is that one-off, throwaway scripts never are, and
 not only do they tend to stay around but they take on a life of their
 own. Today's 10-line file munger is tomorrow's thousand-line ETL batch
 job on which the business depends for some crucial data - yet the
 original author is long gone and no-one dares modify in case it
 breaks. So it is just good sense to use sound practices from the very
 beginning.

 I gave a tech talk recently on using Haskell for scripting -- and it is
 built on the idea that today's throw away script is tomorrow's key piece
 of infrastructure -- so you better get the maintainance and safety story
 right:

    http://donsbot.wordpress.com/2010/08/17/practical-haskell/
 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe




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


Re: [Haskell-cafe] help me evangelize haskell.

2010-09-07 Thread Don Stewart
That's a separate module, based on System.Process -- 

http://code.haskell.org/~dons/code/cpuperf/Process.hs

ckkashyap:
 Hi Dan,
 This presentation is really nice.
 I went over it a couple of times and I think this ppt will help me try
 to use Haskell for things that I usually use Perl for :)
 
 A quick question - import Process bombs on my GHCI(The Glorious
 Glasgow Haskell Compilation System, version 6.12.3) -what do I need to
 do for that?
 
 
 On Sun, Sep 5, 2010 at 11:12 PM, Don Stewart d...@galois.com wrote:
  Gaius:
  My usual rhetoric is that one-off, throwaway scripts never are, and
  not only do they tend to stay around but they take on a life of their
  own. Today's 10-line file munger is tomorrow's thousand-line ETL batch
  job on which the business depends for some crucial data - yet the
  original author is long gone and no-one dares modify in case it
  breaks. So it is just good sense to use sound practices from the very
  beginning.
 
  I gave a tech talk recently on using Haskell for scripting -- and it is
  built on the idea that today's throw away script is tomorrow's key piece
  of infrastructure -- so you better get the maintainance and safety story
  right:
 
     http://donsbot.wordpress.com/2010/08/17/practical-haskell/
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 
 
 
 
 -- 
 Regards,
 Kashyap
 
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] PSA: using MySQL from Haskell programs

2010-09-07 Thread Bryan O'Sullivan
If you are using HDBC-mysql or HDBC-odbc to access MySQL databases, you may
have run into problems with your programs failing due to connection errors.
In this blog posting, I describe what's happening and how to work around it:

http://www.serpentine.com/blog/2010/09/04/dealing-with-fragile-c-libraries-e-g-mysql-from-haskell/
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Proposal: Form a haskell.org committee

2010-09-07 Thread Bryan O'Sullivan
On Sun, Sep 5, 2010 at 9:34 PM, Jason Dagit da...@codersbase.com wrote:

 The darcs project uses the Software Freedom Conservancy as a sort of
 legal entity to hold on to funds and also to help in case anyone takes
 legal action against darcs or darcs needs to take legal action.


I have only the highest praise for the Software Freedom Conservancy folks.
They are smart, capabale, and very accommodating.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: Fwd: Semantics of iteratees, enumerators, enumeratees?

2010-09-07 Thread John Millikin
On Mon, Sep 6, 2010 at 22:49, Ben midfi...@gmail.com wrote:
 Sorry to be late coming into this conversation.

 Something that has bothered me (which I have mentioned to John Lato
 privately) is that it is very easy to write non-compositional code due
 to the chunking.  For example, there is a standard function

 map :: (a - b) - Enumeratee a b c

 whose meaning I hope is clear : use the function to transform the type
 of a stream and pass it to an iteratee.  However last I checked the
 versions provided in both the iteratee and enumerator packages fail to
 satisfy the equation

 map f (it1  it2) == (map f it1)  (map f it 2)

 because of chunking, essentially.  You can check this with f == id and
 it1 and it2 are head:

 let r = runIdentity . runIteratee

 runIdentity $ run $ enumList 10 [1..100] $ r $ joinI $ map id $ r (head  
 head)
 -- Right (Just 2)

 runIdentity $ run $ enumList 10 [1..100] $ r $ joinI $ (map id $ r
 head)  (map id $ r head)
 -- Right (Just 11)

 It is possible to fix this behavior, but it complicates the obvious
 definitions a lot.

Chunking doesn't have anything to do with this, and an iteratee
encoding without input chunking would exhibit the same problem. You're
running into an (annoying? dangerous?) subtlety in enumeratees. In the
particular case of map/head, it's possible to construct an iteratee
with the expected behavior by altering the definition of 'map'.
However, if the composition is more complicated (like map/parse-json),
this alteration becomes impossible.

Remember than an enumeratee's return value contains two levels of
extra input. The outer layer is from the enumeratee (map), while the
inner is from the iteratee (head). The iteratee is allowed to consume
an arbitrary amount of input before yielding, and depending on its
purpose it might yield extra input from a previous stream.

Perhaps the problem is that 'map' is the wrong name? It might make
users expect that it composes horizontally rather than vertically.
Normally this incorrect interpretation would be caught by the type
checker, but using () allows the code to compile.

Anyway, the correct way to encode @(map f it1)  (map f it 2)@, using
above style is:

(map id (r head) = returnI)  (map id (r head) = returnI)

so the full expression becomes:

runIdentity $ run $ enumList 10 [1..100] $ r $ (map id (r head)
= returnI)  (map id (r head) = returnI)

which ought to return the correct value (untested; I have no Haskell
compiler on this computer).
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: [Haskell] ANNOUNCE: reference 0.1

2010-09-07 Thread Maciej Piechotka
On Tue, 2010-09-07 at 02:15 +0200, Bas van Dijk wrote:
 On Mon, Sep 6, 2010 at 11:55 PM, Maciej Piechotka uzytkown...@gmail.com 
 wrote:
  Reference is class which generalizes references and monads they exists
  in. It means that IORef, STRef and others can be accessed by common
  interface.
 
  Currently it is of form:
 
  class Reference r m where
 
  1. There was a proposal to rename the class to MonadRef or
  MonadReference. IMHO it would imply m - r functional dependency and
  therefore disallow the instances for both MVar IO and IORef IO
 
  2. Should the functional dependencies or type famillies be introduced?
  Personally I don't think so as I would like to allow all of the
  following:
 
   - IORef IO
   - MVar IO
   - IORef (ContT IO)
   - MVar (ContT IO)
 
  Any feedback mostly welcome.
 
  Regards
  PS. Darcs repository will be available soon
 
  ___
  Haskell mailing list
  hask...@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell
 
 
 


First I'd like to say sorry for error in cafe mailing list address. The
whole e-mail is included above.

 I've played with a somewhat similar idea:
 
 darcs get http://code.haskell.org/~basvandijk/code/only-read-or-write-vars
 
 API Docs + Hyperlinked source:
 http://code.haskell.org/~basvandijk/code/only-read-or-write-vars/doc/html/only-read-or-write-vars/
 
 This is not released (yet) because I'm unsure about the design.
 
 Especially, I'm unsure whether parameterizing Readable with α is a good idea:
 
 class Readable v m α | v → m where read  v → m α
 
 and whether parameterizing Writable with α and β is a good idea:
 
 class Writable v α m β | v → m where write  v → α → m β
 
 They do allow some some nice instances like:
 
 instance Readable (TMVar α) STM (Maybe α) where
 read = TMVar.tryTakeTMVar
 
 instance Writable (TMVar α) α STM Bool where
 write = TMVar.tryPutTMVar
 
 instance Writable (Chan α) (End α) IO () where
 write t = Chan.unGetChan t  unEnd
 
 -- | Writing @End x@ to a 'Chan' or 'TChan' writes @x@ to the end of
the channel
 -- instead of to the front. Also see 'unGetChan' and 'unGetTChan'.
 newtype End α = End {unEnd  α}
 
 Regards,
 
 Bas
 

I guess they are to some extend like Foldable to FoldableLL and possibly
describing different aspects. Yours seems to be a bit like StateVar[1]
generalized for different monads. Support for ptr  others is additional
bonus.

I wanted clear 1-1 mapping with references - i.e. basic 2 operations
with added third for 'atomic' support. 

For example one of unmentioned law is that:

write r x  read r  ===  write r x  return r -- If it's only thread
write r x  write r y === write r y -- If it's only thread
read r  read r === read r
read r = write r === id -- If it's only thread
read r = const f === f -- If it's only thread?

In fact I guess each on them could be used as RULES as IMHO each case in
which it is not necessary true it is undeterministic anyway.

While Chan is clearly writable and readable it cannot be considered a
reference - it do have it purposes but they are usually different then
references.

To sum up - I would not be willing to use Readable/Writable in place of
Reference but I don't say they don't have their purposes.

PS. I took the liberty of continuing sentence.

[1] http://hackage.haskell.org/package/StateVar-1.0.0.0


signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: [Haskell] ANNOUNCE: reference 0.1

2010-09-07 Thread Alberto G. Corona
Why not to define it for any monad, for example STM (TVars) and whatever?

2010/9/7 Maciej Piechotka uzytkown...@gmail.com

 On Tue, 2010-09-07 at 02:15 +0200, Bas van Dijk wrote:
  On Mon, Sep 6, 2010 at 11:55 PM, Maciej Piechotka uzytkown...@gmail.com
 wrote:
   Reference is class which generalizes references and monads they exists
   in. It means that IORef, STRef and others can be accessed by common
   interface.
  
   Currently it is of form:
  
   class Reference r m where
  
   1. There was a proposal to rename the class to MonadRef or
   MonadReference. IMHO it would imply m - r functional dependency and
   therefore disallow the instances for both MVar IO and IORef IO
  
   2. Should the functional dependencies or type famillies be introduced?
   Personally I don't think so as I would like to allow all of the
   following:
  
- IORef IO
- MVar IO
- IORef (ContT IO)
- MVar (ContT IO)
  
   Any feedback mostly welcome.
  
   Regards
   PS. Darcs repository will be available soon
  
   ___
   Haskell mailing list
   hask...@haskell.org
   http://www.haskell.org/mailman/listinfo/haskell
  
  
 


 First I'd like to say sorry for error in cafe mailing list address. The
 whole e-mail is included above.

  I've played with a somewhat similar idea:
 
  darcs get
 http://code.haskell.org/~basvandijk/code/only-read-or-write-vars
 
  API Docs + Hyperlinked source:
 
 http://code.haskell.org/~basvandijk/code/only-read-or-write-vars/doc/html/only-read-or-write-vars/
 
  This is not released (yet) because I'm unsure about the design.
 
  Especially, I'm unsure whether parameterizing Readable with α is a good
 idea:
 
  class Readable v m α | v → m where read  v → m α
 
  and whether parameterizing Writable with α and β is a good idea:
 
  class Writable v α m β | v → m where write  v → α → m β
 
  They do allow some some nice instances like:
 
  instance Readable (TMVar α) STM (Maybe α) where
  read = TMVar.tryTakeTMVar
 
  instance Writable (TMVar α) α STM Bool where
  write = TMVar.tryPutTMVar
 
  instance Writable (Chan α) (End α) IO () where
  write t = Chan.unGetChan t  unEnd
 
  -- | Writing @End x@ to a 'Chan' or 'TChan' writes @x@ to the end of
 the channel
  -- instead of to the front. Also see 'unGetChan' and 'unGetTChan'.
  newtype End α = End {unEnd  α}
 
  Regards,
 
  Bas
 

 I guess they are to some extend like Foldable to FoldableLL and possibly
 describing different aspects. Yours seems to be a bit like StateVar[1]
 generalized for different monads. Support for ptr  others is additional
 bonus.

 I wanted clear 1-1 mapping with references - i.e. basic 2 operations
 with added third for 'atomic' support.

 For example one of unmentioned law is that:

 write r x  read r  ===  write r x  return r -- If it's only thread
 write r x  write r y === write r y -- If it's only thread
 read r  read r === read r
 read r = write r === id -- If it's only thread
 read r = const f === f -- If it's only thread?

 In fact I guess each on them could be used as RULES as IMHO each case in
 which it is not necessary true it is undeterministic anyway.

 While Chan is clearly writable and readable it cannot be considered a
 reference - it do have it purposes but they are usually different then
 references.

 To sum up - I would not be willing to use Readable/Writable in place of
 Reference but I don't say they don't have their purposes.

 PS. I took the liberty of continuing sentence.

 [1] http://hackage.haskell.org/package/StateVar-1.0.0.0

 ___
 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] Handling platform- or configuration-specific code (or, my CPP complaints)

2010-09-07 Thread Ben Millwood
Good evening, cafe,

Having recently taken on maintenance of a package that depends on
template-haskell, I've been in some discussion with users and
dependencies of my package about how best to write a library that
works with multiple incompatible versions of a dependency. The two
main approaches that I'm aware of are:
1. Use CPP and the macros defined by Cabal to conditionally include or
exclude code for each version.
2. Use Cabal file conditionals to select hs-source-dirs containing
those parts of the code (or even TH to help generate those parts of
the code) that are specific to each configuration.

In my discussion with others and examination of existing libraries, it
seems to me that 1. is the preferred option, but I personally can
think of a number of reasons to prefer the second option:
* CPP was not designed for Haskell, and even cpphs still shows
symptoms of it, so we have to worry about things like its handling of
string gaps or single quotes.
* CPP is primarily a textual manipulation tool, rather than a symbolic
one, which makes it even more easy to produce malformed code with it
than with TH or similar.
* On that note, it's difficult to statically analyse a file using CPP:
parser tools like haskell-src-exts don't support it and it's not at
all obvious how or if they ever could. With Cabal choosing source
files based on configuration, all the source is valid, normal Haskell
and is easy for computers and humans to understand.
* It may require some significant digging into each source file to
establish what configurations must be tested, or to add a new
supported configuration or remove an old one, if they are chosen based
on CPP conditional compilation. When Cabal chooses what is compiled it
is fairly explicit what is chosen and what could be, and adding a new
configuration is - at least in theory - as simple as adding a new file
and conditional.
* It's just not very pretty! Haskell code has a sort of aesthetic that
I don't think CPP macros share - different function application
syntax, for example.

Of course the trouble is that when your conditional compilation is on
the module level there are some things which just can't be done
without code duplication, and there's a tendency for small and often
quite incidental bits of a function definition to suddenly be in
another module instead of where they're used. So I wonder what people
think of the use of CPP in Haskell code, what alternatives people can
propose, or what people hope to see in future to make conditional
compilation of Haskell code more elegant and simple?

I once pondered whether it would be a good idea to somehow make
available to TH splices information from Cabal or GHC's configuration,
so that one could do something like this:

myFunctionDecl = if packageVersion template-haskell = Version [2, 4] []
  then [d| unTyVarBndr (PlainTV n) = n; unTyVarBndr (KindedTV n _) = n |]
  else [d| unTyVarBndr = id |]

This exactly wouldn't make sense because KindedTV wouldn't exist in
the earlier version so the quotation would object, but one could
imagine something similar being useful.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Re: [Haskell] ANNOUNCE: reference 0.1

2010-09-07 Thread Maciej Piechotka
On Tue, 2010-09-07 at 20:36 +0200, Alberto G. Corona wrote:
 Why not to define it for any monad, for example STM (TVars) and
 whatever?

I'm really sorry but I fail to see what does 'it' refers to. reference
0.1 contains at this moment definitions for:

- Reference TVar STM
- Reference IORef IO
- Reference MVar IO
- Reference (STRef s) (ST s)

(http://hackage.haskell.org/packages/archive/reference/0.1/doc/html/Data-Reference.html#t:Reference)

So in fact there is already support for STM/TVar pair.

Regards



signature.asc
Description: This is a digitally signed message part
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] PSA: using MySQL from Haskell programs

2010-09-07 Thread Gaius Hammond


On 7 Sep 2010, at 18:46, Bryan O'Sullivan wrote:

If you are using HDBC-mysql or HDBC-odbc to access MySQL databases,  
you may have run into problems with your programs failing due to  
connection errors. In this blog posting, I describe what's happening  
and how to work around it:


http://www.serpentine.com/blog/2010/09/04/dealing-with-fragile-c-libraries-e-g-mysql-from-haskell/
___



Interestingly a similar issue was posted recently on Hacker News: 
http://news.ycombinator.com/item?id=1661986




Cheers,




G




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


[Haskell-cafe] Re: Haskell-Cafe Digest, Vol 85, Issue 20

2010-09-07 Thread Jeff Rubard
Do U like combinatory logic - or lambda calculus?
It still matters, or something.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to catch exception within the Get monad (theBinary package)

2010-09-07 Thread Donn Cave
Quoth Dimitry Golubovsky golubov...@gmail.com,

 I see another solution: are there any hidden problems?

 I found an interesting package, ChasingBottoms which contains a
 function testing a value to be bottom and returning a Boolean (of
 course it cannot be done without unsafePerformIO).

 I borrowed the idea from that package, and wrote two functions:

 unThrow :: (Exception e) = a - Either e a

 unThrow a = unsafePerformIO $ (E.evaluate a = return . Right) `E.catch`
(\e - return $ Left e)

Like Henning, I'm not going to try to predict a specific problem
with it, but I don't like it.

Have you had a chance to look at cereal (Data.Serialize)?  I frankly
couldn't make it do what you need, as written, but I could make it
work if I modify Serialize.Get to export Get(..) instead of Get.
From there I wrote a variant of the Get (=) function with an
additional end-value-on-failure parameter, [] in your program:

 ebind m g e = Get (\ s0 f k - unGet m s0 (\ _ _ - k B.empty e)
(\ s a - unGet (g a) s f k))

... so to get your error bounded array of Int,

  getx = ebind get (\ a - getx = return . (:) a) []

I think it's very likely there's a simpler way to do this with
Data.Serial as written, I am just a little backwards with state
monads and that kind of thing.

Donn Cave, d...@avvanta.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] [ANN] Crypto-API 0.0.0.1 Released

2010-09-07 Thread Thomas DuBuisson
At long last and after much fruitful discussion on
librar...@haskell.org, Crypto-API is having its first release, version
0.0.0.1!

Crypto-API is a generic interface for cryptographic operations,
platform independent  quality entropy acquisition, property tests and
known-answer tests (KATs) for common algorithms, and a basic benchmark
infrastructure.  Maintainers of hash and cipher implementations are
encouraged to add instances for the classes defined in Crypto.Classes.
 Crypto users are similarly encouraged to use the interfaces provided.

Any concepts or functions of general use to more than one
cryptographic algorithm (ex: padding) is within scope of this package.

Hackage: http://hackage.haskell.org/package/crypto-api
Haddock: http://web.cecs.pdx.edu/~dubuisst/crypto-api-0.0.0.1/html/index.html
Blog: http://tommd.wordpress.com/2010/09/07/crypto-api-released/

At it's heart, Crypto-API is an interface to cryptographic algorithms
allowing crypto developers to provide a minimal, low level interface
and reuse generic higher-level functions while freeing crypto users
from specifying a particular algorithm or implementation.

 Highlights 
* Five type classes of Hash, BlockCipher, AsymCipher, StreamCipher,
and CryptoRandomGen
* Generic algorithms implemented using these class interfaces (ex:
block cipher modes of operation, hashing and HMAC)
* Platform independent acquisition of entropy for cryptographic use
(using /dev/urandom on *nix and the CryptoAPI on windows)
* Test suite and parsing of NIST KAT files
* Rudimentary benchmarking for BlockCipher, Hash, and RNGs

 Hash Example 
The hash developer defines a class instances:

 instance Hash MD5Context MD5Digest where
outputLength = Tagged 128
blockLength  = Tagged 512
initialCtx   = md5InitialContext
updateCtx= md5Update
finalize = md5Finalize

The hash user can remain agnostic about which type of hash is used:

 authMessage :: Hash ctx dgst = B.ByteString - MacKey - dgst - Bool
 authMessage msg k = (==) (hmac' k msg)

More examples can be found on the blog post.

Versioning
I don't intend to bump the version number for API changes in modules
that aren't built by default (Test.Crypto, Benchmark.Crypto).
Otherwise the PVP is in effect.  Let me know if this isn't
appreciated.

 Changes Since Release Candidate 
* Haddock documentation
* Crypto.HMAC uses MacKey to help users keep the key and message separate

Remaining TODO
* Optimize block cipher modes and add new ones
* Migrate Crypto.Random to the random package, pending conversation
and agreement.
* a signature class is planned for signature-only algorithms (DSA)
   class (Binary k, Serialize k) = Signing k where
   sign :: ...
   verify :: ...
* Verify Crypto.Random works on Windows (more likely: fix it) once a
Windows dev shows interest.
* Build and test Crypto.Padding
* Expand test suite.  Include other hashes, modes, block algorithms,
cipher properties.
* Improve benchmarks, use CryptoRandomGen class in benchmark.
* More Haddock documentation
* Consider adding buildIV :: (CryptoRandomGen g) = g - Either
GenError iv routine to StreamCipher interface

Cheers,
Thomas M. DuBuisson
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to catch exception within the Get monad (the Binary package)

2010-09-07 Thread Alexey Khudyakov

On 07.09.2010 20:51, Henning Thielemann wrote:

This solution looks very ugly to me. Catching 'error's is debugging, but
parser failure is kind of exception handling. I guess, the errors you
want to catch are caused by non-supported fail method, right? Can't you
use a monad transformer like explicit-exception:Synchronous.Exception or
transformers:ErrorT around the Binary parser?

ErrorT is useless here since it cannot intercept calls to 'error'. Same 
should be the case with ExcepcionalT. There is also performance penalty


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


Re: [Haskell-cafe] Re: Haskell-Cafe Digest, Vol 85, Issue 20

2010-09-07 Thread Conrad Parker
Very!

On Sep 8, 2010 4:45 AM, Jeff Rubard jeffrub...@gmail.com wrote:

Do U like combinatory logic - or lambda calculus?
It still matters, or something.
___
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] How to catch exception within the Get monad (the Binary package)

2010-09-07 Thread Ben Millwood
On Tue, Sep 7, 2010 at 2:45 PM, Dimitry Golubovsky golubov...@gmail.com wrote:
 unThrow a = unsafePerformIO $ (E.evaluate a = return . Right) `E.catch`
                                               (\e - return $ Left e)

 -- or perhaps the right argument of catch could be just (return . Left)?

 bm2mb :: a - Maybe a

 bm2mb a = case unThrow a of
   Left (e::SomeException) - Nothing
   Right a - Just a

Philosophically these functions are Nasty because they violate
referential transparency. In particular it's possible for the same
expression to throw different exceptions each time it's run depending
on how it's optimised, what other threads are doing, if the user
presses ctrl-C, etc. etc.
See the spoon package:

http://hackage.haskell.org/package/spoon

which alleviates this a little by only catching some kinds of
exception, and not telling you which it caught. It still violates
monotonicity (I believe), so purists will be upset, but practically it
can be useful for when editing the source code to provide explicit
exceptions (which is ideally what you'd do) is not an option.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to catch exception within the Get monad(theBinary package)

2010-09-07 Thread Donn Cave
Quoth Donn Cave d...@avvanta.com,
...
 I think it's very likely there's a simpler way to do this with
 Data.Serial as written, I am just a little backwards with state
 monads and that kind of thing.

OK, another look at it reveals that mplus can be used for this
application, so much more simply,

import Control.Monad (mplus)

getx = do
a - get
x - getn `mplus` return []
return (a:x)




Donn Cave, d...@avvanta.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] PSA: using MySQL from Haskell programs

2010-09-07 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 9/7/10 14:43 , Gaius Hammond wrote:
 On 7 Sep 2010, at 18:46, Bryan O'Sullivan wrote:
 If you are using HDBC-mysql or HDBC-odbc to access MySQL databases, you
 may have run into problems with your programs failing due to connection
 errors. In this blog posting, I describe what's happening and how to work
 around it:

 http://www.serpentine.com/blog/2010/09/04/dealing-with-fragile-c-libraries-e-g-mysql-from-haskell/
 
 Interestingly a similar issue was posted recently on Hacker
 News: http://news.ycombinator.com/item?id=1661986

BSD (CSRG) UNIX had restartable system calls (no EINTR except from select(),
which you had to use if you wanted to be interruptible under some
circumstances which I'm not recalling off the top of my head right now; more
than a few programs that didn't follow the rules turned out to not support
any kind of interruptibility until rewritten to use select()).  ATT
commercial UNIX kept the original Research Edition UNIX EINTR semantics.
POSIX had to reconcile them; the decision was to go with EINTR (you can
simulate restartable system calls by looping on EINTR, but if restartable
system calls are the default the only way to escape them is to rewire the
program to use select() as above) but systems could offer sigaction() flag
SA_RESTARTHAND to enable system call restarting on a signal-by-signal basis.
 (Note that SA_RESTARTHAND is not required for compliance, but a compliant
system with SA_RESTARTHAND must have compliant semantics for it or call it
something else.)

- -- 
brandon s. allbery [linux,solaris,freebsd,perl]  allb...@kf8nh.com
system administrator  [openafs,heimdal,too many hats]  allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon university  KF8NH
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkyGz6wACgkQIn7hlCsL25WargCeKQp4iEMO6y036eFCleertO10
KeEAoK3B9kpVinNWlSnUprAwcAAPtCAI
=Yd6E
-END PGP SIGNATURE-
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] help me evangelize haskell.

2010-09-07 Thread C K Kashyap
Thanks Don!

On Tue, Sep 7, 2010 at 10:51 PM, Don Stewart d...@galois.com wrote:
 That's a separate module, based on System.Process --

    http://code.haskell.org/~dons/code/cpuperf/Process.hs

 ckkashyap:
 Hi Dan,
 This presentation is really nice.
 I went over it a couple of times and I think this ppt will help me try
 to use Haskell for things that I usually use Perl for :)

 A quick question - import Process bombs on my GHCI(The Glorious
 Glasgow Haskell Compilation System, version 6.12.3) -what do I need to
 do for that?


 On Sun, Sep 5, 2010 at 11:12 PM, Don Stewart d...@galois.com wrote:
  Gaius:
  My usual rhetoric is that one-off, throwaway scripts never are, and
  not only do they tend to stay around but they take on a life of their
  own. Today's 10-line file munger is tomorrow's thousand-line ETL batch
  job on which the business depends for some crucial data - yet the
  original author is long gone and no-one dares modify in case it
  breaks. So it is just good sense to use sound practices from the very
  beginning.
 
  I gave a tech talk recently on using Haskell for scripting -- and it is
  built on the idea that today's throw away script is tomorrow's key piece
  of infrastructure -- so you better get the maintainance and safety story
  right:
 
     http://donsbot.wordpress.com/2010/08/17/practical-haskell/
  ___
  Haskell-Cafe mailing list
  Haskell-Cafe@haskell.org
  http://www.haskell.org/mailman/listinfo/haskell-cafe
 



 --
 Regards,
 Kashyap





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


Re: [Haskell-cafe] Re: ghc HEAD

2010-09-07 Thread Ivan Lazar Miljenovic
On 8 September 2010 02:37, Brandon S Allbery KF8NH allb...@ece.cmu.edu wrote:
 A better fix would be to identify safe settings and only allow those (and
 only via +RTS) when setuid.  OTOH that's pretty much the system
 configuration version of the Halting Problem :)

Or optionally, allow the developer to specify which flags are safe
(e.g. users are allowed to specify -N).

-- 
Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com
IvanMiljenovic.wordpress.com
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to catch exception within the Get monad (the Binary package)

2010-09-07 Thread Dimitry Golubovsky
Henning,

On Tue, Sep 7, 2010 at 12:51 PM, Henning Thielemann
schlepp...@henning-thielemann.de wrote:


 This solution looks very ugly to me. Catching 'error's is debugging, but
 parser failure is kind of exception handling. I guess, the errors you
 want to catch are caused by non-supported fail method, right? Can't you
 use a monad transformer like explicit-exception:Synchronous.Exception or
 transformers:ErrorT around the Binary parser?

Alexey already replied, but after looking at the way Binary processes
parser errors I came to the same conclusion: it is by design that it
falls hard when data cannot be deserialized (btw makes sense in many
cases, but not in mine).

I am beginning to realize that probably (de)serializing lazy
structures is not a good idea at all since such structure may be
consumed in pure code, and such parser errors are hidden inside, and
may fire at any moment. Any complications to the binary parser will
bring performance penalty. Or weird solutions like mine are needed.

Thanks.

-- 
Dimitry Golubovsky

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


Re: [Haskell-cafe] ANNOUNCE: Grempa 0.1.0, Embedded grammar DSL and LALR parser generator

2010-09-07 Thread Paulo Tanimoto
Hi Olle,

On Mon, Sep 6, 2010 at 12:45 PM, Olle Fredriksson
fredriksson.o...@gmail.com wrote:
 There are a few other examples in the examples directory of the package,
 most
 notably a grammar and parser for a simple functional language similar to
 Haskell.
 It is possible to generate random input strings and their expected outputs
 for grammars written using Grempa which makes it possible to test the
 generated
 parsers with QuickCheck.
 The package and documentation (should be up soon) can be found here:
 http://hackage.haskell.org/package/Grempa-0.1.0

Very nice job, I'm interested in using it.  I wonder why the
documentation hasn't been generated on Hackage yet.  (I generated it
for myself locally.)

Do you plan to set up a repository somewhere?

Thanks!

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


Re: [Haskell-cafe] CnC Haskell

2010-09-07 Thread Vasili I. Galchin
Hi Ryan,

 I see the generated C++ but where is the CnC front-end code?

Regards,

Vasili

On Thu, Sep 2, 2010 at 7:23 PM, Ryan Newton new...@mit.edu wrote:

 Belated update:

 The haskell-cnc distribution (if you grab it from darcs) now has a
 front-end that parses the graph description files.
 http://hackage.haskell.org/package/haskell-cnc

 For any readers who haven't seen this before --  CnC is a parallel
 programming model that includes both a library and a small DSL for graph
 specification.  The specification file describes the structure of an
 application and captures various invariants about data access.

 The CnC front-end in the haskell-cnc distro is meant to replace existing
 CnC spec translators and generate code for all host languages that support
 the programming model (currently C++, Java, .NET, Haskell).  Also the graph
 specification language is getting a refresh in the process (new
 features/syntax).  The parser is done with Happy.  What's there right now
 only generates C++ code, but the Haskell codegen is straightforward and
 should come along shortly (anyone want to help?).

 The purpose of such a front-end is to generate code that:
   (1) saves boilerplate in graph construction (more of a problem in
 non-haskell languages)
   (2) correctness: enforces invariants expressed in the specification
   (3) performance: generate code that embodies graph analysis and
 optimizations (based also on profiling data)

 Cheers,
   -Ryan



 On Fri, Jun 25, 2010 at 11:02 AM, David Peixotto d...@rice.edu wrote:

 There is a reference for the CnC grammar in the repository for the .NET
 implementation.

 http://github.com/dmpots/CnC.NET/blob/master/CnC.NET/CnC.NET/cnc.grammar

 The parser specification for fsyacc (the F# YACC implementation) is here:

 http://github.com/dmpots/CnC.NET/blob/master/CnC.NET/CnC.NET/Parser.fsy

 The textual representation is still in flux a bit, but this grammar should
 be enough of a guide for implementing a parser in Haskell. The grammar is
 left recursive, so using a parser generator like Happy would be a good
 choice.

 The textual representation will actually be a bit different depending on
 the underlying language since the types of items stored in a collection is
 part of the description. For example in C, an item collection that stores an
 array of ints would be declared like:

 [int* A];

 but in Haskell we would want to write something like

 [Array Int Int A];

 I think dealing with type declarations would in the textual representation
 would be the main difference in implementing the parser in Haskell. Once the
 textual representation has been parsed to an AST it should be possible to
 generate the Haskell code that builds the graph using the haskell-cnc
 package.

 -David

 On Jun 23, 2010, at 3:56 PM, Vasili I. Galchin wrote:



 On Wed, Jun 23, 2010 at 3:47 PM, Don Stewart d...@galois.com wrote:

 vigalchin:
  Hello,
 
   I have been reading work done at Rice University:  http://
  habanero.rice.edu/cnc. Some work has been done by
 http://www.cs.rice.edu/
  ~dmp4866/ on CnC for .Net. One component that David wrote a CnC
 translator that
  translates CnC textual form to the underlying language, e.g. F#. Is
 anybody
  working on a CnC textual form translator for Haskell so a Haskell user
 of CnC
  Haskell can write in a higher level??

 Ah, so by a translator from high level CnC form to this:


 http://hackage.haskell.org/packages/archive/haskell-cnc/latest/doc/hml/Intel-Cnc.htmlhttp://hackage.haskell.org/packages/archive/haskell-cnc/latest/doc/html/Intel-Cnc.html

^^ exactly what I mean


 ? Do you have a reference for the CnC textual form?

  ^^ if you mean something like a context-free grammatical
 definition of the CnC textual form ,,, the answer is I haven't seen such a
 reference.

 V.



 -- Don


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



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



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


Re: [Haskell-cafe] ANNOUNCE: text 0.8.0.0, fast Unicode text support

2010-09-07 Thread Bryan O'Sullivan
On Wed, Sep 1, 2010 at 12:29 PM, Daniel Fischer daniel.is.fisc...@web.dewrote:

 I'm on Linux. I guess that's another point in favour of it:)
 Do you happen to know why it's slower on a Mac?


I'd guess because of something to do with the system iconv.


 So I tentatively believe most of the difference is spent doing the
 replacements.


I have a Replace.hs benchmark in the main text repo, just to be sure we're
talking about the same thing. Factoring out the time spent on I/O, with GHC
HEAD, my replace code takes twice the space and time of that in the
stringsearch package. Given that the space involved is just 121KB maximum
residency while processing a 124MB file, I'm not concerned about it. And the
time required isn't a bad place to start from, I think.

By the way, as this implies, I can't reproduce your space behaviour at all.

I can now say more. Looking at Data.Text.Lazy.replace,

 replace s d = intercalate d . split s

, I also got a space leak with that for BS.Lazy's intercalate and
 stringsearch's split.


How did you observe the space leak? Looking at -hT charted with hp2ps shows
me nothing, and the program executes in constant space regardless of input
size.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe