Quick actions

cmd+k|ctrl+k

Navigation

Languages

Typeable

Snippet info

Language

Haskell

Visibility

public

Author

homam

Created

2016-08-25T09:08:36Z

Updated

2016-08-25T10:02:27Z

{-# LANGUAGE ScopedTypeVariables #-}

import Data.Typeable

askQuestion :: (Typeable a, Typeable b) => b -> a -> b
askQuestion b a = case cast a of
 (Just x) ->  x
 Nothing ->  b

main = getLine >>= (print . askQuestion "Error")
INFO