External Publication
Visit Post

The design of array libraries

Haskell Community [Unofficial] May 21, 2026
Source
I put my ~~money~~ time where my mouth is and made a (much) simplified vector library. Now you can write it like this: {-# LANGUAGE BlockArguments #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE TypeAbstractions #-} module T where import Data.Vector import Data.Proxy import GHC.TypeLits newtype V n x = V {unV :: Int -> x} deriving (Functor) cache :: KnownNat n => V n x -> V n x cache @n (V f) = let !v = generate (fromIntegral (natVal (Proxy @n))) f in V (unsafeIndex v)

Discussion in the ATmosphere

Loading comments...