Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  trouble using the foldl .... (Sunil S Nandihalli)
   2. Re:  trouble using the foldl .... (Sunil S Nandihalli)
   3. Re:  trouble using the foldl .... (Daniel Fischer)
   4.  dph (Luca Ciciriello)
   5.  compilation error.. (Sunil S Nandihalli)
   6. Re:  compilation error.. (Brandon Allbery)


----------------------------------------------------------------------

Message: 1
Date: Thu, 11 Aug 2011 16:23:16 +0530
From: Sunil S Nandihalli <[email protected]>
Subject: [Haskell-beginners] trouble using the foldl ....
To: [email protected]
Message-ID:
        <cap0fd72_r0sws_+9aszf3bsmdd6mpkri6bhbzr9rkhfptqi...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hello everybody,
When I compile a file containing ...

plotAsString::(Integral a)=>[(a,a)]->a->String
plotAsString locs ans = let xs = map fst locs
                            ys = map snd locs
                            locsmap = M.fromList (zip locs [0..])
                            bufsize=10
                            min' = ((\x -> x-bufsize) . minimum)
                            max' = ((\x -> x+bufsize) . maximum)
                            (bmin@(x0,y0),bmax@(x1,y1)) = ((min' xs,min'
ys),(max' xs,max' ys))
                            plotString = foldl (\curStr newRowId -> (foldl
(\ccStr newColId -> (ccStr++(case (M.member (newRowId,newColId) locsmap) of

                            (Just v) -> ("." ++ (show v) ++ ".")

                            (Nothing) -> "   ")))

curStr [y0..y1])) "" [x0..x1]
                        in plotString

I get the following error..

main.hs:34:107:
    Couldn't match expected type `Bool' with actual type `Maybe t0'
    In the pattern: Just v
    In a case alternative: (Just v) -> ("." ++ (show v) ++ ".")
    In the second argument of `(++)', namely
      `(case (M.member (newRowId, newColId) locsmap) of {
          (Just v) -> ("." ++ (show v) ++ ".")
          (Nothing) -> "   " })'

can somebody help?

Thanks,
Sunil.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110811/c902d219/attachment-0001.htm>

------------------------------

Message: 2
Date: Thu, 11 Aug 2011 16:32:58 +0530
From: Sunil S Nandihalli <[email protected]>
Subject: Re: [Haskell-beginners] trouble using the foldl ....
To: [email protected]
Message-ID:
        <cap0fd703tb2bvebjejvfjelbustypb+njaaxqkm2hzc3rm3...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

I think I figured out..  I had to replace M.member with M.lookup..

Thanks,
Sunil.

On Thu, Aug 11, 2011 at 4:23 PM, Sunil S Nandihalli <
[email protected]> wrote:

> Hello everybody,
> When I compile a file containing ...
>
> plotAsString::(Integral a)=>[(a,a)]->a->String
> plotAsString locs ans = let xs = map fst locs
>                             ys = map snd locs
>                             locsmap = M.fromList (zip locs [0..])
>                             bufsize=10
>                             min' = ((\x -> x-bufsize) . minimum)
>                             max' = ((\x -> x+bufsize) . maximum)
>                             (bmin@(x0,y0),bmax@(x1,y1)) = ((min' xs,min'
> ys),(max' xs,max' ys))
>                             plotString = foldl (\curStr newRowId -> (foldl
> (\ccStr newColId -> (ccStr++(case (M.member (newRowId,newColId) locsmap) of
>
>                               (Just v) -> ("." ++ (show v) ++ ".")
>
>                               (Nothing) -> "   ")))
>
> curStr [y0..y1])) "" [x0..x1]
>                         in plotString
>
> I get the following error..
>
> main.hs:34:107:
>     Couldn't match expected type `Bool' with actual type `Maybe t0'
>     In the pattern: Just v
>     In a case alternative: (Just v) -> ("." ++ (show v) ++ ".")
>     In the second argument of `(++)', namely
>       `(case (M.member (newRowId, newColId) locsmap) of {
>           (Just v) -> ("." ++ (show v) ++ ".")
>           (Nothing) -> "   " })'
>
> can somebody help?
>
> Thanks,
> Sunil.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110811/55e2ff5c/attachment-0001.htm>

------------------------------

Message: 3
Date: Thu, 11 Aug 2011 13:07:42 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] trouble using the foldl ....
To: [email protected]
Message-ID: <[email protected]>
Content-Type: Text/Plain;  charset="utf-8"

On Thursday 11 August 2011, 12:53:16, Sunil S Nandihalli wrote:
> Hello everybody,
> When I compile a file containing ...
> I get the following error..
> 
> main.hs:34:107:
>     Couldn't match expected type `Bool' with actual type `Maybe t0'
>     In the pattern: Just v
>     In a case alternative: (Just v) -> ("." ++ (show v) ++ ".")
>     In the second argument of `(++)', namely
>       `(case (M.member (newRowId, newColId) locsmap) of {

`member'  tests whether a key is in the map, it returns a Bool ("is it a 
member", not "give me the member if there is one").
It looks like you want M.lookup here.

>           (Just v) -> ("." ++ (show v) ++ ".")
>           (Nothing) -> "   " })'
> 
> can somebody help?
> 
> Thanks,
> Sunil.




------------------------------

Message: 4
Date: Thu, 11 Aug 2011 13:34:53 +0200
From: Luca Ciciriello <[email protected]>
Subject: [Haskell-beginners] dph
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

I'm here again.
I'm installed from hackage  al dph-<something> packages but still I've problems 
using elemP and foldP (not found).

If I import Data.Array.Parallel.PArr the compiler says:

Could not find module `Data.Array.Parallel.PArr'
    it is a hidden module in the package `dph-par'
    it is a hidden module in the package `dph-seq'

if I use before to build the command "ghc-pkg expose dph-par" and "ghc-pkg 
expose dph-seq"

nothing changes. 
I'm using GHC 7.2.1 64-bit on MacOS X Lion (Xcode 4.1)

Please, please, please, I really need help.

Luca


------------------------------

Message: 5
Date: Thu, 11 Aug 2011 17:13:27 +0530
From: Sunil S Nandihalli <[email protected]>
Subject: [Haskell-beginners] compilation error..
To: [email protected]
Message-ID:
        <CAP0FD70jA4y6ZPz9D-W_HcwCap=wduwgoswsf9magrbsb9q...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hello everybody,
 when I compile the file

https://github.com/sunilnandihalli/is2/blob/master/main.hs

I get
main.hs:28:64:
    Could not deduce (Enum (a, t0))
      arising from the arithmetic sequence `0 .. '
    from the context (Integral a)
      bound by the type signature for
                 plotAsString :: Integral a => [(a, a)] -> (a, a) -> String
      at main.hs:(26,1)-(38,41)
    Possible fix:
      add (Enum (a, t0)) to the context of
        the type signature for
          plotAsString :: Integral a => [(a, a)] -> (a, a) -> String
      or add an instance declaration for (Enum (a, t0))
    In the second argument of `zip', namely `[0 .. ]'
    In the first argument of `M.fromList', namely `(zip locs [0 .. ])'
    In the expression: M.fromList (zip locs [0 .. ])

main.hs:28:65:
    Could not deduce (Num (a, t0)) arising from the literal `0'
    from the context (Integral a)
      bound by the type signature for
                 plotAsString :: Integral a => [(a, a)] -> (a, a) -> String
      at main.hs:(26,1)-(38,41)
    Possible fix:
      add (Num (a, t0)) to the context of
        the type signature for
          plotAsString :: Integral a => [(a, a)] -> (a, a) -> String
      or add an instance declaration for (Num (a, t0))
    In the expression: 0
    In the second argument of `zip', namely `[0 .. ]'
    In the first argument of `M.fromList', namely `(zip locs [0 .. ])'


can somebody help?
Thanks,
Sunil.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110811/efeaceeb/attachment-0001.htm>

------------------------------

Message: 6
Date: Thu, 11 Aug 2011 08:03:06 -0400
From: Brandon Allbery <[email protected]>
Subject: Re: [Haskell-beginners] compilation error..
To: Sunil S Nandihalli <[email protected]>
Cc: [email protected]
Message-ID:
        <CAKFCL4Uu_xixa-EnhHVRqP=4jn=hhyrx4ee0tpkiyhc+ugp...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On Thu, Aug 11, 2011 at 07:43, Sunil S Nandihalli <
[email protected]> wrote:

> Hello everybody,
>  when I compile the file
>
> https://github.com/sunilnandihalli/is2/blob/master/main.hs
>
> I get
> main.hs:28:64:
>     Could not deduce (Enum (a, t0))
>       arising from the arithmetic sequence `0 .. '
>     from the context (Integral a)
>       bound by the type signature for
>                  plotAsString :: Integral a => [(a, a)] -> (a, a) -> String
>       at main.hs:(26,1)-(38,41)
>     Possible fix:
>       add (Enum (a, t0)) to the context of
>         the type signature for
>           plotAsString :: Integral a => [(a, a)] -> (a, a) -> String
>       or add an instance declaration for (Enum (a, t0))
>     In the second argument of `zip', namely `[0 .. ]'
>     In the first argument of `M.fromList', namely `(zip locs [0 .. ])'
>     In the expression: M.fromList (zip locs [0 .. ])
>

The weird error is because Haskell is defined to promote integer literals to
instances of Integral, then applying further an instance of Enum; but the
actual type it's expecting is a tuple because you're using (Just (id,_)) on
line 34 as the result of (M.lookup).  Were you perhaps expecting (M.lookup)
to return a tuple of the key and value?

(Also, in light of your previous message, you'll find things compile more
easily if you learn the correct types and behaviors of standard Haskell
functions instead of making assumptions possibly based on the behavior of
some other language.)

-- 
brandon s allbery                                      [email protected]
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110811/f52ec159/attachment.htm>

------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 38, Issue 26
*****************************************

Reply via email to