4YZYDSDVJFE7RB47LPOUIOQ3U5XBTSJ53UG4TY42VXZI7O3NX7AAC
main = do
let inc = PosMoney @"SEK" $ unsafePos "" 15_550
r = defaultRule
main = runInputT defaultSettings go
where
go :: InputT IO ()
go = do
input <- readInput "Income: " (readEither @Int)
case input of
Left x -> liftIO $ hPutStrLn stderr ("An error occurred: " ++ x)
Right x -> do
let income = mkIncome x
liftIO $ print income
print $ calculate r inc
readInput :: String -> (String -> Either String b) -> InputT IO (Either String b)
readInput prompt f = do
input <- getInputLine prompt
case input of
Nothing -> return $ Left "Input Interrupted"
Just x -> return $ f x
mkIncome :: Int -> Either String (PosMoney "USD")
mkIncome input = eitherPos input >>= return . PosMoney @"USD"