
Hi Lawrence. Other people have given some answers, but perhaps saying it in a different way may also help. For starters, we have to remember that functions do not have instances of `Show' [1]: To exemplify, if we have a function and try to print it, we get an error: f :: a -> a f x = x $ ghci Prelude> :load fn.hs *Main> f <interactive>:2:1: error: • No instance for (Show (a0 -> a0)) arising from a use of ‘print’ (maybe you haven't applied a function to enough arguments?) • In a stmt of an interactive GHCi command: print it *Main> This is just to exemplify that there is nothing wrong with *your* function. As you see, I produced the same error with a much simpler function. So, as others mentioned, it looks like you just tried to print your function, which is not possible. I would also like to add a note about emacs haskell-mode's REPL that is related to this topic. haskell-mode's REPL runs `:type' behind the scenes when we try to print functions. It might give the impression that we can actually print functions, or that functions have instance of `Show', which is not the case. In emacs + haskell-mode, the variable haskell-interactive-types-for-show-ambiguous is supposed to be `t' by default (instead of `nil'). In any case, you can play with it and try to print functions directly by just typing their name [2]: (custom-set-variables '(haskell-interactive-types-for-show-ambiguous t) References: • [1] https://wiki.haskell.org/Show_instance_for_functions • [2] https://haskell.github.io/haskell-mode/manual/latest/Interactive-Haskell.htm... On Thu, Sep 09, 2021 at 04:25:58PM -0500, Galaxy Being wrote:
I've got this
import Data.Tuple fswp :: (a, b) -> (b, a) fswp = Data.Tuple.swap
and get this
• No instance for (Show ((a0, b0) -> (b0, a0))) arising from a use of ‘print’ (maybe you haven't applied a function to enough arguments?) • In a stmt of an interactive GHCi command: print it
Not sure why or what to do to correct it.
⨽ Lawrence Bottorff Grand Marais, MN, USA borgauf@gmail.com
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners