<div dir="ltr"><div>I modified your code little bit and I got this error. <br><br>λ> :t (pure (+) <*> ([1, 2, 3] :: [Int]))<br>(pure (+) <*> ([1, 2, 3] :: [Int])) :: [Int -> Int]<br></div><div><br></div><div><br>λ> show (pure (+) <*> ([1, 2, 3] :: [Int]))<br><br><interactive>:13:1:<br> No instance for (Show (Int -> Int)) arising from a use of ‘show’<br> In the expression: show (pure (+) <*> ([1, 2, 3] :: [Int]))<br> In an equation for ‘it’:<br> it = show (pure (+) <*> ([1, 2, 3] :: [Int]))<br><br></div>You have list of functions ( [Int -> Int] ) and functions are not instance of Show class so error is pointing towards this fact. <br><br>λ> :i Show<br>class Show a where<br> showsPrec :: Int -> a -> ShowS<br> show :: a -> String<br> showList :: [a] -> ShowS<br> -- Defined in ‘GHC.Show’<br>instance Show a => Show [a] -- Defined in ‘GHC.Show’<br>instance Show Ordering -- Defined in ‘GHC.Show’<br>instance Show a => Show (Maybe a) -- Defined in ‘GHC.Show’<br>instance Show Integer -- Defined in ‘GHC.Show’<br>instance Show Int -- Defined in ‘GHC.Show’<br>instance Show Char -- Defined in ‘GHC.Show’<br>instance Show Bool -- Defined in ‘GHC.Show’<br>instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g,<br> Show h, Show i, Show j, Show k, Show l, Show m, Show n, Show o) =><br> Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)<br> -- Defined in ‘GHC.Show’<br>instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g,<br> Show h, Show i, Show j, Show k, Show l, Show m, Show n) =><br> Show (a, b, c, d, e, f, g, h, i, j, k, l, m, n)<br> -- Defined in ‘GHC.Show’<br>instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g,<br> Show h, Show i, Show j, Show k, Show l, Show m) =><br> Show (a, b, c, d, e, f, g, h, i, j, k, l, m)<br> -- Defined in ‘GHC.Show’<br>instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g,<br> Show h, Show i, Show j, Show k, Show l) =><br> Show (a, b, c, d, e, f, g, h, i, j, k, l)<br> -- Defined in ‘GHC.Show’<br>instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g,<br> Show h, Show i, Show j, Show k) =><br> Show (a, b, c, d, e, f, g, h, i, j, k)<br> -- Defined in ‘GHC.Show’<br>instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g,<br> Show h, Show i, Show j) =><br> Show (a, b, c, d, e, f, g, h, i, j)<br> -- Defined in ‘GHC.Show’<br>instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g,<br> Show h, Show i) =><br> Show (a, b, c, d, e, f, g, h, i)<br> -- Defined in ‘GHC.Show’<br>instance (Show a, Show b, Show c, Show d, Show e, Show f, Show g,<br> Show h) =><br> Show (a, b, c, d, e, f, g, h)<br> -- Defined in ‘GHC.Show’<br>instance (Show a, Show b, Show c, Show d, Show e, Show f,<br> Show g) =><br> Show (a, b, c, d, e, f, g)<br> -- Defined in ‘GHC.Show’<br>instance (Show a, Show b, Show c, Show d, Show e, Show f) =><br> Show (a, b, c, d, e, f)<br> -- Defined in ‘GHC.Show’<br>instance (Show a, Show b, Show c, Show d, Show e) =><br> Show (a, b, c, d, e)<br> -- Defined in ‘GHC.Show’<br>instance (Show a, Show b, Show c, Show d) => Show (a, b, c, d)<br> -- Defined in ‘GHC.Show’<br>instance (Show a, Show b, Show c) => Show (a, b, c)<br> -- Defined in ‘GHC.Show’<br>instance (Show a, Show b) => Show (a, b) -- Defined in ‘GHC.Show’<br>instance Show () -- Defined in ‘GHC.Show’<br>instance (Show a, Show b) => Show (Either a b)<br> -- Defined in ‘Data.Either’<br>instance Show a => Show (ZipList a)<br> -- Defined in ‘Control.Applicative’<br>instance Show Float -- Defined in ‘GHC.Float’<br>instance Show Double -- Defined in ‘GHC.Float’<br><br>See the [1] [2].<br><br>[1] <a href="https://wiki.haskell.org/Show_instance_for_functions">https://wiki.haskell.org/Show_instance_for_functions</a><br>[2] <a href="http://stackoverflow.com/questions/15823732/why-is-there-no-show-instance-for-functions">http://stackoverflow.com/questions/15823732/why-is-there-no-show-instance-for-functions</a><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 15, 2015 at 6:17 PM, Shishir Srivastava <span dir="ltr"><<a href="mailto:shishir.srivastava@gmail.com" target="_blank">shishir.srivastava@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">hi,<div><br></div><div>I am trying to naively print an applicative functor using 'show' like this - </div><div><br></div><div><font face="monospace, monospace">show (pure (+) <*> [1, 2, 3])</font><br></div><div><br></div><div>I know there is something fundamentally wrong with that expression but not sure what. </div><div><br></div><div>Can anyone please point it out.</div><div><br></div><div>Thanks,</div><div><div><div><div dir="ltr"><font color="#0b5394"><font style="background-color:rgb(255,255,255)"><font face="georgia, serif" size="2">Shishir </font></font><br></font><br></div></div></div>
</div></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br></div>