Sign in

buster

@axionbuster.com
108 followers 114 following 92 posts

constant, yet volatile

PostsRepliesMedia
buster @axionbuster.com · 27/12/2024
i really like this example from heftia
prog :: IO ()
prog = runEff . runLog . runSpan $ do
    span "example program" do
        log "foo"

        span "greeting" do
            log "hello"
            log "world"

        log "bar"

>>> prog
[Start span 'example program']
[LOG] foo
[Start span 'greeting']
[LOG] hello
[LOG] world
[End span 'greeting']
[LOG] bar
[End span 'example program']
030
buster @axionbuster.com · 27/12/2024
TIL a purely functional double-ended queue with worst-case constant time access to either end is possible and that listing monads explicitly in such a data structure can improve the time complexity of certain operations (such as list concatenation) by changing assoc. of (>>=)
"Simple and efficient purely functional queues and deques," Chris Okasaki. Abstract. We present purely functional implementations of queues and double-ended queues (deques) requiring only O(1) time per operation in the worst case. Our algorithms are considerably simpler than previous designs with the same bounds. The inspiration for our approach is the incremental behavior of certain functions on lazy lists."Purely Functional, Real-Time Deques with Catenation," Haim Kaplan and Robert E. Tarjan. Abstract. We describe an efficient, purely functional implementation of eques with catenation. In addition to being an intriguing problem in its own right, finding a purely functional implementation of catenable deques is required to add certain sophisticated programming constructs to functional programming languages. Our solution has a worst-case running time of O(1) for each push, pop, inject, eject and catenation. The best previously known solution has an O(log* k) time bound for the kth deque operation. Our solution is not only faster but simpler. A key idea used in our result is an algorithmic technique related to the redundant digital representations used to avoid carry propagation in binary counting."Reflection without Remorse: Revealing a hidden sequence to speed up monadic reflection," Atze van der Plocg and Oleg Kiselyov. Abstract. A series of list appends or monad binds for many monads performs algorithmically worse when left-associated. Continuation-passing style (CPS) is well-known to cure this severe dependence of performance on the association pattern. The advantage of CPS dwindles or disappears if we have to examine or modify the intermediate result of that series of appends or binds, before continuing the series. Such examination is frequently needed, for example, to control search in non-determinism monads. We present an alternative approach that is just as general as CPS but more robust: it makes series of binds and other such operations efficient regardless of the association pattern -- and also provides efficient access to intermediate results. The key is to represent such a conceptual sequence as an efficient sequence data structure. Efficient sequence data structures from the literature are homogeneous and cannot be applied as they are in a type-safe way to series of monadic binds. We generalize them to type aligned sequences and show how to construct their (assuredly order-preserving) implementations. We demonstrate that our solution solves previously undocumented, severe performance problems in iteratees, LogicT transformers, free monads and extensible effects.
130
buster @axionbuster.com · 24/12/2024
TIL §§ (sections) is the plural of § (section)
000
Reposted by buster
Terminally Online Leftist 🥂 @terminallyol.bsky.social · 23/12/2024
1345447766339
buster @axionbuster.com · 23/12/2024
Backpropagation is a functor arxiv.org/abs/1711.10455
arxiv.org
Backprop as Functor: A compositional perspective on supervised learning
A supervised learning algorithm searches over a set of functions $A \to B$ parametrised by a space $P$ to find the best approximation to some ideal function $f\colon A \to B$. It does this by taking e...
020
Reposted by buster
fluffy_xenia @fluffyxenia.bsky.social · 21/12/2024
@wunidz.bsky.social here ya go. Not the easiest on the eyes but it's what I could make drive.google.com/file/d/1udxh...
drive.google.com
result.mp4
4135
buster @axionbuster.com · 22/12/2024
i feel so sad when a fellow man says “there are no femcels,” because that means he’s not often had the experience of girls-you’ve-just-met trying to cling onto him and do weird “cutesy” things hoping it’ll actually make them look cute. i always wonder if/how they get bf at all
000
buster @axionbuster.com · 21/12/2024
can anyone explain how this works?
-- | a mysterious module that apparently samples points on the face of a coid
module Face (facepoints, dbgcountfacepoints, dbgdesmos) where

import Control.Lens hiding (index)
import Data.Functor.Rep
import Data.Ix (range)
import Data.List (intercalate)
import Linear.V3
import Text.Printf

-- | retrieve the points on the faces of a cuboid
-- normal to a certain direction (sig: {-1, 0, 1}) from said cuboid
facepoints :: V3 Int -> V3 Int -> [V3 Int]
facepoints coid sig =
  let (!) = index
      -- p, q, r: dimensions
      -- ps: list of points to sample (?)
      -- h: permutation of a V3
      rule p q r ps h
        | sig ! p == 0 = []
        | otherwise =
            [ let a = if i >= coid ! r then coid ! r else i
                  b = if j >= coid ! q then coid ! q else j
                  c = if sig ! p < 0 then 0 else coid ! p
               in h do V3 a b c
            | (i, j) <- ps
            ]
      -- this thing is a total mystery to me
      st i -- compute starting / ending points for the face (?) in dimension i
        | sig ! i < 0 = (1, 0)
        | sig ! i > 0 = (0, 1)
        | otherwise = (0, 0)
      h0 (V3 a b c) = V3 c b a
      h1 (V3 a b c) = V3 b c a
      h2 (V3 a b c) = V3 b a c
      p0 =
        let (sj, ej) = st ey
            (si, ei) = st ez
         in range ((si, sj), (coid ! ez - ei, coid ! ey - ej))
      p1 =
        let (sj, ej) = st ez
         in range ((sj, 0), (coid ! ez - ej, coid ! ex))
      p2 = range ((0, 0), (coid ! ey, coid ! ex))
   in concat
        [ rule ex ey ez p0 h0,
          rule ey ex ez p1 h1,
          rule ez ex ey p2 h2
        ]

-- | print a list of vectors in a format that can be copy-pasted into Desmos
dbgdesmos :: (Show a) => [V3 a] -> String
dbgdesmos vs = "[" ++ intercalate "," (f <$> vs) ++ "]"
  where
    f (V3 x y z) = printf "(%s,%s,%s)" (show x) (show y) (show z)

-- | predict the number of points sampled by 'facepoints'
dbgcountfacepoints :: V3 Int -> V3 Int -> Int
dbgcountfacepoints ((+ pu…
000
Reposted by buster
big naturals history museum @stickstickley.bsky.social · 21/12/2024
121262
buster @axionbuster.com · 21/12/2024
undefined behavior can really do anything
Does Infinity - Infinity = an Electron?
000
buster @axionbuster.com · 21/12/2024
what is so “least” about a least fixed point? in what order?
100
buster @axionbuster.com · 21/12/2024
gist.github.com/axionbuster/...
gist.github.com
Grid ray marching with floating-point error compensation
Grid ray marching with floating-point error compensation - Lib.hs
000
buster @axionbuster.com · 20/12/2024
DDA line drawing algorithm, dimension-independent, lazy, infinite original algorithm is from Wikipedia (for 2D, in C) image: magnified image output, (0, 0) to (10, 5)
-- | the DDA line drawing algorithm
-- (dimension-independent, lazy, infinite)
--
-- you can generate an infinite ray by
-- ignoring the number of steps
--
-- algorithm is due to Wikipedia
dda ::
  forall f i s.
  (Traversable f, MonadZip f, Integral i) =>
  -- | The starting point
  f i ->
  -- | The ending point
  f i ->
  -- | The number of steps (points) to get to the end
  -- and the points
  ST s (i, [f i])
dda start end = do
  let fi = fromIntegral :: i -> Double
      difference = liftM2 (-) end start
      steps = maximum $ abs <$> difference
      step = ((/ fi steps) . fi) <$> difference
  v <- newSTRef `traverse` fmap fi start
  (succ steps,) <$> fix \loop -> do
    v' <- traverse readSTRef v
    forM_ (mzip v step) \(r, s) -> modifySTRef r (+ s)
    (fmap round v' :) <$> loop -- lazy listmagnified image output, (0, 0) to (10, 5)
100
buster @axionbuster.com · 20/12/2024
to build a list in the correct order in Haskell, choose one of three ways: 1. use a writer monad 2. build it in the reverse order, and then reverse it back 3. instead of using a list as an accumulator, use a function of type (a -> [a]) as the accumulator.
110
buster @axionbuster.com · 20/12/2024
the usefulness of MultiWayIf in Haskell programming cannot be overstated (but you could hack it using case () of _ | condition1 -> expression1; _ | condition2 -> expression2; ...)
if
  | all id needs -> do
      enqueue $ newpoint2 ex ey
      unless smooth do
        enqueue $ newpoint2 ey ez
        enqueue $ newpoint2 ex ez
        enqueue $ newpoint1 ex
        enqueue $ newpoint1 ey
        enqueue $ newpoint1 ez
  | needs ^. el ex && needs ^. el ey -> do
      enqueue $ newpoint1 ex
      unless smooth do
        enqueue $ newpoint1 ey
  | needs ^. el ex && needs ^. el ez -> do
      enqueue $ newpoint1 ex
      unless smooth do
        enqueue $ newpoint1 ez
  | needs ^. el ey && needs ^. el ez -> do
      enqueue $ newpoint1 ey
      unless smooth do
        enqueue $ newpoint1 ez
  | otherwise -> pure ()
031
buster @axionbuster.com · 20/12/2024
“is this object oriented mathematics?”
YouTube. A Sensible Introduction to Category Theory by Oliver Lugg.

Comment. Is this object oriented mathematics?
000
buster @axionbuster.com · 20/12/2024
fuck the gang of four, stand edward kmett… seriously
030
buster @axionbuster.com · 20/12/2024
if you have an array with four (4) elements -- a product type -- then its index could be one of four (4) choices -- a sum type indexing is to logarithms as functions are to exponentials
000
Reposted by buster
Echo @isthere.an.echo.inhere.orisitjust.me · 18/12/2024
at santa-scale it probably has to be done by separate nodes in a distributed system
2211
buster @axionbuster.com · 20/12/2024
there's a whole community on the internet accumulating knowledge about teaching, metathinking and problem solving amazing
100
buster @axionbuster.com · 20/12/2024
digging this aesthetic
1945 SIGSALY 1946
SPEECH ENCIPHERMENT SYSTEM
A lectern surrounded by walls made of hardware
010
buster @axionbuster.com · 20/12/2024
when i was 22, i was rotting in bed when Twan van Laarhoven was 22, he published in a blog post an innovation that would be later named after himself ... van Laarhoven lenses also, scary to think that he's nearly 40 now time flies like a banana fruit flies like an arrow
010
Reposted by buster
Arnaud @pankzsoft.net · 18/12/2024
If one has to use CPP in Haskell, doing it in the cabal file as a way to conditionally include modules instead of sprinkling #ifdef/#endif across the code-base feels much cleaner to me. A small amount of code duplication is better than slicing and dicing code to the point it becomes unreadable.
021
Reposted by buster
Hacker News Top 100 Bot (Unofficial) @hn100.bsky.social · 19/12/2024
Haskell vs. Ada vs. C++ vs. an Experiment in Prototyping Productivity (1994) [pdf] Discussion
011
buster @axionbuster.com · 19/12/2024
CRACKED fucking project github.com/hyperion-mc/...
github.com
GitHub - hyperion-mc/hyperion: 170,000 player capable Minecraft game engine built in Rust.
170,000 player capable Minecraft game engine built in Rust. - hyperion-mc/hyperion
000
buster @axionbuster.com · 19/12/2024
how to fix error
000
buster @axionbuster.com · 19/12/2024
writing imperative code in haskell was a mistake
extrapoints :: STRef s (Seq IP) <- new Seq.empty -- right-to-left, FIFO
out :: STRef s [IP] <- new []
callCC \break_ -> do
  let break = break_ ()
  fix \continue -> do
    let tell = write out
    read extrapoints >>= \case
      a :<| points -> do
        tell [a]
        if sameblock a end
          then break
          else continue
      _ -> pure ()
    -- todo...
    break
351
buster @axionbuster.com · 19/12/2024
can you believe that this guy's Haskell implementation of QOI codec beats the C implementation? github.com/0xd34df00d/h...
github.com
GitHub - 0xd34df00d/hsqoi: Haskell implementation of the QOI image format
Haskell implementation of the QOI image format. Contribute to 0xd34df00d/hsqoi development by creating an account on GitHub.
020
buster @axionbuster.com · 18/12/2024
github.com/axionbuster/...
github.com
GitHub - axionbuster/varcomp: Variadic function composition (without hacks)
Variadic function composition (without hacks). Contribute to axionbuster/varcomp development by creating an account on GitHub.
000
buster @axionbuster.com · 17/12/2024
Variadic Composition (uses the Text.Printf trick) (language: GHC2021, no other extensions)
010
buster @axionbuster.com · 17/12/2024
can you find a solution to this problem? (or decide that there is not)
000
buster @axionbuster.com · 12/12/2024
is floating point division by 0 defined in Haskell? i know it’s unconditionally UB on C/C++
200
buster @axionbuster.com · 12/12/2024
fun fact i learned. a box-box collision problem can be reduced to a ray-box collision problem
100
buster @axionbuster.com · 12/12/2024
afraid of formatting and reinstalling my Windows box because uBlock Origin will be blocked on Chrome
000
buster @axionbuster.com · 12/12/2024
ormolu
000
Reposted by buster
Graydon Hoare @graydon-pub.bsky.social · 02/12/2024
Having real windows support out of the gate was a key strategic choice for Rust. It helped that Mozilla was shipping a browser there and knew the relative platform sizes in its bones. I don't like windows especially, but seriously buy a windows dev box and make your stuff work on windows, always.
514318
Reposted by buster
business goose🪿 @goose.art · 01/12/2024
at my old job doing pentesting we had one client who we tested before and reported a finding about base64 not being secure which they claimed to have patched when we did a retest, we found that they just base64ed 3 times instead 🤦‍♂️
5583
buster @axionbuster.com · 02/12/2024
If only Haskell allowed ? as the last character of an identifier... Well now that would be a huge and confusing change
000
Reposted by buster
Josiah @josiah.rs · 01/12/2024
👨🏻‍💻🎄Day 1 Solution of #AdventOfCode in base R. Some may even call it the best R.

sum(abs(do.call(`-`, lapply(read.table("input/day1.txt"), sort))))
6613
buster @axionbuster.com · 01/12/2024
#Haskell made many mistakes but also has some Godsend takes IO being a monad is one Transactions are computation that is never partially performed. Optimistic transactions try first and if it fails rolls back. But arbitrary IO can’t be rolled back. So they live in a distinct monad (STM)
020
buster @axionbuster.com · 01/12/2024
I just completed "Historian Hysteria" - Day 1 - Advent of Code 2024 #AdventOfCode adventofcode.com/2024/day/1
220
buster @axionbuster.com · 01/12/2024
#adventofcode2024 #Haskell is the new #Python
210
buster @axionbuster.com · 01/12/2024
Some brand names on Amazon look like randomly generated and yet manage to deliver good stuff
WSAKOUE (R) WORKOUT EXERCISE BAND
200
buster @axionbuster.com · 30/11/2024
youtu.be/jkqCCSGjadk?...
youtu.be
Unknown Song "You're Going Down"
YouTube video by x
200
buster @axionbuster.com · 30/11/2024
Haskell Generics take such an ungodly amount of time to compile I'm going wild
000
Reposted by buster
Chris Penner @chrispenner.ca · 20/11/2024
Did other #Haskell devs make it waaay too far into their career wondering what the #ActorModel fuss was about only to discover you'd been casually doing it in Haskell for years? It's so easy with STM and async that you don't need actor frameworks like other langs, so I never noticed I was doing it.
2142
Reposted by buster
LambdaDuck @anka213.bsky.social · 20/11/2024
stock deriving can’t derive the proper foldTree, but there are libraries that can. e.g. hackage.haskell.org/package/cata... and hackage.haskell.org/package/recu...
hackage.haskell.org
catamorphism
Exposes a Template Haskell function for generating catamorphisms.
241
buster @axionbuster.com · 30/11/2024
import Control.Monad.Trans (🏳️‍⚧️) — coincidence?
000
buster @axionbuster.com · 30/11/2024
Appalled at the number of people who think (entry-level) MacBooks are overpriced. Maybe they’re non-Americans so economics are somehow different, or all they do is surf the net (and literally nothing else), or they just drop $3k on premium laptops, or must run things like SolidWorks…(?)
010