Haskell: Is it possible to create a list of Show types? List[Show]? -


is possible create list holds values belong show type ?

this similar list[showable] in scala, showable trait.

in way 1 put, example, int , string same list.

is possible? if yes, how ?

you can using existential types

data showbox = forall s. show s => sb s  heterolist :: [showbox] heterolist = [sb "hello world", sb 5, sb 1] 

the thing can items in list show them:

let strings = fmap (\(sb b) -> show b) heterolist 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -