Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Lib
- ( someFunc
- ) where
- data (Show e) => Resource e a
- = NotFetched
- | Loading
- | Loaded a
- | Error e
- data Question =
- Question
- { askedAt :: String
- , text :: String
- }
- someFunc :: IO ()
- someFunc = do
- let question = Loading
- putStrLn $ viewQuestion question
- viewQuestion :: (Show e) => Resource e Question -> String
- viewQuestion NotFetched =
- "Loading..."
- viewQuestion Loading =
- "Loading..."
- viewQuestion (Loaded Question { askedAt = ask, text = txt }) =
- "Asked at " ++ ask ++ "\n" ++ txt
- viewQuestion (Error err) =
- "ERROR: " ++ (show err)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement