let it leave me like a long breath

let it dissipate or fade in the background

(no subject)

Profile

xax: purple-orange {11/3 knotwork star, pointed down (Default)
howling howling howling

Nav

  • Recent Entries
  • Archive
  • Reading
  • Tags
  • Memories
  • Profile

Tags

  • art - 2 uses
  • asteroid garden - 4 uses
  • code - 19 uses
  • demos - 1 use
  • dreams - 5 uses
  • ff7 fangame - 23 uses
  • fic prompts - 13 uses
  • gamedev challenge - 82 uses
  • hell game - 76 uses
  • nanowrimo - 11 uses
  • plants - 9 uses
  • process - 52 uses
  • programming - 51 uses
  • screenshots - 5 uses
  • writing log - 83 uses

May 2025

S M T W T F S
    123
45678 910
1112131415 1617
18192021222324
25262728293031
  • Oct. 27th, 2015
  • xax: purple-orange {11/3 knotwork star, pointed down (Default)
    [personal profile] xax
    • Current Music: The Mountain Goats - Palmcorder Yajna
    Tags:
    • code,
    • programming
    posted @ 01:07 pm

    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
    -- etc

    this 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 n


    but 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.

    • Previous Entry
    • Add Memory
    • Share This Entry
    • Next Entry
    • Reply
Page generated Jan. 23rd, 2026 04:50 pm
Powered by Dreamwidth Studios

Style Credit

  • Style: (No Theme) for vertical