1{-# LANGUAGE TypeFamilies #-}
2{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE EmptyDataDecls #-}
4{-# LANGUAGE TemplateHaskell #-}
5{-# LANGUAGE ConstraintKinds #-}
9import Control.Monad.Ether.Reader
12import Data.Functor.Identity
15import Test.Tasty.QuickCheck
16import Test.QuickCheck.Function
18etherealReader "AmountTag" "runAmountT" "askAmount" ''Int
19type MonadAmount = MonadEtherReader AmountTag
21etherealReader "CountTag" "runCountT" "askCount" ''Integer
22type MonadCount = MonadEtherReader CountTag
25main = defaultMain suite
28suite = testGroup "Ether"
29 [ testGroup "EtherReaderT"
30 [ testProperty "layered sum (local left)" layeredLocalLeft
31 , testProperty "layered sum (local right)" layeredLocalRight
35layeredLocalLeft, layeredLocalRight
36 :: Fun (Int, Integer) Integer -> Fun Integer Integer -> Int -> Integer -> Property
38layeredLocalLeft k f a1 a2 = property (direct == indirect)
40 run = runIdentity . flip runAmountT a1 . flip runCountT a2
41 direct = apply k (fromIntegral a1, apply f a2)
42 indirect = run $ layeredLocalCore (apply f) (\n m -> apply k (fromIntegral n, m))
44layeredLocalRight k f a1 a2 = property (direct == indirect)
46 run = runIdentity . flip runCountT a2 . flip runAmountT a1
47 direct = apply k (fromIntegral a1, apply f a2)
48 indirect = run $ layeredLocalCore (apply f) (\n m -> apply k (fromIntegral n, m))
51 :: (MonadAmount m, MonadCount m)
52 => (Integer -> Integer) -> (Int -> Integer -> a) -> m a
53layeredLocalCore f g = do
55 m <- etherLocal (Proxy :: Proxy CountTag) f askCount
58-- this should not compile
60z = runAmountT (runAmountT (runAmountT askAmount 20) 10) 5
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list