Last active
December 14, 2015 11:39
-
-
Save jhickner/5081100 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE RecordWildCards #-} | |
import Data.Monoid | |
data SalaryConfig = SalaryConfig | |
{ sAllowances :: Bool | |
, sBonus :: Bool | |
, sTax :: Bool | |
, sSurcharge :: Bool | |
} | |
defaultConfig = SalaryConfig True True True True | |
salary :: SalaryConfig -> Double -> Double | |
salary SalaryConfig{..} = appEndo fns | |
where fns = mconcat $ zipWith (\p fn -> if p then Endo fn else mempty) | |
[sAllowances, sBonus, sTax, sSurcharge] | |
[(*1.2), (*1.1), (*0.7), (*0.9)] | |
-- salary defaultConfig 20 -- 16.632 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment