[Haskell-cafe] Operator precedence

2010-09-06 Thread michael rice
Is there a handy list of operators and their precedence somewhere? Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Operator precedence

2010-09-06 Thread michael rice
, Daniel Díaz lazy.dd...@gmail.com wrote: From: Daniel Díaz lazy.dd...@gmail.com Subject: Re: [Haskell-cafe] Operator precedence To: michael rice nowg...@yahoo.com, haskell-cafe@haskell.org Date: Monday, September 6, 2010, 1:06 PM Take a look to the Haskell Report:   http://www.haskell.org

Re: [Haskell-cafe] Operator precedence

2010-09-06 Thread michael rice
Subject: Re: [Haskell-cafe] Operator precedence To: michael rice nowg...@yahoo.com, haskell-cafe@haskell.org Date: Monday, September 6, 2010, 1:17 PM Those are all operators in Prelude. See a concrete library for their operator precedences. -- Daniel Díaz

Re: [Haskell-cafe] Operator precedence

2010-09-06 Thread michael rice
] Operator precedence To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org, Daniel Díaz lazy.dd...@gmail.com Date: Monday, September 6, 2010, 1:50 PM On Mon, Sep 6, 2010 at 1:37 PM, michael rice nowg...@yahoo.com wrote: A concrete library? I'm playing around with Data.Bits. It has

[Haskell-cafe] On to applicative

2010-09-04 Thread michael rice
The two myAction functions below seem to be equivalent and, for this small case, show an interesting economy of code, but being far from a Haskell expert, I have to ask, is the first function as small (code wise) as it could be? Michael import Control.Applicative data Color     = Red     |

Re: [Haskell-cafe] On to applicative

2010-09-04 Thread michael rice
d...@zednenem.com wrote: From: David Menendez d...@zednenem.com Subject: Re: [Haskell-cafe] On to applicative To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Saturday, September 4, 2010, 2:23 PM On Sat, Sep 4, 2010 at 2:06 PM, michael rice nowg...@yahoo.com wrote: The two

Re: [Haskell-cafe] On to applicative

2010-09-02 Thread michael rice
...@mathematik.uni-marburg.de Subject: Re: [Haskell-cafe] On to applicative To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Wednesday, September 1, 2010, 5:28 PM michael rice wrote: Prelude Data.Either let m = Just 7 Prelude Data.Either :t m m :: Maybe Integer So to create a value

Re: [Haskell-cafe] On to applicative

2010-09-02 Thread michael rice
--- On Tue, 8/31/10, Ryan Ingram ryani.s...@gmail.com wrote: From: Ryan Ingram ryani.s...@gmail.com Subject: Re: [Haskell-cafe] On to applicative To: michael rice nowg...@yahoo.com Cc: Vo Minh Thu not...@gmail.com, haskell-cafe@haskell.org Date: Tuesday, August 31, 2010, 4:17 PM FmapFunc is just a test

Re: [Haskell-cafe] On to applicative

2010-09-02 Thread michael rice
a...@2piix.com wrote: From: Alexander Solla a...@2piix.com Subject: Re: [Haskell-cafe] On to applicative To: Cc: haskell-cafe Cafe haskell-cafe@haskell.org Date: Thursday, September 2, 2010, 2:46 PM On Sep 2, 2010, at 11:30 AM, michael rice wrote: In each case, what does the notation show

[Haskell-cafe] On to applicative

2010-09-02 Thread michael rice
This may be a dumb question, but here goes. Types Maybe, Either, List, are types and also instances of Functor (and Monad). Assuming (-) is also a type, where can I find its type definition? Michael ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] On to applicative

2010-09-02 Thread michael rice
Cool, I'll go looking for it. I couldn't find anything on Hoogle. Thanks, Michael --- On Thu, 9/2/10, David Menendez d...@zednenem.com wrote: From: David Menendez d...@zednenem.com Subject: Re: [Haskell-cafe] On to applicative To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org

Re: [Haskell-cafe] On to applicative

2010-09-01 Thread michael rice
that would require x to have a declared type, or is it always inferred by the type of f? Michael --- On Wed, 9/1/10, Tillmann Rendel ren...@mathematik.uni-marburg.de wrote: From: Tillmann Rendel ren...@mathematik.uni-marburg.de Subject: Re: [Haskell-cafe] On to applicative To: michael rice

[Haskell-cafe] On to applicative

2010-08-31 Thread michael rice
Learn You a Haskell ...  says that (-) is a type just like Either. Where can I find its type definition? Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] On to applicative

2010-08-31 Thread michael rice
So it's a type constructor, not a type? Could you please provide a simple example of its usage? Michael --- On Tue, 8/31/10, Vo Minh Thu not...@gmail.com wrote: From: Vo Minh Thu not...@gmail.com Subject: Re: [Haskell-cafe] On to applicative To: michael rice nowg...@yahoo.com Cc: haskell-cafe

Re: [Haskell-cafe] On to applicative

2010-08-31 Thread michael rice
of (-) so I can apply (-)'s version of fmap instance Functor ((-) r) where      fmap f g = (\x - f (g x)) to it? Michael --- On Tue, 8/31/10, Vo Minh Thu not...@gmail.com wrote: From: Vo Minh Thu not...@gmail.com Subject: Re: [Haskell-cafe] On to applicative To: michael rice nowg...@yahoo.com Cc

Re: [Haskell-cafe] On to applicative

2010-08-31 Thread michael rice
...@gmail.com wrote: From: Ryan Ingram ryani.s...@gmail.com Subject: Re: [Haskell-cafe] On to applicative To: michael rice nowg...@yahoo.com Cc: Vo Minh Thu not...@gmail.com, haskell-cafe@haskell.org Date: Tuesday, August 31, 2010, 2:36 PM Prelude FmapFunc let s = show :: ((-) Int) String Prelude

Re: [Haskell-cafe] On to applicative

2010-08-31 Thread michael rice
Hi Vo, Pardon, I grabbed the wrong lines. *Main :t (-) 3 abc interactive:1:1: parse error on input `-' Michael --- On Tue, 8/31/10, Vo Minh Thu not...@gmail.com wrote: From: Vo Minh Thu not...@gmail.com Subject: Re: [Haskell-cafe] On to applicative To: michael rice nowg...@yahoo.com Cc: Ryan

Re: [Haskell-cafe] On to applicative

2010-08-31 Thread michael rice
: Vo Minh Thu not...@gmail.com Subject: Re: [Haskell-cafe] On to applicative To: michael rice nowg...@yahoo.com Cc: Ryan Ingram ryani.s...@gmail.com, haskell-cafe@haskell.org Date: Tuesday, August 31, 2010, 3:23 PM 2010/8/31 michael rice nowg...@yahoo.com Hi Vo, Pardon, I grabbed the wrong lines

Re: [Haskell-cafe] On to applicative

2010-08-31 Thread michael rice
, 4:35 PM -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 8/31/10 13:27 , michael rice wrote: So it's a type constructor, not a type? Could you please provide a simple example of its usage? Assuming you don't mean the trivial use in defining functions, see Control.Monad.Instances: instance

Re: [Haskell-cafe] On to applicative

2010-08-29 Thread michael rice
: SHA1 On 8/28/10 20:43 , michael rice wrote: I'm looking at a discussion of Either (as functor) here: http://learnyouahaskell.com/making-our-own-types-and-typeclasses#the-functor-typeclass instance Functor (Either a) where       fmap f (Right x) = Right (f x)       fmap f (Left x) = Left x

Re: [Haskell-cafe] On to applicative

2010-08-29 Thread michael rice
, 8/30/10, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: From: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com Subject: Re: [Haskell-cafe] On to applicative To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org, Brandon S Allbery KF8NH allb...@ece.cmu.edu Date: Monday, August 30

[Haskell-cafe] On to applicative

2010-08-28 Thread michael rice
I'm looking at a discussion of Either (as functor) here: http://learnyouahaskell.com/making-our-own-types-and-typeclasses#the-functor-typeclass instance Functor (Either a) where       fmap f (Right x) = Right (f x)       fmap f (Left x) = Left x And this line in Data.Either Functor (Either

Re: [Haskell-cafe] On to applicative

2010-08-28 Thread michael rice
Thanks, Brandon. Michael --- On Sat, 8/28/10, Brandon S Allbery KF8NH allb...@ece.cmu.edu wrote: From: Brandon S Allbery KF8NH allb...@ece.cmu.edu Subject: Re: [Haskell-cafe] On to applicative To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Saturday, August 28, 2010, 10:43

[Haskell-cafe] On to applicative

2010-08-27 Thread michael rice
fmap seems oddly named because no mapping takes place, except in the fourth example, where the map is passed in. Just sayin'. Michael 1) Prelude Control.Monad Control.Applicative fmap (++ abc) getLine xyz xyzabc 2) Prelude Control.Monad Control.Applicative Data.Char Data.String fmap (splitAt

Re: [Haskell-cafe] On to applicative

2010-08-27 Thread michael rice
A map can be a function (applied to a (single) value). Got it. Thanks, Michael --- On Fri, 8/27/10, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: From: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com Subject: Re: [Haskell-cafe] On to applicative To: michael rice nowg...@yahoo.com Cc

Re: [Haskell-cafe] On to applicative

2010-08-26 Thread michael rice
Yeah, I figured as much, but the code is copied right off the referenced page. Michael --- On Thu, 8/26/10, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: From: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com Subject: Re: [Haskell-cafe] On to applicative To: michael rice nowg

Re: [Haskell-cafe] On to applicative

2010-08-26 Thread michael rice
Can you recommend an example that works? Michael --- On Thu, 8/26/10, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: From: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com Subject: Re: [Haskell-cafe] On to applicative To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date

Re: [Haskell-cafe] On to applicative

2010-08-26 Thread michael rice
--- On Thu, 8/26/10, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: From: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com Subject: Re: [Haskell-cafe] On to applicative To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Thursday, August 26, 2010, 2:33 AM On 26 August 2010 16

Re: [Haskell-cafe] On to applicative

2010-08-26 Thread michael rice
: [Haskell-cafe] On to applicative To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Thursday, August 26, 2010, 2:50 AM On 26 August 2010 16:47, michael rice nowg...@yahoo.com wrote: OK, fmap2 works, but not fmap3. What am I not understanding? Michael import

Re: [Haskell-cafe] On to applicative

2010-08-26 Thread michael rice
the patience. Michael --- On Thu, 8/26/10, Thomas Davie tom.da...@gmail.com wrote: From: Thomas Davie tom.da...@gmail.com Subject: Re: [Haskell-cafe] On to applicative To: michael rice nowg...@yahoo.com Cc: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com, haskell-cafe@haskell.org Date: Thursday

Re: [Haskell-cafe] On to applicative

2010-08-26 Thread michael rice
Date: Thursday, August 26, 2010, 4:29 AM On Aug 26, 2010, at 12:34 AM, michael rice wrote: A lot of stuff to get one's head around. Was aware of liftM2, liftM3, etc., but not liftA2, liftA3, etc. liftM and liftA are essentially equivalent (and are both essentially equivalent to fmap

Re: [Haskell-cafe] On to applicative

2010-08-26 Thread michael rice
, 2:15 PM On Aug 26, 2010, at 9:27 AM, michael rice wrote: Some functions just happen to map to other functions. $ is flip fmap.  f $ functor = fmap f functor  Brent Yorgey's post noted. map to? Take as arguments? maps to as in outputs. pure f * functor = f $ functor

[Haskell-cafe] On to applicative

2010-08-25 Thread michael rice
From: http://en.wikibooks.org/wiki/Haskell/Applicative_Functors = import Control.Applicative f :: (a - b - c) fmap :: Functor f = (d - e) - f d - f e fmap f :: Functor f = f a - f (b - c)    -- Identify d with a, and e with (b - c) sumsqr :: Int - Int - Int    -- my

Re: [Haskell-cafe] Unwrapping long lines in text files

2010-08-14 Thread michael rice
--- On Sat, 8/14/10, Felipe Lessa felipe.le...@gmail.com wrote: From: Felipe Lessa felipe.le...@gmail.com Subject: Re: [Haskell-cafe] Unwrapping long lines in text files To: Bill Atkins watk...@alum.rpi.edu Cc: michael rice nowg...@yahoo.com, haskell-cafe@haskell.org Date: Saturday, August 14, 2010

Re: [Haskell-cafe] Unwrapping long lines in text files

2010-08-14 Thread michael rice
Hi Bill, Very clever. You are an inspiration. Michael --- On Sat, 8/14/10, Bill Atkins watk...@alum.rpi.edu wrote: From: Bill Atkins watk...@alum.rpi.edu Subject: Re: [Haskell-cafe] Unwrapping long lines in text files To: michael rice nowg...@yahoo.com Cc: Felipe Lessa felipe.le...@gmail.com

Re: [Haskell-cafe] Unwrapping long lines in text files

2010-08-14 Thread michael rice
rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Saturday, August 14, 2010, 7:07 PM On Sat, Aug 14, 2010 at 2:38 AM, michael rice nowg...@yahoo.com wrote: The program below takes a text file and unwraps all lines to 72 columns, but I'm getting an end of file message at the top of my

Re: [Haskell-cafe] Unwrapping long lines in text files

2010-08-14 Thread michael rice
Nope. No redirection. Michael --- On Sat, 8/14/10, Brandon S Allbery KF8NH allb...@ece.cmu.edu wrote: From: Brandon S Allbery KF8NH allb...@ece.cmu.edu Subject: Re: [Haskell-cafe] Unwrapping long lines in text files To: haskell-cafe@haskell.org Date: Saturday, August 14, 2010, 7:17 PM

[Haskell-cafe] Unwrapping long lines in text files

2010-08-13 Thread michael rice
The program below takes a text file and unwraps all lines to 72 columns, but I'm getting an end of file message at the top of my output. How do I lose the EOF? Michael == unwrap.hs == main = do     line - getLine     if null line     then do    putStrLn   

Re: [Haskell-cafe] Unwrapping long lines in text files

2010-08-13 Thread michael rice
, 8/13/10, Bill Atkins watk...@alum.rpi.edu wrote: From: Bill Atkins watk...@alum.rpi.edu Subject: Re: [Haskell-cafe] Unwrapping long lines in text files To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Friday, August 13, 2010, 11:13 PM Not sure if I understood what you're

[Haskell-cafe] Couple of questions about *let* within *do*

2010-08-10 Thread michael rice
From: Learn You a Haskell === Remember let bindings? If you don't, refresh your memory on them by reading this section. They have to be in the form of let bindings in expression, where bindings are names to be given to expressions and expression is the expression that is to

Re: [Haskell-cafe] Couple of questions about *let* within *do*

2010-08-10 Thread michael rice
= do   gen - getStdGen   let code = genCode gen   putStrLn $ Code is ++ show code   putStrLn ... Michael --- On Tue, 8/10/10, Job Vranish job.vran...@gmail.com wrote: From: Job Vranish job.vran...@gmail.com Subject: Re: [Haskell-cafe] Couple of questions about *let* within *do* To: michael rice

Re: [Haskell-cafe] Couple of questions about *let* within *do*

2010-08-10 Thread michael rice
   s6? Michael --- On Tue, 8/10/10, Tillmann Rendel ren...@mathematik.uni-marburg.de wrote: From: Tillmann Rendel ren...@mathematik.uni-marburg.de Subject: Re: [Haskell-cafe] Couple of questions about *let* within *do* To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date

Re: [Haskell-cafe] Couple of questions about *let* within *do*

2010-08-10 Thread michael rice
So all the Xs would be in scope at s6. Important point. Thanks, Michael --- On Tue, 8/10/10, Alex Stangl a...@stangl.us wrote: From: Alex Stangl a...@stangl.us Subject: Re: [Haskell-cafe] Couple of questions about *let* within *do* To: michael rice nowg...@yahoo.com Cc: Tillmann Rendel ren

[Haskell-cafe] What is -

2010-08-08 Thread michael rice
What is - ? Couldn't find anything on Hoogle. 1)  main = do   x - getLine   -- get the value from the IO monad   putStrLn $ You typed: ++ x 2)  pythags = do   z - [1..] --get the value from the List monad?   x - [1..z]   y - [x..z]   guard (x^2 + y^2 == z^2)  

Re: [Haskell-cafe] What is -

2010-08-08 Thread michael rice
getLine = \x -  -- x is a string at this point [1..] = \x -    -- x is WHAT at this point? MIchael --- On Sun, 8/8/10, Henning Thielemann lemm...@henning-thielemann.de wrote: From: Henning Thielemann lemm...@henning-thielemann.de Subject: Re: [Haskell-cafe] What is - To: michael rice

Re: [Haskell-cafe] What is -

2010-08-08 Thread michael rice
-cafe] What is - To: michael rice nowg...@yahoo.com Date: Sunday, August 8, 2010, 11:01 AM On Sun, 8 Aug 2010, michael rice wrote: How would I print each of these integers, one per line? [1,2,3,4,5] = \x - ? You can't do this from inside the List monad, but you can easily do it from outside

[Haskell-cafe] Constructor question

2010-07-31 Thread michael rice
From: Data.Complex data (RealFloat a) = Complex a = !a :+ !a What's the purpose of the exclamation marks? Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Constructor question

2010-07-31 Thread michael rice
rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Saturday, July 31, 2010, 9:32 AM michael rice nowg...@yahoo.com writes: From: Data.Complex data (RealFloat a) = Complex a    = !a :+ !a What's the purpose of the exclamation marks? Forcing; it means that the values are evaluated (up

Re: [Haskell-cafe] Constructor question

2010-07-31 Thread michael rice
Miljenovic ivan.miljeno...@gmail.com wrote: From: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com Subject: Re: [Haskell-cafe] Constructor question To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Saturday, July 31, 2010, 9:32 AM michael rice nowg...@yahoo.com writes: From

Re: [Haskell-cafe] Constructor question

2010-07-31 Thread michael rice
Ok, got ! and WHNF. Thanks, Michael --- On Sat, 7/31/10, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: From: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com Subject: Re: [Haskell-cafe] Constructor question To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Saturday

[Haskell-cafe] Laziness question

2010-07-31 Thread michael rice
From: http://en.wikibooks.org/wiki/Haskell/Laziness Given two functions of one parameter, f and g, we say f is stricter than g if f x evaluates x to a deeper level than g x Exercises    1. Which is the stricter function? f x = length [head x] g x = length (tail x) Prelude let f x = length

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread michael rice
rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Saturday, July 31, 2010, 12:38 PM On Sat, Jul 31, 2010 at 4:56 PM, michael rice nowg...@yahoo.com wrote: From: http://en.wikibooks.org/wiki/Haskell/Laziness Given two functions of one parameter, f and g, we say f is stricter than g

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread michael rice
question To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Saturday, July 31, 2010, 1:47 PM On Sat, Jul 31, 2010 at 5:59 PM, michael rice nowg...@yahoo.com wrote: OK, in f, *length* already knows it's argument is a list. In g, *length* doesn't know what's inside the parens, extra

Re: [Haskell-cafe] Laziness question

2010-07-31 Thread michael rice
Date: Saturday, July 31, 2010, 2:29 PM -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 7/31/10 14:24 , michael rice wrote: Are you saying: [ head x ]  -  [ *thunk* ]   and   length [ *thunk* ] -  1, independent of what *thunk* is, even head [], i.e., *thunk* never needs be evaluated

[Haskell-cafe] Definition of List type?

2010-07-30 Thread michael rice
From: Data.Maybe Description The Maybe type, and associated operations. From: Data.List Description Operations on lists. One description has the type and associated operations, the other only has the operations. Where can I find the type definition for List, and why isn't it in Data.List?

Re: [Haskell-cafe] Definition of List type?

2010-07-30 Thread michael rice
for defining this stuff, i.e., this goes here, that goes there? Michael --- On Fri, 7/30/10, Edward Z. Yang ezy...@mit.edu wrote: From: Edward Z. Yang ezy...@mit.edu Subject: Re: [Haskell-cafe] Definition of List type? To: michael rice nowg...@yahoo.com, haskell-cafe haskell-cafe@haskell.org Date

Re: [Haskell-cafe] Definition of List type?

2010-07-30 Thread michael rice
, Daniel Fischer daniel.is.fisc...@web.de wrote: From: Daniel Fischer daniel.is.fisc...@web.de Subject: Re: [Haskell-cafe] Definition of List type? To: haskell-cafe@haskell.org Cc: michael rice nowg...@yahoo.com Date: Friday, July 30, 2010, 4:23 PM On Friday 30 July 2010 21:54:20, michael rice wrote

[Haskell-cafe] Need Control.Monad.State

2010-07-27 Thread michael rice
How do I import Control.Monad.State? I see this note in http://en.wikibooks.org/wiki/Haskell/Understanding_monads/State   Note: in some package systems used for GHC, the Control.Monad.State module is in a separate package, usually indicated by MTL (Monad Transformer Library). Michael

Re: [Haskell-cafe] Need Control.Monad.State

2010-07-27 Thread michael rice
To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Tuesday, July 27, 2010, 10:51 PM On 28 July 2010 12:39, michael rice nowg...@yahoo.com wrote: How do I import Control.Monad.State? Install and use the mtl library (comes with the Haskell platform), monads-fd (almost identical API

Re: [Haskell-cafe] Need Control.Monad.State

2010-07-27 Thread michael rice
See below. Lot's of warnings. Is the install OK? If so, can I use the same *import*? Michael --- On Tue, 7/27/10, Ivan Miljenovic ivan.miljeno...@gmail.com wrote: If it isn't installed, you can use cabal-install to install it: cabal install mtl -- Ivan Lazar Miljenovic

Re: [Haskell-cafe] Random this! ;-)

2010-07-26 Thread michael rice
, Lyndon Maydwell maydw...@gmail.com wrote: From: Lyndon Maydwell maydw...@gmail.com Subject: Re: [Haskell-cafe] Random this! ;-) To: michael rice nowg...@yahoo.com Cc: Max Rabkin max.rab...@gmail.com, Ozgur Akgun ozgurak...@gmail.com, haskell-cafe@haskell.org Date: Monday, July 26, 2010, 8:29 AM I find

[Haskell-cafe] Random this! ;-)

2010-07-25 Thread michael rice
Hi All, From: http://en.wikibooks.org/wiki/Haskell/Understanding_monads/State    Exercises    1. Implement a function rollNDiceIO :: Int - IO [Int] that,   given an integer, returns a list with that number of pseudo-   random integers between 1 and 6. After a

Re: [Haskell-cafe] Random this! ;-)

2010-07-25 Thread michael rice
: [Haskell-cafe] Random this! ;-) To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Sunday, July 25, 2010, 11:44 AM On Sun, Jul 25, 2010 at 5:39 PM, michael rice nowg...@yahoo.com wrote: I know, ugly, but at least I got it to work. What's a better way to generate this list

Re: [Haskell-cafe] Random this! ;-)

2010-07-25 Thread michael rice
Cool. Everything's there but the N. Learning Haskell is a lot like learning to dance. Michael --- On Sun, 7/25/10, Ozgur Akgun ozgurak...@gmail.com wrote: From: Ozgur Akgun ozgurak...@gmail.com Subject: Re: [Haskell-cafe] Random this! ;-) To: Max Rabkin max.rab...@gmail.com Cc: michael rice

Re: [Haskell-cafe] Heavy lift-ing

2010-07-24 Thread michael rice
Prelude Control.Monad liftM2 (\a b - a : b : []) abc 123 [a1,a2,a3,b1,b2,b3,c1,c2,c3] Prelude Control.Monad Got it! Thanks to all. Michael --- On Sat, 7/24/10, aditya siram aditya.si...@gmail.com wrote: From: aditya siram aditya.si...@gmail.com Subject: Re: [Haskell-cafe] Heavy lift-ing To:

[Haskell-cafe] Type problems

2010-07-24 Thread michael rice
This works: Prelude System.Random do { randomRIO (1,6) = (\x - putStrLn $ Value = ++ show x) } Value = 5 So does this: Prelude System.Random do { x - randomRIO (1,6); putStrLn $ Value = ++ show x } Value = 2 But not this: 1 import Control.Monad 2 import System.Random 3 4 foo :: IO () 5

Re: [Haskell-cafe] Type problems

2010-07-24 Thread michael rice
Thanks, Tobias. I figured it was something like that but lack the syntax expertise on where to put it. MIchael --- On Sat, 7/24/10, Tobias Brandt tob.bra...@googlemail.com wrote: From: Tobias Brandt tob.bra...@googlemail.com Subject: Re: [Haskell-cafe] Type problems To: michael rice nowg

[Haskell-cafe] Heavy lift-ing

2010-07-23 Thread michael rice
Hi, I don't understand what's taking place here. From Hoogle: = liftM2 :: Monad  m = (a1 - a2 - r) - m a1 - m a2 - m r Promote a function to a monad, scanning the monadic arguments from left to right. For example,     liftM2 (+) [0,1] [0,2] = [0,2,1,3]     liftM2 (+) (Just

Re: [Haskell-cafe] Heavy lift-ing

2010-07-23 Thread michael rice
wrote: From: Jürgen Doser jurgen.do...@gmail.com Subject: Re: [Haskell-cafe] Heavy lift-ing To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Friday, July 23, 2010, 4:50 PM El vie, 23-07-2010 a las 15:05 -0400, Nick Bowler escribió: On 11:43 Fri 23 Jul     , michael rice

[Haskell-cafe] Testing for valid data

2010-03-27 Thread michael rice
When I'm learning a new language I like to translate old programs into the new language as a test of my understanding. However, many of the old programs are from old programming texts, many written in the time of punch-cards for batch processing, and many containing significant amounts of code

Re: [Haskell-cafe] Testing for valid data

2010-03-27 Thread michael rice
...@malde.org Subject: Re: [Haskell-cafe] Testing for valid data To: haskell-cafe@haskell.org Date: Saturday, March 27, 2010, 5:20 PM michael rice nowg...@yahoo.com writes: When I'm learning a new language I like to translate old programs into the new language as a test of my understanding. However

Re: [Haskell-cafe] Using regexps to filter data

2010-03-15 Thread michael rice
Subject: Re: [Haskell-cafe] Using regexps to filter data To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Monday, March 15, 2010, 10:09 AM On 15 March 2010 14:02, michael rice nowg...@yahoo.com wrote: Thanks. Looks kind of complicated. Are there any examples of how to use

[Haskell-cafe] Splitting list with predicate

2010-03-14 Thread michael rice
Is there a library function that will create two lists from one based on a predicate, one list for all elements that satisfy the predicate and one for all that do not? Don't want to reinvent the wheel. Michael ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Splitting list with predicate

2010-03-14 Thread michael rice
Most excellent! Thanks. Michael --- On Sun, 3/14/10, Stephen Tetley stephen.tet...@gmail.com wrote: From: Stephen Tetley stephen.tet...@gmail.com Subject: Re: [Haskell-cafe] Splitting list with predicate To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Sunday, March 14

Re: [Haskell-cafe] Splitting list with predicate

2010-03-14 Thread michael rice
Thanks all, Wouldn't one need to know the order of the arguments? (a - Bool) - [a] - ([a], [a]) Michael --- On Sun, 3/14/10, Simon Hengel simon.hen...@wiktory.org wrote: From: Simon Hengel simon.hen...@wiktory.org Subject: Re: [Haskell-cafe] Splitting list with predicate To: michael rice

Re: [Haskell-cafe] Splitting list with predicate

2010-03-14 Thread michael rice
Cool. Will keep that in mind next time I'm looking for an operation but don't know what it's called. Michael --- On Sun, 3/14/10, Simon Hengel simon.hen...@wiktory.org wrote: From: Simon Hengel simon.hen...@wiktory.org Subject: Re: [Haskell-cafe] Splitting list with predicate To: michael rice

[Haskell-cafe] Using regexps to filter data

2010-03-14 Thread michael rice
Not sure I'm even in the right neighborhood with this. Need to screen for integer data. Am I going about this correctly? Michael == [mich...@localhost ~]$ ghci GHCi, version 6.10.4: http://www.haskell.org/ghc/  :? for help Loading package ghc-prim ... linking ... done. Loading package

Re: [Haskell-cafe] Stack ADT?

2010-02-05 Thread michael rice
Not using Stack for anything, just trying to understand how things can be done in Haskell. To that end... What's going on here? I'm not even calling function POP. Michael == module Data.Stack (Stack, emptyStack, isEmptyStack, push, pop, top) where newtype Stack a = Stack

Re: [Haskell-cafe] Stack ADT?

2010-02-05 Thread michael rice
] Stack ADT? To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org, Casey Hawthorne cas...@istar.ca Date: Friday, February 5, 2010, 11:04 AM 2010/2/5 michael rice nowg...@yahoo.com Not using Stack for anything, just trying to understand how things can be done in Haskell. To that end

[Haskell-cafe] Stack ADT?

2010-02-04 Thread michael rice
Can't find a Stack datatype on Hoogle? Where should I look? Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Stack ADT?

2010-02-04 Thread michael rice
: Sebastian Fischer s...@informatik.uni-kiel.de Subject: Re: [Haskell-cafe] Stack ADT? To: haskell-cafe Cafe haskell-cafe@haskell.org Date: Thursday, February 4, 2010, 12:16 PM On Feb 4, 2010, at 6:07 PM, michael rice wrote: Can't find a Stack datatype on Hoogle? Where should I look? Could

[Haskell-cafe] Strange random choice algorithm

2010-01-30 Thread michael rice
I'm not sure where I got this PICK function from, and don't understand why it's written as it is, so I wanted to test it for randomness. It seems random enough. But if I understand the algorithm correctly, instead of selecting one of the elements from the list, it eliminates all the elements

Re: [Haskell-cafe] Strange random choice algorithm

2010-01-30 Thread michael rice
: Saturday, January 30, 2010, 6:06 PM On Jan 30, 2010, at 8:59 PM, michael rice wrote: I'm not sure where I got this PICK function from, and don't understand why it's written as it is, so I wanted to test it for randomness. It seems random enough. We can convince ourselves using reason

[Haskell-cafe] Maybe, maybe not.

2010-01-26 Thread michael rice
Just noticed this difference in the definition of fromMaybe in two different places: http://haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/src/Data-Maybe.html#fromMaybe -- | The 'fromMaybe' function takes a default value and and 'Maybe' -- value.  If the 'Maybe' is 'Nothing', it

Re: [Haskell-cafe] Maybe, maybe not.

2010-01-26 Thread michael rice
not. To: michael rice nowg...@yahoo.com Cc: haskell-cafe haskell-cafe@haskell.org Date: Tuesday, January 26, 2010, 10:52 PM Excerpts from michael rice's message of Tue Jan 26 21:34:42 -0500 2010: fromMaybe d x = case x of {Nothing - d;Just v  - v} fromMaybe z = maybe z id They're equivalent.  Here

Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-20 Thread michael rice
...@malde.org Subject: Re: [Haskell-cafe] Having a look at XMonad window manager To: michael rice nowg...@yahoo.com Cc: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com, haskell-cafe@haskell.org Date: Wednesday, January 20, 2010, 1:20 AM michael rice nowg...@yahoo.com writes: Perhaps. Is there a Linux

Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-20 Thread michael rice
It seems I was doing MUCH more than I needed to do to have a look at XMonad in action. I went back and created a .xsession file with just one line: xmonad I then disabled Nautilus (unchecked show desktop) and started xmonad as follows killall metacity; xmonad Everything now seems to work

Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-19 Thread michael rice
How did you configure it? Are you still using it? Michael --- On Tue, 1/19/10, Chaddaï Fouché chaddai.fou...@gmail.com wrote: From: Chaddaï Fouché chaddai.fou...@gmail.com Subject: Re: [Haskell-cafe] Having a look at XMonad window manager To: John Millikin jmilli...@gmail.com Cc: michael rice

[Haskell-cafe] Having a look at XMonad window manager

2010-01-18 Thread michael rice
I downloaded XMonad from the Fedora 12 repository and would like to see it in action. What must I do to get it working from the Gnome desktop environment? Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-18 Thread michael rice
Subject: Re: [Haskell-cafe] Having a look at XMonad window manager To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Monday, January 18, 2010, 1:57 PM michael rice nowg...@yahoo.com writes: I downloaded XMonad from the Fedora 12 repository and would like to see it in action

Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-18 Thread michael rice
~]$ I added /usr/bin/xmonad to startup applications. All these things were suggested. Michael --- On Mon, 1/18/10, Don Stewart d...@galois.com wrote: From: Don Stewart d...@galois.com Subject: Re: [Haskell-cafe] Having a look at XMonad window manager To: michael rice nowg...@yahoo.com Cc: Ivan

Re: [Haskell-cafe] Having a look at XMonad window manager

2010-01-18 Thread michael rice
Perhaps. Is there a Linux distro that's more XMonad friendly? Michael --- On Mon, 1/18/10, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: From: Ivan Lazar Miljenovic ivan.miljeno...@gmail.com Subject: Re: [Haskell-cafe] Having a look at XMonad window manager To: michael rice nowg

[Haskell-cafe] What's going on here?

2010-01-16 Thread michael rice
I don't see anything wrong with this function, which just subtracts 1 from the first element of an Int list (if there is a first element). Michael My function: dropFirst :: [Int] - [Int] dropFirst [] = [] dropFirst (x:xs) = (x-1) : xs My output: :l dropfirst [1 of 1] Compiling Main  

Re: [Haskell-cafe] What's going on here?

2010-01-16 Thread michael rice
, January 16, 2010, 10:05 PM 在 2010年 1月 17日 星期日 11:02:59,michael rice 寫道: I don't see anything wrong with this function, which just subtracts 1 from   the first element of an Int list (if there is a first element). Michael My function: dropFirst :: [Int] - [Int] dropFirst

[Haskell-cafe] Lazy evaluation/functions

2009-12-27 Thread michael rice
I've seen the terms lazy evaluation and lazy function. Is this just lazy language or are both these terms valid? Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] trace

2009-12-24 Thread michael rice
Can someone provide a simple example of tracing a function. Michael ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] trace

2009-12-24 Thread michael rice
= memo_walk_count (n-2) + memo_walk_count (n-1)    in (map walk_count [0..] !!)   --- On Thu, 12/24/09, Daniel Fischer daniel.is.fisc...@web.de wrote: From: Daniel Fischer daniel.is.fisc...@web.de Subject: Re: [Haskell-cafe] trace To: haskell-cafe@haskell.org Cc: michael rice nowg...@yahoo.com Date

Re: [Haskell-cafe] Haskell and memoization

2009-12-16 Thread michael rice
Thanks all, OK, so this definition of fib fib 0 = 1 fib 1 = 1 fib n = fib (n-1) + fib (n-2) would involve a lot of recomputation for some large n, which memoization would eliminate? Michael --- On Wed, 12/16/09, michael rice nowg...@yahoo.com wrote: From: michael rice nowg...@yahoo.com

[Haskell-cafe] Haskell arrays

2009-12-16 Thread michael rice
Based upon docs I've looked at, Haskell seems to store both an array element value AND its index/indices, whereas most languages just store the value and find its location in memory through mapping calculations. Is it true? Michael ___

Re: [Haskell-cafe] Haskell arrays

2009-12-16 Thread michael rice
Peebles pumpkin...@gmail.com wrote: From: Daniel Peebles pumpkin...@gmail.com Subject: Re: [Haskell-cafe] Haskell arrays To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Wednesday, December 16, 2009, 10:46 PM It doesn't store both, but does provides a flexible indexing strategy

<    1   2   3   4   >