{-| Module  : FiniteCategories
Description : Helpers for instanciating Show.
Copyright   : Guillaume Sabbagh 2021
License     : GPL-3
Maintainer  : guillaumesabbagh@protonmail.com
Stability   : experimental
Portability : portable

Helpers for instanciating Show.
-}
module IO.Show
(
    showFunction
)
where
    import Data.List (intercalate)
    
    -- | Show a function on a certain domain.

    showFunction :: (Show a, Show b) =>
                   (a -> b) -> [a] -> String
    showFunction :: forall a b. (Show a, Show b) => (a -> b) -> [a] -> String
showFunction a -> b
f [a]
xs = String
"(\\x -> case x of " String -> String -> String
forall a. [a] -> [a] -> [a]
++ String -> [String] -> String
forall a. [a] -> [[a]] -> [a]
intercalate String
";" [a -> String
forall a. Show a => a -> String
show a
x String -> String -> String
forall a. [a] -> [a] -> [a]
++String
" -> " String -> String -> String
forall a. [a] -> [a] -> [a]
++ b -> String
forall a. Show a => a -> String
show (a -> b
f a
x) | a
x <- [a]
xs] String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
")"