[Haskell-cafe] (no subject)

2011-06-13 Thread Fernando Henrique Sanches
http://maipenarai.com/lindex02.html

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


Re: [Haskell-cafe] Input and output of mathematical expressions

2011-06-13 Thread Pedro Vasconcelos
On Thu, 9 Jun 2011 16:23:20 +0200
Jacek Generowicz jacek.generow...@cern.ch wrote:

 Greetings Cafe,
 
 What would you recommend as a Haskell-based means of interactively  
 reading and writing mathematical formulae?
 
 As a toy example, what might I use to write a program which presents  
 the user with
 
  Please simplify the expression: \pi x^2 + 3\pi x^2
 
 (Where the TeX-style expression would be presented with a greek pi
 and superscript twos on the xs.)
 
 The user should then have the ability to reply with something that  
 looks like the result of TeXing
 
  5 \pi x^2
 
 Whatever means the user uses to enter this expression, he should be  
 able to preview the typeset version of his input before submitting.
 
 Any ideas?
 
 Thanks.
 


Regarding the rendering math formulas on web browsers: you might want to
have a look at MathJax (http://www.mathjax.org/). You can use LaTeX or
MathML and will work in most browsers (even if when they don't natively
support MathML).

Pedro

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


[Haskell-cafe] YesodAuth documentation

2011-06-13 Thread Никита Тимофеев
Does exist some simple examples using yesod authentication except code of
Haskellers site? Does exist some examples using YesodAuthEmail?

For example, can i use third-party mail server instead of Sendmail for
YesodAuthEmail? Can i disable registration confirmation? Does passwords
stored in a database in an unencrypted form?

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


Re: [Haskell-cafe] (no subject)

2011-06-13 Thread Fernando Henrique Sanches
I'm sorry, somehow my e-mail account got kidnapped. The link is a virus and
should NOT be opened. I apologise for any inconvenience.

Fernando Henrique Sanches


2011/6/13 Fernando Henrique Sanches fernandohsanc...@gmail.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] Input and output of mathematical expressions

2011-06-13 Thread Jerzy Karczmarczuk

Pedro Vasconcelos comments:

Regarding the rendering math formulas on web browsers: you might want to
have a look at MathJax (http://www.mathjax.org/). You can use LaTeX or
MathML and will work in most browsers (even if when they don't natively
support MathML).

Don't forget two other (which I have been using for years)

LaTeXMathML : http://math.etsu.edu/LaTeXMathML/
jsMath : http://www.math.union.edu/~dpvc/jsMath/

The first needs MathML, obviously, but I won't use browser which ignores 
it... Thios is one script, fairly readable. The second one is much 
bigger. Used by Planet Math, integrated into Drupal, etc.
I confess I tried to write something which displayed math fromHaskell, I 
gave even a project of that kind to my student. But the solutions exist 
already and are known, so...


See e.g.
http://www.twingly.com/haskell/stories/4013ffd773e942fdb4b9cf2cb7c0089e


Jerzy Karczmarczuk




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


[Haskell-cafe] YesodAuth documentation

2011-06-13 Thread Тимофеев Никита Дмитриевич
Does exist some simple examples using yesod authentication except code 
of Haskellers site? Does exist some examples using YesodAuthEmail?

For example, can i use third-party mail server instead of Sendmail for 
YesodAuthEmail? Can i disable registration confirmation? Does passwords 
stored in a database in an unencrypted form?

--
Timofeev N.D.

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


Re: [Haskell-cafe] [Haskell] ANNOUNCE: Parallel and Concurrent programming in Haskell, a tutorial

2011-06-13 Thread Henning Thielemann


On Thu, 19 May 2011, Simon Marlow wrote:

I've put together a tutorial on Parallel and Concurrent programming in 
Haskell, here:


 http://community.haskell.org/~simonmar/par-tutorial.pdf

The main reason for writing this was that I needed some lecture notes for a 
course at the CEFP summer school next month, but I hope the material is 
useful to the Haskell community in general.


Thank you a lot for this overview!

Concerning the parallelisation of K-means: It seems to be difficult to 
choose a size for the pieces of points. Since the 'combine' function is 
associative something map-reduce-like seems to be applicable. That is, if 
there is a library function for a parallelised 'reduce' and I promise, 
that I call it with an associative function as argument, then the library 
could choose an appropriate size for the pieces. Is there already library 
support for parallelism of this style?


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


Re: [Haskell-cafe] YesodAuth documentation

2011-06-13 Thread Michael Steele
Does exist some simple examples using yesod authentication except code of
Haskellers site? Does exist some examples using YesodAuthEmail?

Another example is Orangeroster [1].

For example, can i use  third-party mail server instead of Sendmail for
YesodAuthEmail?

No. Email handling is done through the mime-mail package, which uses
sendmail to do it's work.

Can i disable registration confirmation? Does passwords stored in a
database in an unencrypted form?

The stock email plugin does not let you disable these features, but it
should be easy to write your own.

[1] : http://github.com/snoyberg/orangeroster
2011/6/13 Тимофеев Никита Дмитриевич ndtimof...@gmail.com

 Does exist some simple examples using yesod authentication except code
 of Haskellers site? Does exist some examples using YesodAuthEmail?

 For example, can i use third-party mail server instead of Sendmail for
 YesodAuthEmail? Can i disable registration confirmation? Does passwords
 stored in a database in an unencrypted form?

 --
 Timofeev N.D.

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




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


[Haskell-cafe] GHC handles badly with math formulas

2011-06-13 Thread Grigory Sarnitskiy
I've noted several times that GHC doesn't evaluate formulas for Double values 
during compilation.

That is using
4.2326514735445615 instead of (512 / 0.844)**(1/3)
or
0.906179845938664 instead of (1/3) * sqrt(5 + 2 * sqrt(10 / 7))

This can lead to significant slowdown if such values are called often. It's not 
always convenient to use where or let to reduce the number of calculations of 
such constants so I wonder how to force GHC to evaluate them during compilation?

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


Re: [Haskell-cafe] [Haskell] ANNOUNCE: Parallel and Concurrent programming in Haskell, a tutorial

2011-06-13 Thread Simon Marlow

On 13/06/2011 15:23, Henning Thielemann wrote:


On Thu, 19 May 2011, Simon Marlow wrote:


I've put together a tutorial on Parallel and Concurrent programming in
Haskell, here:

http://community.haskell.org/~simonmar/par-tutorial.pdf

The main reason for writing this was that I needed some lecture notes
for a course at the CEFP summer school next month, but I hope the
material is useful to the Haskell community in general.


Thank you a lot for this overview!

Concerning the parallelisation of K-means: It seems to be difficult to
choose a size for the pieces of points.


In practice it's not too sensitive - as long as the value is much larger 
than the number of cores, but less than the spark pool size (4096), you 
should be ok.



Since the 'combine' function is
associative something map-reduce-like seems to be applicable. That is,
if there is a library function for a parallelised 'reduce' and I
promise, that I call it with an associative function as argument, then
the library could choose an appropriate size for the pieces. Is there
already library support for parallelism of this style?


Not really, but there ought to be.  Various people have looked at this 
problem, but not much in Haskell (look at Lazy Tree Splitting for 
example).  In practice you usually want to add a cut-off point to the 
tree below which you stop trying to parallelise.


Cheers,
Simon

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


Re: [Haskell-cafe] GHC handles badly with math formulas

2011-06-13 Thread Daniel Fischer
On Monday 13 June 2011, 17:46:23, Grigory Sarnitskiy wrote:
 I've noted several times that GHC doesn't evaluate formulas for Double
 values during compilation.
 
 That is using
 4.2326514735445615 instead of (512 / 0.844)**(1/3)
 or
 0.906179845938664 instead of (1/3) * sqrt(5 + 2 * sqrt(10 / 7))
 
 This can lead to significant slowdown if such values are called often.
 It's not always convenient to use where or let to reduce the number of
 calculations of such constants so I wonder how to force GHC to evaluate
 them during compilation?

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

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


Re: [Haskell-cafe] GHC handles badly with math formulas

2011-06-13 Thread Chris Smith
On Mon, 2011-06-13 at 19:46 +0400, Grigory Sarnitskiy wrote:
 I've noted several times that GHC doesn't evaluate formulas for Double values 
 during compilation.
 
 That is using
 4.2326514735445615 instead of (512 / 0.844)**(1/3)
 or
 0.906179845938664 instead of (1/3) * sqrt(5 + 2 * sqrt(10 / 7))

Yep, looks that way.  It's the square roots and powers that GHC is not
applying.  Where you've got divisions between constants, those are
getting applied at compile time.

 This can lead to significant slowdown if such values are called often.

If you assign them to a global name, then lazy evaluation will take care
of it.  It looks like GHC is even throwing in a specialization for
Double when I give the global name a polymorphic type.

-- 
Chris Smith



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


Re: [Haskell-cafe] question about interruptable state runner

2011-06-13 Thread Mario Blažević

On 11-06-09 04:14 PM, Alexander V Vershilov wrote:

Hello.

I'm writing a small tcp server with that can handle connections and
answer by rules writen in a small script that can be interpreted by server.
For this purpose I've written an interpreter that has type

   ErrorT MyError (StateT ScriptState IO)

so I can call native IO function in that script, and define new one.
   I can run this script with runState (runErrorT (...)) oldState.

But there is one problem: in script i should be able to call functions that
will stop script interpretation and wait for some server event. To continue
interpretation.

Can smb give an advice what is the best way to do it?



	It appears you've already settled on operational, and that's a good 
choice. I just wanted to point out the monad-coroutine as a possible 
alternative. The two packages have lots of similarities, the main 
difference appears to be in the way the monad suspension is seen: Prompt 
vs. Functor.


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


Re: [Haskell-cafe] Unexpected type error

2011-06-13 Thread Alexander Solla
On Sun, Jun 12, 2011 at 7:12 PM, Antoine Latter aslat...@gmail.com wrote:

 Types from differing versions of the same module are specifically not
 compatible - even if they are defined identically (in this case they
 are different, though).

 You can do one of two things:

 1. Edit the package description of the package that wants the older
 version of parsec to allow to use the new one. Also, it helps to
 slightly bump the version number of the package when you do this.

 2. Use the older version of parsec in your software. You already have
 it installed (or else the package you want to use wouldn't be able to
 load!). If you're using ghci you can start it with the option
 '-package parsec-2.1.0.1'.


I understand that types from different versions of a module are
incompatible.  What I don't understand is why one module is using a new
version of Parsec when it is constrained to use the old one (I control
both modules.  Their package descriptions contain the same line).  Is this a
cabal-dev bug?

I'll try the -package parsec-2.1.0.1 tip, but this is /not/ a long term
solution to my problem.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Unexpected type error

2011-06-13 Thread Antoine Latter
On Mon, Jun 13, 2011 at 12:34 PM, Alexander Solla alex.so...@gmail.com wrote:


 On Sun, Jun 12, 2011 at 7:12 PM, Antoine Latter aslat...@gmail.com wrote:

 Types from differing versions of the same module are specifically not
 compatible - even if they are defined identically (in this case they
 are different, though).

 You can do one of two things:

 1. Edit the package description of the package that wants the older
 version of parsec to allow to use the new one. Also, it helps to
 slightly bump the version number of the package when you do this.

 2. Use the older version of parsec in your software. You already have
 it installed (or else the package you want to use wouldn't be able to
 load!). If you're using ghci you can start it with the option
 '-package parsec-2.1.0.1'.

 I understand that types from different versions of a module are
 incompatible.  What I don't understand is why one module is using a new
 version of Parsec when it is constrained to use the old one (I control
 both modules.  Their package descriptions contain the same line).  Is this a
 cabal-dev bug?
 I'll try the -package parsec-2.1.0.1 tip, but this is /not/ a long term
 solution to my problem.

I think I might be mus-understanding your problem.

Which module is producing the error message? In which package? How are
you compiling this module? What should be constraining it to the older
version of parsec?

I'd been assuming that you were getting this message from compiling
your own modules by hand, or in GHCi.

Take care,
Antoine

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


Re: [Haskell-cafe] Unexpected type error

2011-06-13 Thread Alexander Solla
On Mon, Jun 13, 2011 at 10:45 AM, Antoine Latter aslat...@gmail.com wrote:

 On Mon, Jun 13, 2011 at 12:34 PM, Alexander Solla alex.so...@gmail.com
 wrote:
 
 
  On Sun, Jun 12, 2011 at 7:12 PM, Antoine Latter aslat...@gmail.com
 wrote:
 
  Types from differing versions of the same module are specifically not
  compatible - even if they are defined identically (in this case they
  are different, though).
 
  You can do one of two things:
 
  1. Edit the package description of the package that wants the older
  version of parsec to allow to use the new one. Also, it helps to
  slightly bump the version number of the package when you do this.
 
  2. Use the older version of parsec in your software. You already have
  it installed (or else the package you want to use wouldn't be able to
  load!). If you're using ghci you can start it with the option
  '-package parsec-2.1.0.1'.
 
  I understand that types from different versions of a module are
  incompatible.  What I don't understand is why one module is using a new
  version of Parsec when it is constrained to use the old one (I control
  both modules.  Their package descriptions contain the same line).  Is
 this a
  cabal-dev bug?
  I'll try the -package parsec-2.1.0.1 tip, but this is /not/ a long term
  solution to my problem.

 I think I might be mus-understanding your problem.

 Which module is producing the error message? In which package? How are
 you compiling this module? What should be constraining it to the older
 version of parsec?

 I'd been assuming that you were getting this message from compiling
 your own modules by hand, or in GHCi.


I am working on Lime, an unreleased module.  It depends on Lime-Utility,
which is also under my control.  Lime's package description contains the
Build-Depends constraints (among many others):

Lime-Utility  =0.1   0.2
parsec =2.1  2.2

Lime-Utility's package description contains the Build-depends constraint:

parsec =2.1  2.2

I am using cabal-dev to maintain a package database in my Lime.Blah working
directory.  I get a compilation failure (based on mismatched types, based on
different versions of Parsec) when I use:

$ cabal-dev ghci
 :cd src
 :l Lime.Data.IPAddress

Interestingly, if I do:

$ cabal-dev clean  cabal-dev configure  cabal-dev clean

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


[Haskell-cafe] Profiling with Data.PQueue.Min

2011-06-13 Thread blackcat
I'm having trouble with getting a profiling version of Data.PQueue.Min. 
I've set the profiling options in ~/.cabal/config and used it to build 
profiling versions of other packages.  When I run cabal install 
--reinstall pqueue, it runs successfully and properly installs the 
package...but it isn't building a profiling version.


Has anyone else gotten this to work?  I'd appreciate some pointers.

thanks
Lee Short


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


Re: [Haskell-cafe] YesodAuth documentation

2011-06-13 Thread Michael Snoyman
2011/6/13 Michael Steele mikesteel...@gmail.com:
Does exist some simple examples using yesod authentication except code of
 Haskellers site? Does exist some examples using YesodAuthEmail?

 Another example is Orangeroster [1].

For example, can i use  third-party mail server instead of Sendmail for
 YesodAuthEmail?

 No. Email handling is done through the mime-mail package, which uses
 sendmail to do it's work.

Actually, that's not entirely accurate. The Yesod scaffolding tool
generates a site that uses mime-mail and sendmail, but there's nothing
inherent in yesod-auth requiring either. Additionally, mime-mail
includes a function to use the sendmail executable, but it can also be
used with other packages, such as Haskellnet. I think we should move
in the direction of making these integrations better. In fact, next
time I need to set up a project that sends email, I'll likely be doing
just that.

Can i disable registration confirmation? Does passwords stored in a
 database in an unencrypted form?

 The stock email plugin does not let you disable these features, but it
 should be easy to write your own.

You could just copy the email module from yesod-auth and make the
modifications there. Or even better if you're so inclined: submit a
patch to make these features optional. If you are so inclined, feel
free to contact me for some guidance.

Michael


 [1] : http://github.com/snoyberg/orangeroster
 2011/6/13 Тимофеев Никита Дмитриевич ndtimof...@gmail.com

 Does exist some simple examples using yesod authentication except code
 of Haskellers site? Does exist some examples using YesodAuthEmail?

 For example, can i use third-party mail server instead of Sendmail for
 YesodAuthEmail? Can i disable registration confirmation? Does passwords
 stored in a database in an unencrypted form?

 --
 Timofeev N.D.

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



 --
 -- Michael Steele

 ___
 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] Unexpected type error

2011-06-13 Thread Antoine Latter
On Mon, Jun 13, 2011 at 1:00 PM, Alexander Solla alex.so...@gmail.com wrote:


 On Mon, Jun 13, 2011 at 10:45 AM, Antoine Latter aslat...@gmail.com wrote:

 On Mon, Jun 13, 2011 at 12:34 PM, Alexander Solla alex.so...@gmail.com
 wrote:
 
 
  On Sun, Jun 12, 2011 at 7:12 PM, Antoine Latter aslat...@gmail.com
  wrote:
 
  Types from differing versions of the same module are specifically not
  compatible - even if they are defined identically (in this case they
  are different, though).
 
  You can do one of two things:
 
  1. Edit the package description of the package that wants the older
  version of parsec to allow to use the new one. Also, it helps to
  slightly bump the version number of the package when you do this.
 
  2. Use the older version of parsec in your software. You already have
  it installed (or else the package you want to use wouldn't be able to
  load!). If you're using ghci you can start it with the option
  '-package parsec-2.1.0.1'.
 
  I understand that types from different versions of a module are
  incompatible.  What I don't understand is why one module is using a new
  version of Parsec when it is constrained to use the old one (I control
  both modules.  Their package descriptions contain the same line).  Is
  this a
  cabal-dev bug?
  I'll try the -package parsec-2.1.0.1 tip, but this is /not/ a long
  term
  solution to my problem.

 I think I might be mus-understanding your problem.

 Which module is producing the error message? In which package? How are
 you compiling this module? What should be constraining it to the older
 version of parsec?

 I'd been assuming that you were getting this message from compiling
 your own modules by hand, or in GHCi.

 I am working on Lime, an unreleased module.  It depends on Lime-Utility,
 which is also under my control.  Lime's package description contains the
 Build-Depends constraints (among many others):
 Lime-Utility  =0.1   0.2
 parsec         =2.1  2.2
 Lime-Utility's package description contains the Build-depends constraint:
 parsec         =2.1  2.2

 I am using cabal-dev to maintain a package database in my Lime.Blah working
 directory.  I get a compilation failure (based on mismatched types, based on
 different versions of Parsec) when I use:
 $ cabal-dev ghci
 :cd src
 :l Lime.Data.IPAddress
 Interestingly, if I do:
 $ cabal-dev clean  cabal-dev configure  cabal-dev clean
 Lime.Data.IPAddress compiles.

The command 'cabal-dev ghci' does not use the cabal package
description to figure out which dependencies to pull in - if the
module you're loading asks for module 'A.B' it loads the most recent
version found in the local cabal-devel packages database - even if
that same module, when compiled with cabal, would pull in a different
package.

In your case I'm guessing that something you do later on with
cabal-dev pulls in a package which requires parsec-3, which then
causes ghci to pull in parsec-3 as its newest version.

Getting a proper 'cabal ghci' that passes command-line flags to ghci
(along the lines of the -package parameter I gave you above) is
something that the cabal folks know people are interested in, but it
isn't something we have today.

Does that make sense?

Antoine

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


Re: [Haskell-cafe] [Vendettaproject]

2011-06-13 Thread Fernando Henrique Sanches
I'm sorry, somehow my e-mail account got kidnapped. The link is a virus and
should NOT be opened. I apologise for any inconvenience.

Peço desculpas, de alguma forma minha conta de e-mail foi invadida. O link é
um vírus e NÃO deve ser aberto. Peço desculpas por qualquer transtorno.
Fernando Henrique Sanches


Em 13 de junho de 2011 04:32, Fernando Henrique Sanches 
fernandohsanc...@gmail.com escreveu:



 --
 Você está recebendo esta mensagem porque se inscreveu no grupo Vendetta
 Project dos Grupos do Google.
 Para postar neste grupo, envie um e-mail para
 fire-kitsune-anime-et-al-c...@googlegroups.com.
 Para cancelar a inscrição nesse grupo, envie um e-mail para
 fire-kitsune-anime-et-al-club+unsubscr...@googlegroups.com.
 Para obter mais opções, visite esse grupo em
 http://groups.google.com/group/fire-kitsune-anime-et-al-club?hl=pt-BR.


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


Re: [Haskell-cafe] Haskell-Cafe Digest, Vol 93, Issue 58

2011-06-13 Thread Albert Y. C. Lai

On 11-06-08 11:17 PM, Gregory Guthrie wrote:

So the implication of the rules:
   1) all IO must start from the top level, and there is only one IO
   2) you cannot extract anything from an IO

Seems to be that the whole program structure becomes a series of do... blocks, 
which is basically a sequential imperative looking style.
The general advice of Strive to keep as much of the program pure as possible 
thus seems difficult.


Suppose you teach Java or C++ or any OOP, and you give out this basic 
homework to beginners: write a program to take two complex numbers from 
the user, then print their sum. You are assured to receive such flawed 
design:


class complex {
  double r, i;
public:
  complex() {
cout  please enter the real part:;
cin  r;
cout  please enter the imaginary part:;
cin  i;
  }
}

The urge to do I/O at all the wrong places is a born instinct. Humanity 
strives to organize programs (and articles) by stream of consciousness 
rather than by separation of concerns. Why do they ask the user in the 
constructor? Because that's where the editor cursor was when they 
remembered to ask the user. Similarly in Haskell, why do they read input 
in the data processing function? Because that's where the editor cursor 
was when they remembered to read input. This is universal to FP, OOP, 
IP, any P, with or without language restrictions.


For people who organize programs by stream of consciousness, Haskell's 
separation of IO does not help, but SML's and C++'s non-separation does 
not help either. Nothing helps. Don't worry about them.


For people who organize programs by separation of concerns, such as you 
and me: Haskell's separation of IO helps. This is what matters.


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


Re: [Haskell-cafe] Haskell-Cafe Digest, Vol 93, Issue 58

2011-06-13 Thread M.C.A. (Marco) Devillers
 The urge to do I/O at all the wrong places is a born instinct.


The original poster was well aware how to factor out IO out of his program,
as made apparent by his initial comment: An option I suppose would be to
read the dictionary at the top level, and then pass it all the way down to
the analysis routine that uses it, but that exposes the details of how the
analysis is done, and couples the top and bottom levels of the previously
modular functions.

His original argument was a genuine observation that IO sometimes seems to
be adverse to the loose coupling of modules. Dissing that argument away as:
you are doing IO at the wrong place, doesn't convince me the least.

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


[Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-13 Thread michael rice
Is there an (existing) way to select 5 Ints randomly (no duplicates) from a 
population, say 1-20 (inclusive)?
Michael___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell-Cafe Digest, Vol 93, Issue 58

2011-06-13 Thread Alexander Solla
On Mon, Jun 13, 2011 at 4:45 PM, M.C.A. (Marco) Devillers 
marco.devill...@gmail.com wrote:


 The urge to do I/O at all the wrong places is a born instinct.


 The original poster was well aware how to factor out IO out of his program,
 as made apparent by his initial comment: An option I suppose would be to
 read the dictionary at the top level, and then pass it all the way down to
 the analysis routine that uses it, but that exposes the details of how the
 analysis is done, and couples the top and bottom levels of the previously
 modular functions.

 His original argument was a genuine observation that IO sometimes seems to
 be adverse to the loose coupling of modules. Dissing that argument away as:
 you are doing IO at the wrong place, doesn't convince me the least.


There are ways to decouple IO from pure code.  I often have a Main
datatype which constructs a pure context (based on command line arguments,
files and their contents, etc) which is then interpreted by pure code.  In
other words, this is a pure control structure, which is computed by IO
(sometimes in an applicative style, sometimes in a monadic one), and then
passed into the pure world for processing.  This can be as tightly or
loosely coupled as we like, assuming we understand that if a value is even
partially based on the results of an IO computation, then IO is going to
drive the computation of that value.  There's no way around that.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-13 Thread Alexander Solla
On Mon, Jun 13, 2011 at 4:56 PM, michael rice nowg...@yahoo.com wrote:

 Is there an (existing) way to select 5 Ints randomly (no duplicates) from a
 population, say 1-20 (inclusive)?

 Michael


This is as close as I have gotten, but it is only probabilistically true.

take_n_unique_randoms_in_range :: ( Ord random
  , Random random
  , MonadIO io
  ) = Int - (random, random) - io
[random]
take_n_unique_randoms_in_range n (a,b) = liftM ((take n) . nub) .
(replicateM (3*n)) . liftIO $ randomRIO (a,b)

I'm going to put making an iteratee-based solution on my agenda.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-13 Thread Arlen Christian Mart Cuss
On Mon, 2011-06-13 at 16:56 -0700, michael rice wrote:
 Is there an (existing) way to select 5 Ints randomly (no duplicates)
 from a population, say 1-20 (inclusive)?
 


Does anything from random-extras look like it'll work?
http://hackage.haskell.org/packages/archive/random-extras/0.17/doc/html/Data-Random-Extras.html

Shuffle [1..20], then take 5?


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


Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-13 Thread Felipe Almeida Lessa
On Mon, Jun 13, 2011 at 8:56 PM, michael rice nowg...@yahoo.com wrote:
 Is there an (existing) way to select 5 Ints randomly (no duplicates) from a 
 population, say 1-20 (inclusive)?

Yes, already implemented in the monte-carlo package as sampleSubset [1],

  sampleSubset :: MonadMC m = [a] - Int - m [a]

Complete example code for your example:

  evalMC (sampleSubset [1..20] 5) (mt19937 0)

Cheers!

[1] 
http://hackage.haskell.org/packages/archive/monte-carlo/0.4.1/doc/html/Control-Monad-MC-Class.html#v:sampleSubset

--
Felipe.

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


Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-13 Thread michael rice
Thanks, all.
It seemed like something like this should exist in a prob/stat package, and if 
so, didn't want to reinvent the wheel.
Shuffle [1..20], then take 5?
Yes, so simple, I'm embarrassed I didn't think of it.
Michael


--- On Mon, 6/13/11, Felipe Almeida Lessa felipe.le...@gmail.com wrote:

From: Felipe Almeida Lessa felipe.le...@gmail.com
Subject: Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o 
dups) from a range of Ints
To: michael rice nowg...@yahoo.com
Cc: haskell-cafe@haskell.org
Date: Monday, June 13, 2011, 9:38 PM

On Mon, Jun 13, 2011 at 8:56 PM, michael rice nowg...@yahoo.com wrote:
 Is there an (existing) way to select 5 Ints randomly (no duplicates) from a 
 population, say 1-20 (inclusive)?

Yes, already implemented in the monte-carlo package as sampleSubset [1],

  sampleSubset :: MonadMC m = [a] - Int - m [a]

Complete example code for your example:

  evalMC (sampleSubset [1..20] 5) (mt19937 0)

Cheers!

[1] 
http://hackage.haskell.org/packages/archive/monte-carlo/0.4.1/doc/html/Control-Monad-MC-Class.html#v:sampleSubset

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


Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-13 Thread michael rice
Reason why this doesn't work?
Michael
==
[michael@sabal ~]$ cabal install monte-carloResolving 
dependencies...Downloading primitive-0.3.1...Configuring 
primitive-0.3.1...Preprocessing library primitive-0.3.1...Building 
primitive-0.3.1...[1 of 7] Compiling Data.Primitive.MachDeps ( 
Data/Primitive/MachDeps.hs, dist/build/Data/Primitive/MachDeps.o )[2 of 7] 
Compiling Control.Monad.Primitive ( Control/Monad/Primitive.hs, 
dist/build/Control/Monad/Primitive.o )
Control/Monad/Primitive.hs:24:1:    Warning: Module `GHC.IOBase' is deprecated: 
use GHC.IO instead[3 of 7] Compiling Data.Primitive.Types ( 
Data/Primitive/Types.hs, dist/build/Data/Primitive/Types.o )
Data/Primitive/Types.hs:39:30:    Warning: In the use of `mkNorepType'          
   (imported from Data.Data):             Deprecated: Use mkNoRepType 
instead[4 of 7] Compiling Data.Primitive.Array ( Data/Primitive/Array.hs, 
dist/build/Data/Primitive/Array.o )
Data/Primitive/Array.hs:27:30:    Warning: In the use of `mkNorepType'          
   (imported from Data.Data):             Deprecated: Use mkNoRepType 
instead[5 of 7] Compiling Data.Primitive.ByteArray ( 
Data/Primitive/ByteArray.hs, dist/build/Data/Primitive/ByteArray.o )
Data/Primitive/ByteArray.hs:36:30:    Warning: In the use of `mkNorepType'      
       (imported from Data.Data):             Deprecated: Use mkNoRepType 
instead[6 of 7] Compiling Data.Primitive.Addr ( Data/Primitive/Addr.hs, 
dist/build/Data/Primitive/Addr.o )[7 of 7] Compiling Data.Primitive   ( 
Data/Primitive.hs, dist/build/Data/Primitive.o )Registering 
primitive-0.3.1...Installing library in 
/home/michael/.cabal/lib/primitive-0.3.1/ghc-7.0.2Registering 
primitive-0.3.1...Downloading vector-0.7.0.1...Configuring 
vector-0.7.0.1...Preprocessing library vector-0.7.0.1...Building 
vector-0.7.0.1...[ 1 of 19] Compiling Data.Vector.Storable.Internal ( 
Data/Vector/Storable/Internal.hs, dist/build/Data/Vector/Storable/Internal.o )[ 
2 of 19] Compiling Data.Vector.Fusion.Util ( Data/Vector/Fusion/Util.hs, 
dist/build/Data/Vector/Fusion/Util.o )[ 3 of 19] Compiling 
Data.Vector.Fusion.Stream.Size ( Data/Vector/Fusion/Stream/Size.hs,
 dist/build/Data/Vector/Fusion/Stream/Size.o )
Data/Vector/Fusion/Stream/Size.hs:25:10:    Warning: No explicit method nor 
default method for `*'    In the instance declaration for `Num Size'
Data/Vector/Fusion/Stream/Size.hs:25:10:    Warning: No explicit method nor 
default method for `abs'    In the instance declaration for `Num Size'
Data/Vector/Fusion/Stream/Size.hs:25:10:    Warning: No explicit method nor 
default method for `signum'    In the instance declaration for `Num Size'[ 4 of 
19] Compiling Data.Vector.Internal.Check ( Data/Vector/Internal/Check.hs, 
dist/build/Data/Vector/Internal/Check.o )[ 5 of 19] Compiling 
Data.Vector.Fusion.Stream.Monadic ( Data/Vector/Fusion/Stream/Monadic.hs, 
dist/build/Data/Vector/Fusion/Stream/Monadic.o )Loading package ghc-prim ... 
linking ... done.Loading package integer-gmp ... linking ... done.Loading 
package base ... linking ... done.Loading package primitive-0.3.1 ... linking 
... done.[ 6 of 19] Compiling Data.Vector.Fusion.Stream ( 
Data/Vector/Fusion/Stream.hs, dist/build/Data/Vector/Fusion/Stream.o )[ 7 of 
19] Compiling Data.Vector.Generic.Mutable ( Data/Vector/Generic/Mutable.hs, 
dist/build/Data/Vector/Generic/Mutable.o )[ 8 of 19] Compiling 
Data.Vector.Generic.Base ( Data/Vector/Generic/Base.hs, 
dist/build/Data/Vector/Generic/Base.o
 )[ 9 of 19] Compiling Data.Vector.Generic.New ( Data/Vector/Generic/New.hs, 
dist/build/Data/Vector/Generic/New.o )[10 of 19] Compiling Data.Vector.Generic 
( Data/Vector/Generic.hs, dist/build/Data/Vector/Generic.o )
Data/Vector/Generic.hs:185:36:    Warning: In the use of `mkNorepType'          
   (imported from Data.Data):             Deprecated: Use mkNoRepType 
instead[11 of 19] Compiling Data.Vector.Primitive.Mutable ( 
Data/Vector/Primitive/Mutable.hs, dist/build/Data/Vector/Primitive/Mutable.o 
)[12 of 19] Compiling Data.Vector.Primitive ( Data/Vector/Primitive.hs, 
dist/build/Data/Vector/Primitive.o )[13 of 19] Compiling 
Data.Vector.Storable.Mutable ( Data/Vector/Storable/Mutable.hs, 
dist/build/Data/Vector/Storable/Mutable.o )[14 of 19] Compiling 
Data.Vector.Storable ( Data/Vector/Storable.hs, 
dist/build/Data/Vector/Storable.o )[15 of 19] Compiling 
Data.Vector.Unboxed.Base ( Data/Vector/Unboxed/Base.hs, 
dist/build/Data/Vector/Unboxed/Base.o )[16 of 19] Compiling Data.Vector.Unboxed 
( Data/Vector/Unboxed.hs, dist/build/Data/Vector/Unboxed.o )[17 of 19] 
Compiling Data.Vector.Unboxed.Mutable ( Data/Vector/Unboxed/Mutable.hs,
 dist/build/Data/Vector/Unboxed/Mutable.o )[18 of 19] Compiling 
Data.Vector.Mutable ( Data/Vector/Mutable.hs, dist/build/Data/Vector/Mutable.o 
)[19 of 19] Compiling Data.Vector      ( Data/Vector.hs, 
dist/build/Data/Vector.o )Registering vector-0.7.0.1...Installing library in 
/home/michael/.cabal/lib/vector-0.7.0.1/ghc-7.0.2Registering 

Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-13 Thread Felipe Almeida Lessa
On Mon, Jun 13, 2011 at 11:44 PM, michael rice nowg...@yahoo.com wrote:
 Downloading gsl-random-0.4.3...
 [1 of 1] Compiling Main             ( 
 /tmp/gsl-random-0.4.32479/gsl-random-0.4.3/Setup.lhs, 
 /tmp/gsl-random-0.4.32479/gsl-random-0.4.3/dist/setup/Main.o )
 Linking /tmp/gsl-random-0.4.32479/gsl-random-0.4.3/dist/setup/setup ...
 Configuring gsl-random-0.4.3...
 setup: The program gsl-config is required but it could not be found.
 cabal: Error: some packages failed to install:
 gsl-random-0.4.3 failed during the configure step. The exception was:
 ExitFailure 1

You have to install GSL development packages on your system.

Cheers,

--
Felipe.

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


Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-13 Thread michael rice
And then reinstall the monte-carlo?
Michael

--- On Mon, 6/13/11, Felipe Almeida Lessa felipe.le...@gmail.com wrote:

From: Felipe Almeida Lessa felipe.le...@gmail.com
Subject: Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o 
dups) from a range of Ints
To: michael rice nowg...@yahoo.com
Cc: haskell-cafe@haskell.org
Date: Monday, June 13, 2011, 10:45 PM

On Mon, Jun 13, 2011 at 11:44 PM, michael rice nowg...@yahoo.com wrote:
 Downloading gsl-random-0.4.3...
 [1 of 1] Compiling Main             ( 
 /tmp/gsl-random-0.4.32479/gsl-random-0.4.3/Setup.lhs, 
 /tmp/gsl-random-0.4.32479/gsl-random-0.4.3/dist/setup/Main.o )
 Linking /tmp/gsl-random-0.4.32479/gsl-random-0.4.3/dist/setup/setup ...
 Configuring gsl-random-0.4.3...
 setup: The program gsl-config is required but it could not be found.
 cabal: Error: some packages failed to install:
 gsl-random-0.4.3 failed during the configure step. The exception was:
 ExitFailure 1

You have to install GSL development packages on your system.

Cheers,

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


Re: [Haskell-cafe] YesodAuth documentation

2011-06-13 Thread Michael Steele
Actually, that's not entirely accurate. The Yesod scaffolding tool
generates a site that uses mime-mail and sendmail, but there's nothing
inherent in yesod-auth requiring either.

My apologies for adding to the confusion. I see now that
Yesod.Auth.Email handles database interactions, generates
verify URLs for new accounts to use, and provides forms to
embed in HTML. It doesn't actually create email messages or
handle any kind of email delivery.

I saw the mime-mail dependency, and then forgot
where I had seen Network.Mail.Mime.renderSendMail actually
being called.

 The stock email plugin does not let you disable these features, but it
 should be easy to write your own.

You could just copy the email module from yesod-auth and make the
modifications there. Or even better if you're so inclined: submit a
patch to make these features optional. If you are so inclined, feel
free to contact me for some guidance.

My understanding is that none of the plugins included in
yesod-auth are magic in any way. New ones can be created
outside of the official package as long as their associated
AuthPlugin has a Text value unique among any others being
used. Is this all correct?
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe