I was playing with arrows and for that, I tried to write a function which traces its input and output. It didn't work because I ended up needing a Show constraint on the parameter of my type when instanciating the Arrow class. Anyway, my question is the following, is there a way to create a showlike
function, which uses show
if possible and a default string if not.
I tried the following (using type families) but it doesn't work
{-# TypeFamilies #-}
type family ToShow where
Show a => ToShow a = a -- doesn't compile
ToShow a = ()
toShow :: a -> ToShow a
toShow x = ???
show' :: a -> String
show' = show . toShow
Any idea if this is possible ?