You need to enable some extensions:
{-# LANGUAGE OverlappingInstances, FlexibleInstances #-} module FunShow where instance Show ((->) aa) where show _ = "<<Endofunction>>" instance Show ((->) ab) where show _ = "<<Function>>"
You need OverlappingInstances since the a -> b instance also matches the endofunctions functions, so they overlap, and you need FlexibleInstances because the language standard states that type variables in instance declarations are different.
*FunShow> show not "<<Endofunction>>" *FunShow> show fst "<<Function>>" *FunShow> show id "<<Endofunction>>"
Daniel Fischer
source share