, , .
, , " ".
-, :
Simple :: forall a. (Typeable a, Show a) =>
Message -> (String -> a) -> Question
Question
Simple {a}{typeableDict4a}{showDict4a} message parser
. "", Typeable Show.
. , .
runQuestion :: forall b. (Typeable b, Show b) => Question -> IO b
, , runQuestion, , Question. .
runQuestion {b}{typeableDict4b}{showDict4b}
(Simple {a}{typeableDict4a}{showDict4a} message parser) = do
-- so parser :: String -> a
putStrLn message -- ok, as message :: String
ans <- getLine -- ensures ans :: String
return $ parser ans -- has type IO a, not IO b
parser a, Question, b, runQuestion. , , .
, print
print :: forall c. Show c => c -> IO ()
main = getLine >>= (runQuestion . getQuestion) >>= print
main = getLine >>=
(runQuestion {b}{typeableDict4b}{showDict4b} . getQuestion) >>=
print {b}{showDict4b}
runQuestion {b} IO b, , print c , runQuestion b, b, Typeable, Show. Typeable ( runQuestion); Show print .
, - , runQuestion , , - ( ) ,
typeFrom :: Question -> *
typeFrom (Simple {a}{typeableDict4a}{showDict4a} message parser) = a
runQuestion :: (q :: Question) -> IO (typeFrom q)
, , Haskell: ", ". , , , . print , .