{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreib7dw5ra3xtnqgvh4iac5zpohf2ishsmzc5qlv3bm4cqp635gx4yq",
    "uri": "at://did:plc:pi6woz4d47bkuws673w2il2r/app.bsky.feed.post/3mgvrzosu5jz2"
  },
  "path": "/t/fancy-haskell-advice-add-recursion-to-a-strongly-typed-stack-machine/13607#post_8",
  "publishedAt": "2026-03-12T23:18:12.000Z",
  "site": "https://discourse.haskell.org",
  "tags": [
    "github.com/AriFordsham/stack-machine",
    "src/StackMachine.hs",
    "`main`",
    "show original"
  ],
  "textContent": "So I have worked out the scheme I want and implemented it, so far without compile-time stack-underflow guarantees. They will be an interesting challenge to add, any pointers appreciated!\n\ngithub.com/AriFordsham/stack-machine\n\n#### src/StackMachine.hs\n\n`main`\n\n\n    {-# LANGUAGE ImpredicativeTypes #-}\n    {-# LANGUAGE RecordWildCards #-}\n    {-# LANGUAGE TypeFamilies #-}\n\n    module StackMachine where\n\n    import Data.Bits ((.&.))\n    import Data.List (uncons)\n\n    import Data.Foldable (foldlM)\n\n    import Control.Monad.Identity (Identity)\n\n    import Data.Fin (Fin, fin0, fin1, fin2, fin3, fin4)\n    import Data.Type.Nat (Nat (S), Nat1, Nat5)\n    import Data.Vec.Lazy (Vec (..), (!))\n\n    data Instr = And | Add | Eq | Dup | Swap | Push Int | Pop\n      deriving (Show)\n\n\n\nThis file has been truncated. show original",
  "title": "Fancy Haskell advice: Add recursion to a strongly-typed stack machine"
}