module Data.Has where
class Has a t where
get :: t -> a
modify :: (a -> a) -> t -> t
instance Has a a where
get = id
modify = id
instance Has a (a, b) where
get (a, _) = a
modify f (a, b) = (f a, b)
instance Has b (a, b) where
get (_, b) = b
modify f (a, b) = (a, f b)
instance Has a (a, b, c) where
get (a, _, _) = a
modify f (a, b, c) = (f a, b, c)
instance Has b (a, b, c) where
get (_, b, _) = b
modify f (a, b, c) = (a, f b, c)
instance Has c (a, b, c) where
get (_, _, c) = c
modify f (a, b, c) = (a, b, f c)
instance Has a (a, b, c, d) where
get (a, _, _, _) = a
modify f (a, b, c, d) = (f a, b, c, d)
instance Has b (a, b, c, d) where
get (_, b, _, _) = b
modify f (a, b, c, d) = (a, f b, c, d)
instance Has c (a, b, c, d) where
get (_, _, c, _) = c
modify f (a, b, c, d) = (a, b, f c, d)
instance Has d (a, b, c, d) where
get (_, _, _, d) = d
modify f (a, b, c, d) = (a, b, c, f d)
instance Has a (a, b, c, d, e) where
get (a, _, _, _, _) = a
modify f (a, b, c, d, e) = (f a, b, c, d, e)
instance Has b (a, b, c, d, e) where
get (_, b, _, _, _) = b
modify f (a, b, c, d, e) = (a, f b, c, d, e)
instance Has c (a, b, c, d, e) where
get (_, _, c, _, _) = c
modify f (a, b, c, d, e) = (a, b, f c, d, e)
instance Has d (a, b, c, d, e) where
get (_, _, _, d, _) = d
modify f (a, b, c, d, e) = (a, b, c, f d, e)
instance Has e (a, b, c, d, e) where
get (_, _, _, _, e) = e
modify f (a, b, c, d, e) = (a, b, c, d, f e)
instance Has a (a, b, c, d, e, f) where
get (a, _, _, _, _, _) = a
modify ff (a, b, c, d, e, f) = (ff a, b, c, d, e, f)
instance Has b (a, b, c, d, e, f) where
get (_, b, _, _, _, _) = b
modify ff (a, b, c, d, e, f) = (a, ff b, c, d, e, f)
instance Has c (a, b, c, d, e, f) where
get (_, _, c, _, _, _) = c
modify ff (a, b, c, d, e, f) = (a, b, ff c, d, e, f)
instance Has d (a, b, c, d, e, f) where
get (_, _, _, d, _, _) = d
modify ff (a, b, c, d, e, f) = (a, b, c, ff d, e, f)
instance Has e (a, b, c, d, e, f) where
get (_, _, _, _, e, _) = e
modify ff (a, b, c, d, e, f) = (a, b, c, d, ff e, f)
instance Has f (a, b, c, d, e, f) where
get (_, _, _, _, _, f) = f
modify ff (a, b, c, d, e, f) = (a, b, c, d, e, ff f)
instance Has a (a, b, c, d, e, f, g) where
get (a, _, _, _, _, _, _) = a
modify ff (a, b, c, d, e, f, g) = (ff a, b, c, d, e, f, g)
instance Has b (a, b, c, d, e, f, g) where
get (_, b, _, _, _, _, _) = b
modify ff (a, b, c, d, e, f, g) = (a, ff b, c, d, e, f, g)
instance Has c (a, b, c, d, e, f, g) where
get (_, _, c, _, _, _, _) = c
modify ff (a, b, c, d, e, f, g) = (a, b, ff c, d, e, f, g)
instance Has d (a, b, c, d, e, f, g) where
get (_, _, _, d, _, _, _) = d
modify ff (a, b, c, d, e, f, g) = (a, b, c, ff d, e, f, g)
instance Has e (a, b, c, d, e, f, g) where
get (_, _, _, _, e, _, _) = e
modify ff (a, b, c, d, e, f, g) = (a, b, c, d, ff e, f, g)
instance Has f (a, b, c, d, e, f, g) where
get (_, _, _, _, _, f, _) = f
modify ff (a, b, c, d, e, f, g) = (a, b, c, d, e, ff f, g)
instance Has g (a, b, c, d, e, f, g) where
get (_, _, _, _, _, _, g) = g
modify ff (a, b, c, d, e, f, g) = (a, b, c, d, e, f, ff g)
instance Has a (a, b, c, d, e, f, g, h) where
get (a, _, _, _, _, _, _, _) = a
modify ff (a, b, c, d, e, f, g, h) = (ff a, b, c, d, e, f, g, h)
instance Has b (a, b, c, d, e, f, g, h) where
get (_, b, _, _, _, _, _, _) = b
modify ff (a, b, c, d, e, f, g, h) = (a, ff b, c, d, e, f, g, h)
instance Has c (a, b, c, d, e, f, g, h) where
get (_, _, c, _, _, _, _, _) = c
modify ff (a, b, c, d, e, f, g, h) = (a, b, ff c, d, e, f, g, h)
instance Has d (a, b, c, d, e, f, g, h) where
get (_, _, _, d, _, _, _, _) = d
modify ff (a, b, c, d, e, f, g, h) = (a, b, c, ff d, e, f, g, h)
instance Has e (a, b, c, d, e, f, g, h) where
get (_, _, _, _, e, _, _, _) = e
modify ff (a, b, c, d, e, f, g, h) = (a, b, c, d, ff e, f, g, h)
instance Has f (a, b, c, d, e, f, g, h) where
get (_, _, _, _, _, f, _, _) = f
modify ff (a, b, c, d, e, f, g, h) = (a, b, c, d, e, ff f, g, h)
instance Has g (a, b, c, d, e, f, g, h) where
get (_, _, _, _, _, _, g, _) = g
modify ff (a, b, c, d, e, f, g, h) = (a, b, c, d, e, f, ff g, h)
instance Has h (a, b, c, d, e, f, g, h) where
get (_, _, _, _, _, _, _, h) = h
modify ff (a, b, c, d, e, f, g, h) = (a, b, c, d, e, f, g, ff h)