On Fri, Sep 12, 2008 at 8:53 PM, Don Stewart <[EMAIL PROTECTED]> wrote:
> cetin.sert:
>
>>    main :: IO ()
>>    main = do
>>      as <- getArgs
>>      mt <- newPureMT
>>      let colors = randomRs (lo,hi) mt :: [RGB]
>>      print $ zip tx cs
>>      where
>>        lo = read $ as !! 0
>>        hi = read $ as !! 1
>>        tx =        as !! 2
>>    Why is as not visible in the where block?
>
> Same as:
>
>     main =
>       let
>         lo = read $ as !! 0
>         hi = read $ as !! 1
>         tx =        as !! 2
>       in do
>         as <- getArgs
>         mt <- newPureMT
>         let colors = randomRs (lo,hi) mt :: [RGB]
>         print $ zip tx cs
>
> If that helps think about when things are bound.

And you probably want this rewrite (untested):
    main :: IO ()
    main = do
      as <- getArgs
      let lo = read $ as !! 0
           hi = read $ as !! 1
           tx = as !! 2
      mt <- newPureMT
      let colors = randomRs (lo,hi) mt :: [RGB]
      print $ zip tx cs

My indentation may be a bit off as I didn't use a fixed width font to type it.

Jason
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to