{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreieaoa5e3o6mxiwhjovoyhtp3kp3mycloj63qjqiisle32hodcnfza",
    "uri": "at://did:plc:pi6woz4d47bkuws673w2il2r/app.bsky.feed.post/3mmfmnbdfzpj2"
  },
  "path": "/t/the-design-of-array-libraries/14114#post_6",
  "publishedAt": "2026-05-21T22:17:35.000Z",
  "site": "https://discourse.haskell.org",
  "tags": [
    "simplified vector library",
    "@n"
  ],
  "textContent": "I put my ~~money~~ time where my mouth is and made a (much) simplified vector library. Now you can write it like this:\n\n\n    {-# LANGUAGE BlockArguments #-}\n    {-# LANGUAGE LambdaCase #-}\n    {-# LANGUAGE TypeAbstractions #-}\n\n    module T where\n\n    import Data.Vector\n    import Data.Proxy\n    import GHC.TypeLits\n\n    newtype V n x = V {unV :: Int -> x} deriving (Functor)\n\n    cache :: KnownNat n => V n x -> V n x\n    cache @n (V f) =\n      let !v = generate (fromIntegral (natVal (Proxy @n))) f\n      in V (unsafeIndex v)\n",
  "title": "The design of array libraries"
}