Advertisement
Guest User

Untitled

a guest
Feb 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Lib
  2.     ( someFunc
  3.     ) where
  4.  
  5.  
  6. data (Show e) => Resource e a
  7.     = NotFetched
  8.     | Loading
  9.     | Loaded a
  10.     | Error e
  11.  
  12.  
  13. data Question =
  14.     Question
  15.     { askedAt :: String
  16.     , text :: String
  17.     }
  18.  
  19.  
  20. someFunc :: IO ()
  21. someFunc = do
  22.     let question = Loading
  23.     putStrLn $ viewQuestion question
  24.  
  25.  
  26. viewQuestion :: (Show e) => Resource e Question -> String
  27. viewQuestion NotFetched =
  28.     "Loading..."
  29. viewQuestion Loading =
  30.     "Loading..."
  31. viewQuestion (Loaded Question { askedAt = ask, text = txt }) =
  32.     "Asked at " ++ ask ++ "\n" ++ txt
  33. viewQuestion (Error err) =
  34.     "ERROR: " ++ (show err)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement