Functions to Polymorphic Types Answer

Run Settings
LanguageHaskell
Language Version
Run Command
{-# LANGUAGE GADTs, ScopedTypeVariables #-} import Data.Typeable data Foo where Foo :: (Typeable a, Show a) => a -> Foo instance Show Foo where show (Foo a) = show a fiveFoo :: Foo fiveFoo = Foo (5 :: Int) -- (Foo 5) doesn't work because of ambiguity falseFoo :: Foo falseFoo = Foo False getFoo :: String -> Foo getFoo "five" = fiveFoo getFoo "false" = falseFoo main = do print $ getFoo "five" -- prints '5' print $ getFoo "false" -- prints 'False'
Editor Settings
Theme
Key bindings
Full width
Lines