Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/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. Using Show (Shishir Srivastava)
2. Re: Left vs Right (Kostiantyn Rybnikov)
3. Re: Using Show (mukesh tiwari)
4. Parse error (Shishir Srivastava)
5. Re: Parse error (Brandon Allbery)
----------------------------------------------------------------------
Message: 1
Date: Wed, 15 Apr 2015 13:47:49 +0100
From: Shishir Srivastava <[email protected]>
To: beginners <[email protected]>
Subject: [Haskell-beginners] Using Show
Message-ID:
<cale5rtsftzhrq9rqtssvqyx3s1n+b4rwpap+nzgus+0yuq9...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
hi,
I am trying to naively print an applicative functor using 'show' like this
-
show (pure (+) <*> [1, 2, 3])
I know there is something fundamentally wrong with that expression but not
sure what.
Can anyone please point it out.
Thanks,
Shishir
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150415/e3a23932/attachment-0001.html>
------------------------------
Message: 2
Date: Wed, 15 Apr 2015 15:50:01 +0300
From: Kostiantyn Rybnikov <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Left vs Right
Message-ID:
<CAAbahfTLubcCJZjNH7L84eh=NxVUKKSUN+iJc3Kf2YJd5-=z...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Adding to others,
For fmapping left value I suggest using fmapLeft from errors package, for
fmapping both you can use
either (Left . replicate 3) (Right . replicate 3)
14 ????. 2015 19:48 "Shishir Srivastava" <[email protected]>
????:
> Hi,
>
> Can someone please explain the difference in outputs of the following two
> expressions -
>
> --------------
>
> ghci> fmap (replicate 3) (Right "blah")
> Right ["blah","blah","blah"]
>
> ghci> fmap (replicate 3) (Left "foo")
> Left "foo"
>
> ---------------
>
> Why does 'Right' return a list of Strings whereas 'Left' returns just a
> String.
>
> Thanks,
> Shishir
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150415/ebfc14eb/attachment-0001.html>
------------------------------
Message: 3
Date: Wed, 15 Apr 2015 18:43:19 +0530
From: mukesh tiwari <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Using Show
Message-ID:
<CAFHZvE9ki0iX=18wUOuZrO_sVXHxS8=0hgFy=o_75qkf6an...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
I modified your code little bit and I got this error.
?> :t (pure (+) <*> ([1, 2, 3] :: [Int]))
(pure (+) <*> ([1, 2, 3] :: [Int])) :: [Int -> Int]
?> show (pure (+) <*> ([1, 2, 3] :: [Int]))
<interactive>:13:1:
No instance for (Show (Int -> Int)) arising from a use of ?show?
In the expression: show (pure (+) <*> ([1, 2, 3] :: [Int]))
In an equation for ?it?:
it = show (pure (+) <*> ([1, 2, 3] :: [Int]))
You have list of functions ( [Int -> Int] ) and functions are not instance
of Show class so error is pointing towards this fact.
?> :i Show
class Show a where
showsPrec :: Int -> a -> ShowS
show :: a -> String
showList :: [a] -> ShowS
-- Defined in ?GHC.Show?
instance Show a => Show [a] -- Defined in ?GHC.Show?
instance Show Ordering -- Defined in ?GHC.Show?
instance Show a => Show (Maybe a) -- Defined in ?GHC.Show?
instance Show Integer -- Defined in ?GHC.Show?
instance Show Int -- Defined in ?GHC.Show?
instance Show Char -- Defined in ?GHC.Show?
instance Show Bool -- Defined in ?GHC.Show?
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g,
Show h, Show i, Show j, Show k, Show l, Show m, Show n, Show o) =>
Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
-- Defined in ?GHC.Show?
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g,
Show h, Show i, Show j, Show k, Show l, Show m, Show n) =>
Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n)
-- Defined in ?GHC.Show?
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g,
Show h, Show i, Show j, Show k, Show l, Show m) =>
Show (a, b, c, d, e, f, g, h, i, j, k, l, m)
-- Defined in ?GHC.Show?
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g,
Show h, Show i, Show j, Show k, Show l) =>
Show (a, b, c, d, e, f, g, h, i, j, k, l)
-- Defined in ?GHC.Show?
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g,
Show h, Show i, Show j, Show k) =>
Show (a, b, c, d, e, f, g, h, i, j, k)
-- Defined in ?GHC.Show?
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g,
Show h, Show i, Show j) =>
Show (a, b, c, d, e, f, g, h, i, j)
-- Defined in ?GHC.Show?
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g,
Show h, Show i) =>
Show (a, b, c, d, e, f, g, h, i)
-- Defined in ?GHC.Show?
instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g,
Show h) =>
Show (a, b, c, d, e, f, g, h)
-- Defined in ?GHC.Show?
instance (Show a, Show b, Show c, Show d, Show e, Show f,
Show g) =>
Show (a, b, c, d, e, f, g)
-- Defined in ?GHC.Show?
instance (Show a, Show b, Show c, Show d, Show e, Show f) =>
Show (a, b, c, d, e, f)
-- Defined in ?GHC.Show?
instance (Show a, Show b, Show c, Show d, Show e) =>
Show (a, b, c, d, e)
-- Defined in ?GHC.Show?
instance (Show a, Show b, Show c, Show d) => Show (a, b, c, d)
-- Defined in ?GHC.Show?
instance (Show a, Show b, Show c) => Show (a, b, c)
-- Defined in ?GHC.Show?
instance (Show a, Show b) => Show (a, b) -- Defined in ?GHC.Show?
instance Show () -- Defined in ?GHC.Show?
instance (Show a, Show b) => Show (Either a b)
-- Defined in ?Data.Either?
instance Show a => Show (ZipList a)
-- Defined in ?Control.Applicative?
instance Show Float -- Defined in ?GHC.Float?
instance Show Double -- Defined in ?GHC.Float?
See the [1] [2].
[1] https://wiki.haskell.org/Show_instance_for_functions
[2]
http://stackoverflow.com/questions/15823732/why-is-there-no-show-instance-for-functions
On Wed, Apr 15, 2015 at 6:17 PM, Shishir Srivastava <
[email protected]> wrote:
> hi,
>
> I am trying to naively print an applicative functor using 'show' like this
> -
>
> show (pure (+) <*> [1, 2, 3])
>
> I know there is something fundamentally wrong with that expression but not
> sure what.
>
> Can anyone please point it out.
>
> Thanks,
> Shishir
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150415/194b43ce/attachment-0001.html>
------------------------------
Message: 4
Date: Wed, 15 Apr 2015 17:21:20 +0100
From: Shishir Srivastava <[email protected]>
To: beginners <[email protected]>
Subject: [Haskell-beginners] Parse error
Message-ID:
<cale5rtstxmtoyqvszkdcf6+7op06cr0om_r_d-9nz4kn_jj...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi,
I am trying to run the following from the GHCi command prompt which results
in parse error.
--------------
Prelude> :{
Prelude| foo :: Maybe String
Prelude| foo = do
Prelude| x <- Just 3
Prelude| y <- Just "!"
Prelude| Just (show x ++ y)
Prelude| :}
<interactive>:145:5: parse error on input `='
---------------
Any help would be appreciated.
Thanks,
Shishir
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150415/096a834e/attachment-0001.html>
------------------------------
Message: 5
Date: Wed, 15 Apr 2015 12:23:28 -0400
From: Brandon Allbery <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Parse error
Message-ID:
<cakfcl4ws40-iz9owfub7nydc_b8aedghjcv0fpt87dvt1so...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Wed, Apr 15, 2015 at 12:21 PM, Shishir Srivastava <
[email protected]> wrote:
> I am trying to run the following from the GHCi command prompt which
> results in parse error.
>
ghci is not ghc, and requires `let`
>
> --------------
> Prelude> :{
> Prelude| foo :: Maybe String
> Prelude| foo = do
> Prelude| x <- Just 3
> Prelude| y <- Just "!"
> Prelude| Just (show x ++ y)
> Prelude| :}
>
> <interactive>:145:5: parse error on input `='
> ---------------
>
> Any help would be appreciated.
>
> Thanks,
> Shishir
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
--
brandon s allbery kf8nh sine nomine associates
[email protected] [email protected]
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20150415/edc664c1/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 82, Issue 15
*****************************************