2016-06-23 23:19:51 +03:00
|
|
|
{-# LANGUAGE DataKinds, GeneralizedNewtypeDeriving #-}
|
2016-07-29 21:31:15 +03:00
|
|
|
module Info (Range(..), characterRange, setCharacterRange, Category(..), category, setCategory, Cost(..), cost, setCost) where
|
2016-03-31 00:26:52 +03:00
|
|
|
|
2016-06-17 17:26:20 +03:00
|
|
|
import Data.Record
|
2016-05-26 19:58:04 +03:00
|
|
|
import Prologue
|
2016-03-31 00:26:52 +03:00
|
|
|
import Category
|
|
|
|
import Range
|
2016-07-13 22:30:37 +03:00
|
|
|
import Test.QuickCheck
|
2016-03-31 00:26:52 +03:00
|
|
|
|
2016-08-18 17:52:49 +03:00
|
|
|
newtype Cost = Cost { unCost :: Int }
|
2016-06-30 19:47:21 +03:00
|
|
|
deriving (Eq, Num, Ord, Show)
|
2016-06-17 17:26:20 +03:00
|
|
|
|
2016-06-17 20:33:50 +03:00
|
|
|
characterRange :: HasField fields Range => Record fields -> Range
|
|
|
|
characterRange = getField
|
2016-06-17 17:26:20 +03:00
|
|
|
|
2016-06-17 21:07:21 +03:00
|
|
|
setCharacterRange :: HasField fields Range => Record fields -> Range -> Record fields
|
2016-06-17 20:33:50 +03:00
|
|
|
setCharacterRange = setField
|
2016-06-17 17:29:24 +03:00
|
|
|
|
2016-06-17 20:33:50 +03:00
|
|
|
category :: HasField fields Category => Record fields -> Category
|
|
|
|
category = getField
|
2016-06-17 17:26:20 +03:00
|
|
|
|
2016-06-17 21:07:21 +03:00
|
|
|
setCategory :: HasField fields Category => Record fields -> Category -> Record fields
|
2016-06-17 20:33:50 +03:00
|
|
|
setCategory = setField
|
2016-06-17 17:29:24 +03:00
|
|
|
|
2016-06-17 20:33:50 +03:00
|
|
|
cost :: HasField fields Cost => Record fields -> Cost
|
|
|
|
cost = getField
|
2016-06-17 17:26:20 +03:00
|
|
|
|
2016-06-17 21:07:21 +03:00
|
|
|
setCost :: HasField fields Cost => Record fields -> Cost -> Record fields
|
2016-06-17 20:33:50 +03:00
|
|
|
setCost = setField
|
2016-07-13 22:30:37 +03:00
|
|
|
|
|
|
|
|
|
|
|
-- Instances
|
|
|
|
|
|
|
|
instance Arbitrary Cost where
|
|
|
|
arbitrary = Cost <$> arbitrary
|
|
|
|
|
|
|
|
shrink = fmap Cost . shrink . unCost
|