A slither more readable.
Even though I can somehow arrive at this, I am still baffled by Hyperfunctions.
Continuing to play with Hyperfunctions until I achieve enlightenment.
Implementing `\xs -> xs <> 0 : reverse xs`.
2
9
503
Liam Goodacre retweeted
A slither more readable.
Even though I can somehow arrive at this, I am still baffled by Hyperfunctions.
I can't prove it but I feel like @hensoncompany's "The Dark Crystal" and @Naughty_Dog's "Jak and Daxter" are somehow the same universe.
1
67
Ah, in the short ones: `kickit` can be replaced by `run`.
Which is:
```
run :: (a -&> a) -> a
run h = invoke h id
```
I didn't need the `rep id` at all.
2
61
heterogeneous zippy foldable of foldables via hyperfunctions
github.com/LiamGoodacre/hype…
nitter.cf/Jose_A_Alonso/status/1…
Hyperfunctions: Communicating continuations. ~ Donnacha Oisín Kidney, Nicolas Wu. doisinkidney.com/pdfs/hyperf… #Haskell #FunctionalProgramming
Liam Goodacre retweeted
Hyperfunctions: Communicating continuations. ~ Donnacha Oisín Kidney, Nicolas Wu. doisinkidney.com/pdfs/hyperf… #Haskell #FunctionalProgramming
Inspired by Phil Freeman's (@paf31) water-level Tardis solution, here's an approach using a Day convolution of state, one running forwards the other backwards.
Tardis solution: gist.github.com/paf31/9d84ec…
Day state solution: gist.github.com/LiamGoodacre…
2
285
Liam Goodacre retweeted
New algorithm for collaborative text editing just dropped: arxiv.org/pdf/2409.14252
Does this ( sort of alternating (pre-order-)depth-first and breadth-first ) tree walk have a name? I haven't found it anywhere yet.
It walks immediate child elements first, and then each of their entire sub-trees, recursively.
![Haskell code: ``` import Data.Char import Data.Tree import Data.Functor.Day import Control.Monad.State.Strict funky :: Applicative f => (a -> f b) -> Tree a -> f (Tree b) funky f = dap . go where go (Node x xs) = Day (f x) (dap $ traverse go xs) Node demo :: Int -> Int -> Tree () demo m n = Node () (if n < 0 then [] else replicate m (demo m (n - 1))) ticking :: (State Int String -> State Int r) -> r ticking f = evalState (f (modify succ *> (show <$> get))) 0 shrink :: String -> String shrink = unlines . filter (any isDigit) . lines main :: IO () main = putStrLn $ shrink $ drawTree $ ticking $ \tick -> funky (const tick) (demo 2 2) ```](https://pbs.twimg.com/media/GNXrzeqXQAAQQpp.jpg?name=small&format=webp)
ALT Haskell code: ``` import Data.Char import Data.Tree import Data.Functor.Day import Control.Monad.State.Strict funky :: Applicative f => (a -> f b) -> Tree a -> f (Tree b) funky f = dap . go where go (Node x xs) = Day (f x) (dap $ traverse go xs) Node demo :: Int -> Int -> Tree () demo m n = Node () (if n < 0 then [] else replicate m (demo m (n - 1))) ticking :: (State Int String -> State Int r) -> r ticking f = evalState (f (modify succ *> (show <$> get))) 0 shrink :: String -> String shrink = unlines . filter (any isDigit) . lines main :: IO () main = putStrLn $ shrink $ drawTree $ ticking $ \tick -> funky (const tick) (demo 2 2) ```
Hehe,
Walk the tree once but process each entry in an order determined by the entries themselves.
Implemented via an enhanced FreeAp which maintains sorting via a key (entries at equal keys combine directly).
Liam Goodacre retweeted
Read about an exciting new technique @mpickering_ and Zubin have been developing for profiling memory usage of Haskell programs: well-typed.com/blog/2024/01/…















