├── Setup.hs ├── .gitignore ├── CHANGELOG ├── README.md ├── data-has.cabal ├── LICENSE ├── .travis.yml ├── benchmark └── Main.hs └── Data └── Has.hs /Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | dist-* 3 | cabal-dev 4 | *.o 5 | *.hi 6 | *.chi 7 | *.chs.h 8 | *.dyn_o 9 | *.dyn_hi 10 | .hpc 11 | .hsenv 12 | .cabal-sandbox/ 13 | cabal.sandbox.config 14 | *.prof 15 | *.aux 16 | *.hp 17 | *.eventlog 18 | .stack-work/ 19 | cabal.project.local 20 | .HTF/ 21 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | # v0.4.0.0 2 | 3 | * Add `:*:` type operator and pattern synonym for tuple. 4 | * Drop GHC < 7.10 support. 5 | 6 | # v0.3.0.0 7 | 8 | * Add `hasLens`, thanks @pavelkogan! 9 | 10 | # v0.2.1.0 11 | 12 | * Fix benchmarks. 13 | 14 | # v0.2.0.0 15 | 16 | * Change `get/modify` to `getter/modifier` to reduce naming collision, namely `get/modify` would collide with `MonadState`. 17 | * Add tuple instances up to 12 elements. 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | data-has 2 | ======== 3 | 4 | [![Hackage](https://img.shields.io/hackage/v/data-has.svg?style=flat)](http://hackage.haskell.org/package/data-has) 5 | [![Build Status](https://travis-ci.org/winterland1989/data-has.svg)](https://travis-ci.org/winterland1989/data-has) 6 | 7 | A simple extensible product system, a typical usage is to free you from considering how to layer your monad stack, because your can now extend your monad in one layer: 8 | 9 | ```haskell 10 | {-# LANGUAGE FlexibleContexts #-} 11 | 12 | -- in some library code 13 | ... 14 | logInAnyReaderHasLogger :: (Has Logger r, MonadReader r m) => LogString -> m () 15 | logInAnyReaderHasLogger s = asks getter >>= logWithLogger s 16 | 17 | queryInAnyReaderHasSQL :: (Has SqlBackEnd r, MonadReader r m) => Query -> m a 18 | queryInAnyReaderHasSQL q = asks getter >>= queryWithSQL q 19 | ... 20 | 21 | -- now you want to use these effects together 22 | ... 23 | logger <- initLogger ... 24 | sql <- initSqlBackEnd ... 25 | 26 | (`runReader` (logger, sql)) $ do 27 | ... 28 | logInAnyReaderHasLogger ... 29 | ... 30 | x <- queryInAnyReaderHasSQL ... 31 | ... 32 | ... 33 | ``` 34 | -------------------------------------------------------------------------------- /data-has.cabal: -------------------------------------------------------------------------------- 1 | name: data-has 2 | version: 0.4.0.0 3 | synopsis: Simple extensible product 4 | description: Simple extensible product 5 | license: BSD3 6 | license-file: LICENSE 7 | author: winterland1989 8 | maintainer: winterland1989@gmail.com 9 | -- copyright: 10 | category: Data 11 | build-type: Simple 12 | extra-source-files: README.md, CHANGELOG 13 | cabal-version: >=1.10 14 | homepage: https://github.com/winterland1989/data-has 15 | 16 | source-repository head 17 | type: git 18 | location: git://github.com/winterland1989/data-has.git 19 | 20 | library 21 | exposed-modules: Data.Has 22 | -- other-modules: 23 | -- other-extensions: 24 | build-depends: base >= 4.8 && < 5 25 | 26 | -- hs-source-dirs: 27 | default-language: Haskell2010 28 | 29 | benchmark bench 30 | type: exitcode-stdio-1.0 31 | main-is: Main.hs 32 | hs-source-dirs: benchmark 33 | default-language: Haskell2010 34 | build-depends: base 35 | , data-has 36 | , criterion >= 1.0.2.0 37 | , transformers 38 | 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, winterland1989 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following 13 | disclaimer in the documentation and/or other materials provided 14 | with the distribution. 15 | 16 | * Neither the name of winterland1989 nor the names of other 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # NB: don't set `language: haskell` here 2 | 3 | # explicitly request legacy non-sudo based build environment 4 | sudo: required 5 | 6 | # The following enables several GHC versions to be tested; often it's enough to test only against the last release in a major GHC version. Feel free to omit lines listings versions you don't need/want testing for. 7 | env: 8 | - CABALVER=1.18 GHCVER=7.8.4 9 | - CABALVER=1.22 GHCVER=7.10.2 10 | - CABALVER=1.24 GHCVER=8.0.1 11 | # - CABALVER=head GHCVER=head # see section about GHC HEAD snapshots 12 | 13 | # Note: the distinction between `before_install` and `install` is not important. 14 | before_install: 15 | - travis_retry sudo add-apt-repository -y ppa:hvr/ghc 16 | - travis_retry sudo apt-get update 17 | - travis_retry sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER # see note about happy/alex 18 | - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH 19 | - | 20 | if [ ${GHCVER%.*} = "8.0" ] || [ ${GHCVER%.*} = "7.8" ] || [ ${GHCVER%.*} = "7.10" ]; then 21 | travis_retry sudo apt-get install happy-1.19.4 alex-3.1.3 22 | export PATH=/opt/alex/3.1.3/bin:/opt/happy/1.19.4/bin:$PATH 23 | else 24 | travis_retry sudo apt-get install happy alex 25 | fi 26 | 27 | install: 28 | - cabal --version 29 | - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]" 30 | - travis_retry cabal update 31 | - cabal install --only-dependencies --enable-tests --enable-benchmarks 32 | 33 | # Here starts the actual work to be performed for the package under test; any command which exits with a non-zero exit code causes the build to fail. 34 | script: 35 | - if [ -f configure.ac ]; then autoreconf -i; fi 36 | - cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging 37 | - cabal build # this builds all libraries and executables (including tests/benchmarks) 38 | - cabal test 39 | - cabal bench 40 | - cabal check 41 | - cabal sdist # tests that a source-distribution can be generated 42 | 43 | # Check that the resulting source distribution can be built & installed. 44 | # If there are no other `.tar.gz` files in `dist`, this can be even simpler: 45 | # `cabal install --force-reinstalls dist/*-*.tar.gz` 46 | - SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz && 47 | (cd dist && cabal install --force-reinstalls "$SRC_TGZ") 48 | 49 | -------------------------------------------------------------------------------- /benchmark/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ScopedTypeVariables #-} 2 | {-# LANGUAGE FlexibleContexts #-} 3 | {-# LANGUAGE DataKinds #-} 4 | {-# LANGUAGE KindSignatures #-} 5 | 6 | module Main where 7 | 8 | ------------------------------------------------------------------------------- 9 | 10 | import Control.Monad.Trans.Reader 11 | import Control.Monad.Trans.Class 12 | import Criterion.Main 13 | import Data.Has 14 | import GHC.TypeLits 15 | 16 | main :: IO () 17 | main = defaultMain 18 | [ bgroup "has vs 2 layer reader" 19 | [ bench "has" $ whnf (runReader hasReader) (1 :: Int, "hello" :: String) 20 | , bench "2 layer" $ whnf (\ (i, s) -> runReader (runReaderT multiReader i) s) 21 | (1 :: Int, "hello" :: String) 22 | ] 23 | , bgroup "has vs 8 layer reader" 24 | [ bench "has" $ whnf (runReader hasReader8) 25 | ( T 1 :: T 1 Int 26 | , T 2 :: T 2 Int 27 | , T 3 :: T 3 Int 28 | , T 4 :: T 4 Int 29 | , T 5 :: T 5 Int 30 | , T 6 :: T 6 Int 31 | , T 7 :: T 7 Int 32 | , T 8 :: T 8 Int) 33 | , bench "8 layer" $ whnf (\ (i1, i2, i3, i4, i5, i6, i7, i8) -> 34 | runReader 35 | (runReaderT 36 | (runReaderT 37 | (runReaderT 38 | (runReaderT 39 | (runReaderT 40 | (runReaderT 41 | (runReaderT multiReader8 i1 42 | ) i2) i3) i4) i5) i6) i7) i8 43 | ) (1, 2, 3, 4, 5, 6, 7, 8) 44 | ] 45 | ] 46 | 47 | hasReader :: (Has Int r, Has String r) => Reader r String 48 | hasReader = do 49 | i :: Int <- asks getter 50 | s :: String <- asks getter 51 | return (s ++ show i) 52 | 53 | multiReader :: ReaderT Int (Reader String) String 54 | multiReader = do 55 | i <- ask 56 | s <- lift ask 57 | return (s ++ show i) 58 | 59 | newtype T (a :: Nat) b = T { uT :: b } 60 | 61 | hasReader8 :: ( Has (T 1 Int) r 62 | , Has (T 2 Int) r 63 | , Has (T 3 Int) r 64 | , Has (T 4 Int) r 65 | , Has (T 5 Int) r 66 | , Has (T 6 Int) r 67 | , Has (T 7 Int) r 68 | , Has (T 8 Int) r 69 | ) => Reader r Int 70 | hasReader8 = do 71 | i1 :: T 1 Int <- asks getter 72 | i2 :: T 2 Int <- asks getter 73 | i3 :: T 3 Int <- asks getter 74 | i4 :: T 4 Int <- asks getter 75 | i5 :: T 5 Int <- asks getter 76 | i6 :: T 6 Int <- asks getter 77 | i7 :: T 7 Int <- asks getter 78 | i8 :: T 8 Int <- asks getter 79 | return (uT i1 + uT i2 + uT i3 + uT i4 + uT i5 + uT i6 + uT i7 + uT i8) 80 | 81 | multiReader8 :: ReaderT Int 82 | (ReaderT Int 83 | (ReaderT Int 84 | (ReaderT Int 85 | (ReaderT Int 86 | (ReaderT Int 87 | (ReaderT Int 88 | (Reader Int))))))) Int 89 | multiReader8 = do 90 | i1 <- ask 91 | i2 <- lift ask 92 | i3 <- lift (lift ask) 93 | i4 <- lift (lift (lift ask)) 94 | i5 <- lift (lift (lift (lift ask))) 95 | i6 <- lift (lift (lift (lift (lift ask)))) 96 | i7 <- lift (lift (lift (lift (lift (lift ask))))) 97 | i8 <- lift (lift (lift (lift (lift (lift (lift ask)))))) 98 | return (i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8) 99 | -------------------------------------------------------------------------------- /Data/Has.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE MultiParamTypeClasses #-} 2 | {-# LANGUAGE FlexibleInstances #-} 3 | {-# LANGUAGE RankNTypes #-} 4 | {-# LANGUAGE PatternSynonyms #-} 5 | {-# LANGUAGE TypeOperators #-} 6 | 7 | {-| 8 | Module : Data.Has 9 | Description : Simple extensible product 10 | Copyright : (c) Winterland, 2016 11 | License : BSD 12 | Maintainer : drkoster@qq.com 13 | Stability : experimental 14 | Portability : PORTABLE 15 | 16 | This module provide 'Has' class which provide simple extensible product. 17 | The use case for this class is illustrated as following: 18 | 19 | @ 20 | \{\-\# LANGUAGE FlexibleContexts \#\-\} 21 | 22 | -- in some library code 23 | ... 24 | logInAnyReaderHasLogger :: (Has Logger r, MonadReader r m) => LogString -> m () 25 | logInAnyReaderHasLogger s = asks getter >>= logWithLogger s 26 | 27 | queryInAnyReaderHasSQL :: (Has SqlBackEnd r, MonadReader r m) => Query -> m a 28 | queryInAnyReaderHasSQL q = asks getter >>= queryWithSQL q 29 | ... 30 | 31 | -- now you want to use these effects together 32 | ... 33 | logger <- initLogger ... 34 | sql <- initSqlBackEnd ... 35 | 36 | (\`runReader\` (logger, sql)) $ do 37 | ... 38 | logInAnyReaderHasLogger ... 39 | ... 40 | x <- queryInAnyReaderHasSQL ... 41 | ... 42 | @ 43 | 44 | If you need multiple elements with same type, you can use 45 | like: 46 | 47 | @ 48 | (Has (Tagged \"StdLogger\" Logger) r, Has (Tagged \"FileLogger\" Logger) r, ...) => ... 49 | 50 | runYourMonad ... ( stdLogger :: Tagged \"StdLogger\" Logger 51 | , fileLogger :: Tagged \"FileLogger\" Logger, ...) 52 | @ 53 | 54 | Or you can define newtypes(which is less verbose and require no dependency): 55 | 56 | @ 57 | newtype StdLogger = StdLogger Logger 58 | newtype FileLogger = FileLogger Logger 59 | 60 | runYourMonad ... (StdLogger stdLogger, FileLogger fileLogger) 61 | @ 62 | 63 | Polymorphic values, such as numeric and string literals(with OverloadedString Enabled) 64 | may lead to type inference failure, you simply need type annotations in these cases: 65 | 66 | @ ... (3 :: Int, "hello" :: String, ...) @ 67 | 68 | This module also provide infix type operator and pattern synonym of tuple, i.e. inductive procducts, 69 | which is more convenient to write. An overlapping instance prefer first(left) one is provided: 70 | 71 | @ 72 | > getter (True :*: "hello" :*: 1) :: Integer 73 | > 1 74 | > getter (1 :*: 2 :*: 3) :: Integer 75 | > 1 76 | @ 77 | 78 | -} 79 | 80 | module Data.Has where 81 | 82 | import Data.Functor.Identity ( Identity(Identity, runIdentity) ) 83 | import Control.Applicative ( Const(Const, getConst) ) 84 | 85 | type Lens t a = forall f. Functor f => (a -> f a) -> t -> f t 86 | 87 | -- | Infix version of tuple(right associative). 88 | type a :*: b = (a, b) 89 | 90 | -- | Infix pattern alias for tuple(right associative). 91 | pattern (:*:) :: a -> b -> (a, b) 92 | pattern a :*: b = (a, b) 93 | 94 | infixr 1 :*: 95 | 96 | -- | A type class for extensible product. 97 | -- 98 | -- We provide instances for tuples up to 12 elements by default. 99 | -- You can define your own instance of 'Has', but most of the time tuples will do fine. 100 | -- 101 | class Has a t where 102 | {-# MINIMAL getter, modifier | hasLens #-} 103 | getter :: t -> a 104 | getter = getConst . hasLens Const 105 | 106 | modifier :: (a -> a) -> t -> t 107 | modifier f t = runIdentity (hasLens (Identity . f) t) 108 | 109 | hasLens :: Lens t a 110 | hasLens afa t = (\a -> modifier (const a) t) <$> afa (getter t) 111 | 112 | instance Has a a where 113 | getter = id 114 | {-# INLINABLE getter #-} 115 | modifier = id 116 | {-# INLINABLE modifier #-} 117 | 118 | instance {-# OVERLAPPING #-} Has a (a, b) where 119 | getter (a, _) = a 120 | {-# INLINABLE getter #-} 121 | modifier f (a, b) = (f a, b) 122 | {-# INLINABLE modifier #-} 123 | 124 | instance {-# OVERLAPPABLE #-} Has b bs => Has b (a, bs) where 125 | getter (_, bs) = getter bs 126 | {-# INLINABLE getter #-} 127 | modifier f (a, b) = (a, modifier f b) 128 | {-# INLINABLE modifier #-} 129 | 130 | -------------------------------------------------------------------------------- 131 | 132 | instance Has a (a, b, c) where 133 | getter (a, _, _) = a 134 | {-# INLINABLE getter #-} 135 | modifier f (a, b, c) = (f a, b, c) 136 | {-# INLINABLE modifier #-} 137 | instance Has b (a, b, c) where 138 | getter (_, b, _) = b 139 | {-# INLINABLE getter #-} 140 | modifier f (a, b, c) = (a, f b, c) 141 | {-# INLINABLE modifier #-} 142 | instance Has c (a, b, c) where 143 | getter (_, _, c) = c 144 | {-# INLINABLE getter #-} 145 | modifier f (a, b, c) = (a, b, f c) 146 | {-# INLINABLE modifier #-} 147 | 148 | -------------------------------------------------------------------------------- 149 | 150 | instance Has a (a, b, c, d) where 151 | getter (a, _, _, _) = a 152 | {-# INLINABLE getter #-} 153 | modifier f (a, b, c, d) = (f a, b, c, d) 154 | {-# INLINABLE modifier #-} 155 | instance Has b (a, b, c, d) where 156 | getter (_, b, _, _) = b 157 | {-# INLINABLE getter #-} 158 | modifier f (a, b, c, d) = (a, f b, c, d) 159 | {-# INLINABLE modifier #-} 160 | instance Has c (a, b, c, d) where 161 | getter (_, _, c, _) = c 162 | {-# INLINABLE getter #-} 163 | modifier f (a, b, c, d) = (a, b, f c, d) 164 | {-# INLINABLE modifier #-} 165 | instance Has d (a, b, c, d) where 166 | getter (_, _, _, d) = d 167 | {-# INLINABLE getter #-} 168 | modifier f (a, b, c, d) = (a, b, c, f d) 169 | {-# INLINABLE modifier #-} 170 | 171 | -------------------------------------------------------------------------------- 172 | 173 | instance Has a (a, b, c, d, e) where 174 | getter (a, _, _, _, _) = a 175 | {-# INLINABLE getter #-} 176 | modifier f (a, b, c, d, e) = (f a, b, c, d, e) 177 | {-# INLINABLE modifier #-} 178 | instance Has b (a, b, c, d, e) where 179 | getter (_, b, _, _, _) = b 180 | {-# INLINABLE getter #-} 181 | modifier f (a, b, c, d, e) = (a, f b, c, d, e) 182 | {-# INLINABLE modifier #-} 183 | instance Has c (a, b, c, d, e) where 184 | getter (_, _, c, _, _) = c 185 | {-# INLINABLE getter #-} 186 | modifier f (a, b, c, d, e) = (a, b, f c, d, e) 187 | {-# INLINABLE modifier #-} 188 | instance Has d (a, b, c, d, e) where 189 | getter (_, _, _, d, _) = d 190 | {-# INLINABLE getter #-} 191 | modifier f (a, b, c, d, e) = (a, b, c, f d, e) 192 | {-# INLINABLE modifier #-} 193 | instance Has e (a, b, c, d, e) where 194 | getter (_, _, _, _, e) = e 195 | {-# INLINABLE getter #-} 196 | modifier f (a, b, c, d, e) = (a, b, c, d, f e) 197 | {-# INLINABLE modifier #-} 198 | 199 | -------------------------------------------------------------------------------- 200 | 201 | instance Has a (a, b, c, d, e, f) where 202 | getter (a, _, _, _, _, _) = a 203 | {-# INLINABLE getter #-} 204 | modifier ff (a, b, c, d, e, f) = (ff a, b, c, d, e, f) 205 | {-# INLINABLE modifier #-} 206 | instance Has b (a, b, c, d, e, f) where 207 | getter (_, b, _, _, _, _) = b 208 | {-# INLINABLE getter #-} 209 | modifier ff (a, b, c, d, e, f) = (a, ff b, c, d, e, f) 210 | {-# INLINABLE modifier #-} 211 | instance Has c (a, b, c, d, e, f) where 212 | getter (_, _, c, _, _, _) = c 213 | {-# INLINABLE getter #-} 214 | modifier ff (a, b, c, d, e, f) = (a, b, ff c, d, e, f) 215 | {-# INLINABLE modifier #-} 216 | instance Has d (a, b, c, d, e, f) where 217 | getter (_, _, _, d, _, _) = d 218 | {-# INLINABLE getter #-} 219 | modifier ff (a, b, c, d, e, f) = (a, b, c, ff d, e, f) 220 | {-# INLINABLE modifier #-} 221 | instance Has e (a, b, c, d, e, f) where 222 | getter (_, _, _, _, e, _) = e 223 | {-# INLINABLE getter #-} 224 | modifier ff (a, b, c, d, e, f) = (a, b, c, d, ff e, f) 225 | {-# INLINABLE modifier #-} 226 | instance Has f (a, b, c, d, e, f) where 227 | getter (_, _, _, _, _, f) = f 228 | {-# INLINABLE getter #-} 229 | modifier ff (a, b, c, d, e, f) = (a, b, c, d, e, ff f) 230 | {-# INLINABLE modifier #-} 231 | 232 | -------------------------------------------------------------------------------- 233 | 234 | instance Has a (a, b, c, d, e, f, g) where 235 | getter (a, _, _, _, _, _, _) = a 236 | {-# INLINABLE getter #-} 237 | modifier ff (a, b, c, d, e, f, g) = (ff a, b, c, d, e, f, g) 238 | {-# INLINABLE modifier #-} 239 | instance Has b (a, b, c, d, e, f, g) where 240 | getter (_, b, _, _, _, _, _) = b 241 | {-# INLINABLE getter #-} 242 | modifier ff (a, b, c, d, e, f, g) = (a, ff b, c, d, e, f, g) 243 | {-# INLINABLE modifier #-} 244 | instance Has c (a, b, c, d, e, f, g) where 245 | getter (_, _, c, _, _, _, _) = c 246 | {-# INLINABLE getter #-} 247 | modifier ff (a, b, c, d, e, f, g) = (a, b, ff c, d, e, f, g) 248 | {-# INLINABLE modifier #-} 249 | instance Has d (a, b, c, d, e, f, g) where 250 | getter (_, _, _, d, _, _, _) = d 251 | {-# INLINABLE getter #-} 252 | modifier ff (a, b, c, d, e, f, g) = (a, b, c, ff d, e, f, g) 253 | {-# INLINABLE modifier #-} 254 | instance Has e (a, b, c, d, e, f, g) where 255 | getter (_, _, _, _, e, _, _) = e 256 | {-# INLINABLE getter #-} 257 | modifier ff (a, b, c, d, e, f, g) = (a, b, c, d, ff e, f, g) 258 | {-# INLINABLE modifier #-} 259 | instance Has f (a, b, c, d, e, f, g) where 260 | getter (_, _, _, _, _, f, _) = f 261 | {-# INLINABLE getter #-} 262 | modifier ff (a, b, c, d, e, f, g) = (a, b, c, d, e, ff f, g) 263 | {-# INLINABLE modifier #-} 264 | instance Has g (a, b, c, d, e, f, g) where 265 | getter (_, _, _, _, _, _, g) = g 266 | {-# INLINABLE getter #-} 267 | modifier ff (a, b, c, d, e, f, g) = (a, b, c, d, e, f, ff g) 268 | {-# INLINABLE modifier #-} 269 | 270 | -------------------------------------------------------------------------------- 271 | 272 | instance Has a (a, b, c, d, e, f, g, h) where 273 | getter (a, _, _, _, _, _, _, _) = a 274 | {-# INLINABLE getter #-} 275 | modifier ff (a, b, c, d, e, f, g, h) = (ff a, b, c, d, e, f, g, h) 276 | {-# INLINABLE modifier #-} 277 | instance Has b (a, b, c, d, e, f, g, h) where 278 | getter (_, b, _, _, _, _, _, _) = b 279 | {-# INLINABLE getter #-} 280 | modifier ff (a, b, c, d, e, f, g, h) = (a, ff b, c, d, e, f, g, h) 281 | {-# INLINABLE modifier #-} 282 | instance Has c (a, b, c, d, e, f, g, h) where 283 | getter (_, _, c, _, _, _, _, _) = c 284 | {-# INLINABLE getter #-} 285 | modifier ff (a, b, c, d, e, f, g, h) = (a, b, ff c, d, e, f, g, h) 286 | {-# INLINABLE modifier #-} 287 | instance Has d (a, b, c, d, e, f, g, h) where 288 | getter (_, _, _, d, _, _, _, _) = d 289 | {-# INLINABLE getter #-} 290 | modifier ff (a, b, c, d, e, f, g, h) = (a, b, c, ff d, e, f, g, h) 291 | {-# INLINABLE modifier #-} 292 | instance Has e (a, b, c, d, e, f, g, h) where 293 | getter (_, _, _, _, e, _, _, _) = e 294 | {-# INLINABLE getter #-} 295 | modifier ff (a, b, c, d, e, f, g, h) = (a, b, c, d, ff e, f, g, h) 296 | {-# INLINABLE modifier #-} 297 | instance Has f (a, b, c, d, e, f, g, h) where 298 | getter (_, _, _, _, _, f, _, _) = f 299 | {-# INLINABLE getter #-} 300 | modifier ff (a, b, c, d, e, f, g, h) = (a, b, c, d, e, ff f, g, h) 301 | {-# INLINABLE modifier #-} 302 | instance Has g (a, b, c, d, e, f, g, h) where 303 | getter (_, _, _, _, _, _, g, _) = g 304 | {-# INLINABLE getter #-} 305 | modifier ff (a, b, c, d, e, f, g, h) = (a, b, c, d, e, f, ff g, h) 306 | {-# INLINABLE modifier #-} 307 | instance Has h (a, b, c, d, e, f, g, h) where 308 | getter (_, _, _, _, _, _, _, h) = h 309 | {-# INLINABLE getter #-} 310 | modifier ff (a, b, c, d, e, f, g, h) = (a, b, c, d, e, f, g, ff h) 311 | {-# INLINABLE modifier #-} 312 | 313 | -------------------------------------------------------------------------------- 314 | 315 | instance Has a (a, b, c, d, e, f, g, h, i) where 316 | getter (a, _, _, _, _, _, _, _, _) = a 317 | {-# INLINABLE getter #-} 318 | modifier ff (a, b, c, d, e, f, g, h, i) = (ff a, b, c, d, e, f, g, h, i) 319 | {-# INLINABLE modifier #-} 320 | instance Has b (a, b, c, d, e, f, g, h, i) where 321 | getter (_, b, _, _, _, _, _, _, _) = b 322 | {-# INLINABLE getter #-} 323 | modifier ff (a, b, c, d, e, f, g, h, i) = (a, ff b, c, d, e, f, g, h, i) 324 | {-# INLINABLE modifier #-} 325 | instance Has c (a, b, c, d, e, f, g, h, i) where 326 | getter (_, _, c, _, _, _, _, _, _) = c 327 | {-# INLINABLE getter #-} 328 | modifier ff (a, b, c, d, e, f, g, h, i) = (a, b, ff c, d, e, f, g, h, i) 329 | {-# INLINABLE modifier #-} 330 | instance Has d (a, b, c, d, e, f, g, h, i) where 331 | getter (_, _, _, d, _, _, _, _, _) = d 332 | {-# INLINABLE getter #-} 333 | modifier ff (a, b, c, d, e, f, g, h, i) = (a, b, c, ff d, e, f, g, h, i) 334 | {-# INLINABLE modifier #-} 335 | instance Has e (a, b, c, d, e, f, g, h, i) where 336 | getter (_, _, _, _, e, _, _, _, _) = e 337 | {-# INLINABLE getter #-} 338 | modifier ff (a, b, c, d, e, f, g, h, i) = (a, b, c, d, ff e, f, g, h, i) 339 | {-# INLINABLE modifier #-} 340 | instance Has f (a, b, c, d, e, f, g, h, i) where 341 | getter (_, _, _, _, _, f, _, _, _) = f 342 | {-# INLINABLE getter #-} 343 | modifier ff (a, b, c, d, e, f, g, h, i) = (a, b, c, d, e, ff f, g, h, i) 344 | {-# INLINABLE modifier #-} 345 | instance Has g (a, b, c, d, e, f, g, h, i) where 346 | getter (_, _, _, _, _, _, g, _, _) = g 347 | {-# INLINABLE getter #-} 348 | modifier ff (a, b, c, d, e, f, g, h, i) = (a, b, c, d, e, f, ff g, h, i) 349 | {-# INLINABLE modifier #-} 350 | instance Has h (a, b, c, d, e, f, g, h, i) where 351 | getter (_, _, _, _, _, _, _, h, _) = h 352 | {-# INLINABLE getter #-} 353 | modifier ff (a, b, c, d, e, f, g, h, i) = (a, b, c, d, e, f, g, ff h, i) 354 | {-# INLINABLE modifier #-} 355 | instance Has i (a, b, c, d, e, f, g, h, i) where 356 | getter (_, _, _, _, _, _, _, _, i) = i 357 | {-# INLINABLE getter #-} 358 | modifier ff (a, b, c, d, e, f, g, h, i) = (a, b, c, d, e, f, g, h, ff i) 359 | {-# INLINABLE modifier #-} 360 | 361 | -------------------------------------------------------------------------------- 362 | 363 | instance Has a (a, b, c, d, e, f, g, h, i, j) where 364 | getter (a, _, _, _, _, _, _, _, _, _) = a 365 | {-# INLINABLE getter #-} 366 | modifier ff (a, b, c, d, e, f, g, h, i, j) = (ff a, b, c, d, e, f, g, h, i, j) 367 | {-# INLINABLE modifier #-} 368 | instance Has b (a, b, c, d, e, f, g, h, i, j) where 369 | getter (_, b, _, _, _, _, _, _, _, _) = b 370 | {-# INLINABLE getter #-} 371 | modifier ff (a, b, c, d, e, f, g, h, i, j) = (a, ff b, c, d, e, f, g, h, i, j) 372 | {-# INLINABLE modifier #-} 373 | instance Has c (a, b, c, d, e, f, g, h, i, j) where 374 | getter (_, _, c, _, _, _, _, _, _, _) = c 375 | {-# INLINABLE getter #-} 376 | modifier ff (a, b, c, d, e, f, g, h, i, j) = (a, b, ff c, d, e, f, g, h, i, j) 377 | {-# INLINABLE modifier #-} 378 | instance Has d (a, b, c, d, e, f, g, h, i, j) where 379 | getter (_, _, _, d, _, _, _, _, _, _) = d 380 | {-# INLINABLE getter #-} 381 | modifier ff (a, b, c, d, e, f, g, h, i, j) = (a, b, c, ff d, e, f, g, h, i, j) 382 | {-# INLINABLE modifier #-} 383 | instance Has e (a, b, c, d, e, f, g, h, i, j) where 384 | getter (_, _, _, _, e, _, _, _, _, _) = e 385 | {-# INLINABLE getter #-} 386 | modifier ff (a, b, c, d, e, f, g, h, i, j) = (a, b, c, d, ff e, f, g, h, i, j) 387 | {-# INLINABLE modifier #-} 388 | instance Has f (a, b, c, d, e, f, g, h, i, j) where 389 | getter (_, _, _, _, _, f, _, _, _, _) = f 390 | {-# INLINABLE getter #-} 391 | modifier ff (a, b, c, d, e, f, g, h, i, j) = (a, b, c, d, e, ff f, g, h, i, j) 392 | {-# INLINABLE modifier #-} 393 | instance Has g (a, b, c, d, e, f, g, h, i, j) where 394 | getter (_, _, _, _, _, _, g, _, _, _) = g 395 | {-# INLINABLE getter #-} 396 | modifier ff (a, b, c, d, e, f, g, h, i, j) = (a, b, c, d, e, f, ff g, h, i, j) 397 | {-# INLINABLE modifier #-} 398 | instance Has h (a, b, c, d, e, f, g, h, i, j) where 399 | getter (_, _, _, _, _, _, _, h, _, _) = h 400 | {-# INLINABLE getter #-} 401 | modifier ff (a, b, c, d, e, f, g, h, i, j) = (a, b, c, d, e, f, g, ff h, i, j) 402 | {-# INLINABLE modifier #-} 403 | instance Has i (a, b, c, d, e, f, g, h, i, j) where 404 | getter (_, _, _, _, _, _, _, _, i, _) = i 405 | {-# INLINABLE getter #-} 406 | modifier ff (a, b, c, d, e, f, g, h, i, j) = (a, b, c, d, e, f, g, h, ff i, j) 407 | {-# INLINABLE modifier #-} 408 | instance Has j (a, b, c, d, e, f, g, h, i, j) where 409 | getter (_, _, _, _, _, _, _, _, _, j) = j 410 | {-# INLINABLE getter #-} 411 | modifier ff (a, b, c, d, e, f, g, h, i, j) = (a, b, c, d, e, f, g, h, i, ff j) 412 | {-# INLINABLE modifier #-} 413 | 414 | -------------------------------------------------------------------------------- 415 | 416 | instance Has a (a, b, c, d, e, f, g, h, i, j, k) where 417 | getter (a, _, _, _, _, _, _, _, _, _, _) = a 418 | {-# INLINABLE getter #-} 419 | modifier ff (a, b, c, d, e, f, g, h, i, j, k) = (ff a, b, c, d, e, f, g, h, i, j, k) 420 | {-# INLINABLE modifier #-} 421 | instance Has b (a, b, c, d, e, f, g, h, i, j, k) where 422 | getter (_, b, _, _, _, _, _, _, _, _, _) = b 423 | {-# INLINABLE getter #-} 424 | modifier ff (a, b, c, d, e, f, g, h, i, j, k) = (a, ff b, c, d, e, f, g, h, i, j, k) 425 | {-# INLINABLE modifier #-} 426 | instance Has c (a, b, c, d, e, f, g, h, i, j, k) where 427 | getter (_, _, c, _, _, _, _, _, _, _, _) = c 428 | {-# INLINABLE getter #-} 429 | modifier ff (a, b, c, d, e, f, g, h, i, j, k) = (a, b, ff c, d, e, f, g, h, i, j, k) 430 | {-# INLINABLE modifier #-} 431 | instance Has d (a, b, c, d, e, f, g, h, i, j, k) where 432 | getter (_, _, _, d, _, _, _, _, _, _, _) = d 433 | {-# INLINABLE getter #-} 434 | modifier ff (a, b, c, d, e, f, g, h, i, j, k) = (a, b, c, ff d, e, f, g, h, i, j, k) 435 | {-# INLINABLE modifier #-} 436 | instance Has e (a, b, c, d, e, f, g, h, i, j, k) where 437 | getter (_, _, _, _, e, _, _, _, _, _, _) = e 438 | {-# INLINABLE getter #-} 439 | modifier ff (a, b, c, d, e, f, g, h, i, j, k) = (a, b, c, d, ff e, f, g, h, i, j, k) 440 | {-# INLINABLE modifier #-} 441 | instance Has f (a, b, c, d, e, f, g, h, i, j, k) where 442 | getter (_, _, _, _, _, f, _, _, _, _, _) = f 443 | {-# INLINABLE getter #-} 444 | modifier ff (a, b, c, d, e, f, g, h, i, j, k) = (a, b, c, d, e, ff f, g, h, i, j, k) 445 | {-# INLINABLE modifier #-} 446 | instance Has g (a, b, c, d, e, f, g, h, i, j, k) where 447 | getter (_, _, _, _, _, _, g, _, _, _, _) = g 448 | {-# INLINABLE getter #-} 449 | modifier ff (a, b, c, d, e, f, g, h, i, j, k) = (a, b, c, d, e, f, ff g, h, i, j, k) 450 | {-# INLINABLE modifier #-} 451 | instance Has h (a, b, c, d, e, f, g, h, i, j, k) where 452 | getter (_, _, _, _, _, _, _, h, _, _, _) = h 453 | {-# INLINABLE getter #-} 454 | modifier ff (a, b, c, d, e, f, g, h, i, j, k) = (a, b, c, d, e, f, g, ff h, i, j, k) 455 | {-# INLINABLE modifier #-} 456 | instance Has i (a, b, c, d, e, f, g, h, i, j, k) where 457 | getter (_, _, _, _, _, _, _, _, i, _, _) = i 458 | {-# INLINABLE getter #-} 459 | modifier ff (a, b, c, d, e, f, g, h, i, j, k) = (a, b, c, d, e, f, g, h, ff i, j, k) 460 | {-# INLINABLE modifier #-} 461 | instance Has j (a, b, c, d, e, f, g, h, i, j, k) where 462 | getter (_, _, _, _, _, _, _, _, _, j, _) = j 463 | {-# INLINABLE getter #-} 464 | modifier ff (a, b, c, d, e, f, g, h, i, j, k) = (a, b, c, d, e, f, g, h, i, ff j, k) 465 | {-# INLINABLE modifier #-} 466 | instance Has k (a, b, c, d, e, f, g, h, i, j, k) where 467 | getter (_, _, _, _, _, _, _, _, _, _, k) = k 468 | {-# INLINABLE getter #-} 469 | modifier ff (a, b, c, d, e, f, g, h, i, j, k) = (a, b, c, d, e, f, g, h, i, j, ff k) 470 | {-# INLINABLE modifier #-} 471 | 472 | -------------------------------------------------------------------------------- 473 | 474 | instance Has a (a, b, c, d, e, f, g, h, i, j, k, l) where 475 | getter (a, _, _, _, _, _, _, _, _, _, _, _) = a 476 | {-# INLINABLE getter #-} 477 | modifier ff (a, b, c, d, e, f, g, h, i, j, k, l) = (ff a, b, c, d, e, f, g, h, i, j, k, l) 478 | {-# INLINABLE modifier #-} 479 | instance Has b (a, b, c, d, e, f, g, h, i, j, k, l) where 480 | getter (_, b, _, _, _, _, _, _, _, _, _, _) = b 481 | {-# INLINABLE getter #-} 482 | modifier ff (a, b, c, d, e, f, g, h, i, j, k, l) = (a, ff b, c, d, e, f, g, h, i, j, k, l) 483 | {-# INLINABLE modifier #-} 484 | instance Has c (a, b, c, d, e, f, g, h, i, j, k, l) where 485 | getter (_, _, c, _, _, _, _, _, _, _, _, _) = c 486 | {-# INLINABLE getter #-} 487 | modifier ff (a, b, c, d, e, f, g, h, i, j, k, l) = (a, b, ff c, d, e, f, g, h, i, j, k, l) 488 | {-# INLINABLE modifier #-} 489 | instance Has d (a, b, c, d, e, f, g, h, i, j, k, l) where 490 | getter (_, _, _, d, _, _, _, _, _, _, _, _) = d 491 | {-# INLINABLE getter #-} 492 | modifier ff (a, b, c, d, e, f, g, h, i, j, k, l) = (a, b, c, ff d, e, f, g, h, i, j, k, l) 493 | {-# INLINABLE modifier #-} 494 | instance Has e (a, b, c, d, e, f, g, h, i, j, k, l) where 495 | getter (_, _, _, _, e, _, _, _, _, _, _, _) = e 496 | {-# INLINABLE getter #-} 497 | modifier ff (a, b, c, d, e, f, g, h, i, j, k, l) = (a, b, c, d, ff e, f, g, h, i, j, k, l) 498 | {-# INLINABLE modifier #-} 499 | instance Has f (a, b, c, d, e, f, g, h, i, j, k, l) where 500 | getter (_, _, _, _, _, f, _, _, _, _, _, _) = f 501 | {-# INLINABLE getter #-} 502 | modifier ff (a, b, c, d, e, f, g, h, i, j, k, l) = (a, b, c, d, e, ff f, g, h, i, j, k, l) 503 | {-# INLINABLE modifier #-} 504 | instance Has g (a, b, c, d, e, f, g, h, i, j, k, l) where 505 | getter (_, _, _, _, _, _, g, _, _, _, _, _) = g 506 | {-# INLINABLE getter #-} 507 | modifier ff (a, b, c, d, e, f, g, h, i, j, k, l) = (a, b, c, d, e, f, ff g, h, i, j, k, l) 508 | {-# INLINABLE modifier #-} 509 | instance Has h (a, b, c, d, e, f, g, h, i, j, k, l) where 510 | getter (_, _, _, _, _, _, _, h, _, _, _, _) = h 511 | {-# INLINABLE getter #-} 512 | modifier ff (a, b, c, d, e, f, g, h, i, j, k, l) = (a, b, c, d, e, f, g, ff h, i, j, k, l) 513 | {-# INLINABLE modifier #-} 514 | instance Has i (a, b, c, d, e, f, g, h, i, j, k, l) where 515 | getter (_, _, _, _, _, _, _, _, i, _, _, _) = i 516 | {-# INLINABLE getter #-} 517 | modifier ff (a, b, c, d, e, f, g, h, i, j, k, l) = (a, b, c, d, e, f, g, h, ff i, j, k, l) 518 | {-# INLINABLE modifier #-} 519 | instance Has j (a, b, c, d, e, f, g, h, i, j, k, l) where 520 | getter (_, _, _, _, _, _, _, _, _, j, _, _) = j 521 | {-# INLINABLE getter #-} 522 | modifier ff (a, b, c, d, e, f, g, h, i, j, k, l) = (a, b, c, d, e, f, g, h, i, ff j, k, l) 523 | {-# INLINABLE modifier #-} 524 | instance Has k (a, b, c, d, e, f, g, h, i, j, k, l) where 525 | getter (_, _, _, _, _, _, _, _, _, _, k, _) = k 526 | {-# INLINABLE getter #-} 527 | modifier ff (a, b, c, d, e, f, g, h, i, j, k, l) = (a, b, c, d, e, f, g, h, i, j, ff k, l) 528 | {-# INLINABLE modifier #-} 529 | instance Has l (a, b, c, d, e, f, g, h, i, j, k, l) where 530 | getter (_, _, _, _, _, _, _, _, _, _, _, l) = l 531 | {-# INLINABLE getter #-} 532 | modifier ff (a, b, c, d, e, f, g, h, i, j, k, l) = (a, b, c, d, e, f, g, h, i, j, k, ff l) 533 | {-# INLINABLE modifier #-} 534 | --------------------------------------------------------------------------------