appl1 :: (a -> t) -> a -> t
appl1 = id
appl2 :: (a -> b -> t) -> (a, b) -> t
appl2 f (a, b) = appl1 (f a) b
appl3 :: (a -> b -> c -> t) -> (a, (b, c)) -> t
appl3 f (a, b) = appl2 (f a) b
appl4 :: (a -> b -> c -> d -> t) -> (a, (b, (c, d))) -> t
appl4 f (a, b) = appl3 (f a) b
appl5 f (a, b) = appl4 (f a) b
appl6 f (a, b) = appl5 (f a) b
-- etc
appr1 :: (a -> t) -> a -> t
appr1 = id
appr2 :: (a -> b -> t) -> (b, a) -> t
appr2 f (n, rs) = appr1 f rs n
appr3 :: (a -> b -> c -> t) -> (c, (b, a)) -> t
appr3 f (n, rs) = appr2 f rs n
appr4 :: (a -> b -> c -> d -> t) -> (d, (c, (b, a))) -> t
appr4 f (n, rs) = appr3 f rs n
appr5 f (n, rs) = appr4 f rs n
appr6 f (n, rs) = appr5 f rs n
-- etcthis can be somewhat generalized so we're not stuck using only tuples forever (this is with viewpatterns btw):
class Splittable a b c | a -> b c where
_fst :: a -> b
_snd :: a -> c
instance Splittable (a, b) a b where
_fst = fst
_snd = snd
pair :: Splittable a b c => a -> (b, c)
pair a = (_fst a, _snd a)
applg1 :: (a -> t) -> a -> t
applg1 = id
applg2 :: Splittable s a b => (a -> b -> t) -> s -> t
applg2 f (pair -> (a, b)) = applg1 (f a) b
applg3 :: (Splittable s a s', Splittable s' b c) => (a -> b -> c -> t) -> s -> t
applg3 f (pair -> (a, b)) = applg2 (f a) b
applg4 f (pair -> (a, b)) = applg3 (f a) b
applg5 f (pair -> (a, b)) = applg4 (f a) b
applg6 f (pair -> (a, b)) = applg5 (f a) b
apprg1 :: (a -> t) -> a -> t
apprg1 = id
apprg2 :: Splittable s a b => (b -> a -> t) -> s -> t
apprg2 f (pair -> (n, rs)) = apprg1 f rs n
apprg3 :: (Splittable s a s', Splittable s' b c) => (c -> b -> a -> t) -> s -> t
apprg3 f (pair -> (n, rs)) = apprg2 f rs n
apprg4 f (pair -> (n, rs)) = apprg3 f rs n
apprg5 f (pair -> (n, rs)) = apprg4 f rs n
apprg6 f (pair -> (n, rs)) = apprg5 f rs nbut what i'd really like is to generalize these functions so that i don't need an infinite number of them based off of their argument count. they all do the same thing!! given what i've read about polyvariadic functions in haskell this should be totally possible. i just haven't really wrapped my head around the code yet.
and also maybe some way to set it up so the function type there doesn't have to be a function? like the only function i really want to get out of this whole deal is something like
render :: (Extend (Extend (Extend ...) v') v) -> (... ? v' ? v -> t) -> Map k t except i can't even come close to formulating what that type would look like. especially given Extend isn't a type but instead a typeclass.