Skip to content

Instantly share code, notes, and snippets.

@gatlin
Last active December 29, 2015 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gatlin/7632557 to your computer and use it in GitHub Desktop.
Save gatlin/7632557 to your computer and use it in GitHub Desktop.
A point-free (pointless?) little program to calculate how much to invoice clients to get a desired amount after Stripe's fees.
module Main where
import System.Environment
main :: IO ()
main = getArgs >>= parse >>= display . roundMoney . charge
charge :: Fractional a => a -> a
charge = (/ 0.971) . (+ 0.3)
display :: Show a => a -> IO ()
display = putStrLn . show
parse :: (Monad m, Read b) => [String] -> m b
parse = return . read . flip (!!) 0
roundMoney :: RealFrac f => f -> f
roundMoney = (/ 10.0 ^^ 2) . fromInteger . round . (100 *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment