I would like to implement the show method for (binary) functions and make it able to distingish endofunctions (a -> a).
Something like t
You need to enable some extensions:
{-# LANGUAGE OverlappingInstances, FlexibleInstances #-}
module FunShow where
instance Show ((->) a a) where
show _ = "<>"
instance Show ((->) a b) where
show _ = "<>"
You need OverlappingInstances since the instance a -> b also matches endofunctions, so there's overlap, and you need FlexibleInstances because the language standard mandates that the type variables in instance declarations are distinct.
*FunShow> show not
"<>"
*FunShow> show fst
"<>"
*FunShow> show id
"<>"