Re: [Haskell-cafe] Applicative is like an Arrow

2013-08-18 Thread damodar kulkarni
Thanks again for the detailed and explanatory answer.

That's the reason I'm writing these huge responses, because I hope I can
 shorten this journey for others.


This has certainly helped me grasp some aspects in this regard.

While Monad Transformers are awesome and can solve many problems quite
 easily, I'm pretty sure that there is almost always a nicer, more
 functional way to solve such a problem.


Incidentally, I happened to bump in to this paper, it claims they have
found a way that allows us get rid of the need of monad transformers in a
more systematic manner, by using what they call Monad coproduct. The
paper titled Composing Monads Using Coproducts is here. [1]

I haven't understood it much till now, and it seems I will have to try real
hard to read this paper.

Ref.
[1] http://isi.uni-bremen.de/~cxl/habil/papers/icfp02.pdf


Thanks and regards,
-Damodar Kulkarni
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] ANN: hspec-test-framework - Run test-framework tests with Hspec

2013-08-18 Thread Simon Hengel
Hi,
I just released hspec-test-framework[1] and hspec-test-framework-th[2]
to Hackage.

They can be used to run test-framework tests with Hspec unmodified.

This can also be used to work around test-framework's incompatibility
with QuickCheck-2.6 and base-4.7.0 ;)

Have a look at the README for usage instructions:

https://github.com/sol/hspec-test-framework#readme

Cheers,
Simon

[1] http://hackage.haskell.org/package/hspec-test-framework
[2] http://hackage.haskell.org/package/hspec-test-framework-th

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


Re: [Haskell-cafe] ANN: hspec-test-framework - Run test-framework tests with Hspec

2013-08-18 Thread Alfredo Di Napoli
Hi Simon,

this is an exciting news!

May I ask the question that maybe is lurking in the shadow?

Due to the recent announcement of Roman's tasty library, are there plans
to basically release something similar to hspec-test-framework and
hspec-test-framework-th but targeting tasty instead?

Bye :)
A.


On 18 August 2013 14:50, Simon Hengel s...@typeful.net wrote:

 Hi,
 I just released hspec-test-framework[1] and hspec-test-framework-th[2]
 to Hackage.

 They can be used to run test-framework tests with Hspec unmodified.

 This can also be used to work around test-framework's incompatibility
 with QuickCheck-2.6 and base-4.7.0 ;)

 Have a look at the README for usage instructions:

 https://github.com/sol/hspec-test-framework#readme

 Cheers,
 Simon

 [1] http://hackage.haskell.org/package/hspec-test-framework
 [2] http://hackage.haskell.org/package/hspec-test-framework-th

 ___
 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] abs minBound (0 :: Int) negate minBound == (minBound :: Int)

2013-08-18 Thread Nicolas Frisby
The docs at


http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:gcd

give a NB mentioning that (abs minBound == minBound) is possible for
fixed-width types.

This holds, for example, at Int. It is also the case that (negate minBound
== minBound).

Two questions:

  1) This behavior surprised me. Does it surprise enough people to include
a warning in the Haddock for abs and negate? IE Here.


http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Num

  2) Is this a common behavior in other languages? My tinkering with gcc
suggests it does not support the value -2^63, but instead bottoms out at
(-2^63+1).

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


Re: [Haskell-cafe] Alternative name for return

2013-08-18 Thread Nikolaos Bezirgiannis
Dag Odenhall dag.odenh...@gmail.com writes:

 I particularly like she's (her?) syntax for Alternative. Not sure
 whether or not Idris has that. Applicative tuples would be nice too,
 something like (|a,b,c|) translating to liftA3 (,,) a b c. And
 operators too, liftA2 (+) a b as (| a + b |)?

I patched she and did applicative tuples. Check my recent blog post on
it:

http://blog.bezirg.net/posts/2013-08-03-enhancement-to-the-strathclyde-haskell-enhancement.html


She already does lifting of binary operators, AFAIK.

Cheers




 On Thu, Aug 15, 2013 at 11:08 AM, Erik Hesselink hessel...@gmail.com
 wrote:

 On Thu, Aug 15, 2013 at 5:39 AM, Jason Dagit dag...@gmail.com
 wrote:
  Also, if anyone wants to look at prior art first, Idris
 supports applicative
  brackets.

 As does she [0].

 Erik

 [0] https://personal.cis.strath.ac.uk/conor.mcbride/pub/she/
 idiom.html

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




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


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


[Haskell-cafe] ANN: processing-1.2.0.0. Graphic web applications with processing.js.

2013-08-18 Thread Daniel Díaz Casanueva
Hello readers of Haskell-Cafe.

Yesterday I uploaded a new version of the processing library [1].

== What is this library for? ==

The library is oriented to create graphic applications that run in a web
browser, with no need of running a server. It provides the user with a set
of functions and combinators that can be used to create an abstract piece
code. This code is rendered to the processing language syntax. Once the
code is uploaded, using processing.js [2], the output code is runnable from
any browser with JavaScript support. To quickly give you a taste of the
library, look at this animation, created with a simple recursive function:

http://daniel-diaz.github.io/projects/processing/mill.html

The code is here:

https://github.com/Daniel-Diaz/processing/blob/master/examples/mill.hs

== What's new? ==

After a couple of weeks working hard to have this library properly working,
I think it have reached a point of reasonable usability. As a proof, I have
written a simplified version of the Pac-Man game [3]. However, although I
have implemented some code optimizations, it seems that the game still does
not run smoothly in every web browser. I will definitely keep trying to
improve the performance of the code generated by the library.

I encourage you to try the library if you are interested, but keep in mind
that it is still in an early stage, and may contain bugs, lack some
important features, have an incomplete documentation or suffer from API
changes.

== References ==

[1] Library at Hackage -
http://hackage.haskell.org/package/processing-1.2.0.0
[2] Processing.js - http://processingjs.org
[3] Pac-Man game -
http://daniel-diaz.github.io/projects/processing/pacman.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: hspec-test-framework - Run test-framework tests with Hspec

2013-08-18 Thread Simon Hengel
Hi,

 Due to the recent announcement of Roman's tasty library, are there
 plans to basically release something similar to hspec-test-framework
 and hspec-test-framework-th but targeting tasty instead?

I care about Hspec[1] and want to provide an upgrade path for
test-framework users, but I'm looking forward to friendly competition ;)

Cheers,
Simon

[1] http://hspec.github.io/

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


[Haskell-cafe] MongoDB single insertions super slow

2013-08-18 Thread Kyle Hanson
I am trying to write a simple benchmark of testing 1000 single inserts in
mongodb, but doing single insertions is super slow. It takes nearly 40
seconds to perform these operations with the haskell mongodb driver, but
under a second to perform the same number of operations of single inserts
in python.

Here are the two files I am working with:

https://gist.github.com/hansonkd/6263648

I checked the BSON serialization, and writing it to a socket instead of
mongodb driver, makes the script run in under a second so the problem seems
to be with the mongodb driver.

Any insights would be appreciated.

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


Re: [Haskell-cafe] Database.postgreSQL.Simple - ambigious type

2013-08-18 Thread Hartmut Pfarr

Hi Tom,
I played a bit with your suggestion, and it is running now :-)
But instead of  IO [Int]  I think we need  IO [Only Int]   because of 
the 1-element-tupel problem?


With   IO [Only Int]   it looks like this:

---
{-# LANGUAGE OverloadedStrings #-}

import Database.PostgreSQL.Simple

myconn :: ConnectInfo
myconn = defaultConnectInfo {
connectUser = test,
connectPassword = test,
connectDatabase = test}

main :: IO ()
main = do
  c - connect myconn :: IO Connection
  rs - query_ c select 2 + 2 :: IO [Only Int]
  putStrLn $ Result from database  ++ show (fromOnly $ head rs)
  return ()
---

Best regards
Hartmut

On 08/18/2013 12:11 AM, Tom Ellis wrote:

On Sat, Aug 17, 2013 at 11:59:24PM +0200, Hartmut Pfarr wrote:

{-# LANGUAGE OverloadedStrings #-}

import Database.PostgreSQL.Simple
import Database.PostgreSQL.Simple.FromRow

hello :: (FromRow a) = IO [a]
hello = do
   conn - connect defaultConnectInfo
   query_ conn select 2 + 2


Either

 main = print = (hello :: IO [Int])

or give hello a monomorphic type signature, such as

 hello :: IO [Int]

Tom

___
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] MongoDB single insertions super slow

2013-08-18 Thread Carter Schonwald
Have you contacted the maintainer? I believe that the Haskell mongodb
driver is maintained by someone at 10gen? (Or at least at some point was )

Without spending time looking at the mongo driver, it's hard to know.
On Aug 18, 2013 3:58 PM, Kyle Hanson hanoo...@gmail.com wrote:

 I am trying to write a simple benchmark of testing 1000 single inserts in
 mongodb, but doing single insertions is super slow. It takes nearly 40
 seconds to perform these operations with the haskell mongodb driver, but
 under a second to perform the same number of operations of single inserts
 in python.

 Here are the two files I am working with:

 https://gist.github.com/hansonkd/6263648

 I checked the BSON serialization, and writing it to a socket instead of
 mongodb driver, makes the script run in under a second so the problem seems
 to be with the mongodb driver.

 Any insights would be appreciated.

 --
 Kyle Hanson


 ___
 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] Database.postgreSQL.Simple - ambigious type

2013-08-18 Thread Tom Ellis
On Sun, Aug 18, 2013 at 10:16:06PM +0200, Hartmut Pfarr wrote:
 I played a bit with your suggestion, and it is running now :-)
 But instead of  IO [Int]  I think we need  IO [Only Int]   because
 of the 1-element-tupel problem?

Yes you're right.  I had forgotten that postgresql-simple dealt with
single-column tables with Only.  Well done for getting it working!

Tom

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


Re: [Haskell-cafe] abs minBound (0 :: Int) negate minBound == (minBound :: Int)

2013-08-18 Thread Richard A. O'Keefe

On 19/08/2013, at 3:38 AM, Nicolas Frisby wrote:

 The docs at
 
   
 http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:gcd
 
 give a NB mentioning that (abs minBound == minBound) is possible for 
 fixed-width types.

At least three ways to represent negative integers in binary have been used:
- twos-complement   (asymmetric, -INT_MIN == INT_MIN, abs can have a negative 
result)
- ones-complement(symmetric, -INT_MIN == INT_MAX, abs is always 
non-negative)
- sign-and-magnitude (symmetric, -INT_MIN == INT_MAX, abs is always 
non-negative)

Having used a B6700 as an undergraduate, I still think sign-and-magnitude is the
only really safe-and-simple scheme.  However, twos-complement has conquered.

The argument for twos-complement, which always puzzled me, is that the other
systems have two ways to represent zero.  I never found this to be a problem,
not even for bitwise operations, on the B6700.  I *did* find abs x  0
succeeding to be a pain in the posterior.  (The B6700 had two different tests:
'are these two numbers equal' and 'are these two bit patterns equal'.)

 Two questions:
 
   1) This behavior surprised me. Does it surprise enough people to include a 
 warning in the Haddock for abs and negate?

We cannot expect everyone who uses Haskell to be familiar with
the eccentricities of popular hardware.  I think it's worth mentioning.

   2) Is this a common behavior in other languages?

Yes.

 My tinkering with gcc suggests it does not support the value -2^63, but 
 instead bottoms out at (-2^63+1).

Your tinkering was insufficient.

f% cat 2c.c
#include stdio.h
#include limits.h

int main(void) {
printf(%d\n, INT_MIN + INT_MAX);
return 0;
}
f% gcc 2c.c
f% a.out
-1

Oh wait.  You said 63, not 31.

Change the key line to

printf(%lld\n, LLONG_MIN + LLONG_MAX);

LLONG_MIN is going to be -(2**63) on any SPARC, x86, x86-64,
Power(PC), Alpha, ARM, MIPS, or z/Series machine, and a host
of others.

 
 Thanks.
 ___
 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