{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreigveikwzsytvea5jng6q4ntwmqgvnmtadwgchd2hcv225l6plafwi",
    "uri": "at://did:plc:pi6woz4d47bkuws673w2il2r/app.bsky.feed.post/3mm6ypbkpg5m2"
  },
  "path": "/t/ann-hsrs-ergonomic-haskell-bindings-for-rust/14129#post_2",
  "publishedAt": "2026-05-19T05:11:18.000Z",
  "site": "https://discourse.haskell.org",
  "textContent": "Always cool to see improved ffi!\n\nMy initial question is why use a newtype around a Word8 and pattern synonyms instead of actual enumerated types? You can still go via an integral interpretation in the boundary, and you’d be able to derive Enum and Bounded, as well as letting the Haskell side write safer code.\n\nFor example:\n\n\n    data Register = Reg0 | Reg1 | Count\n      deriving (Generic, Show, Eq, Enum, Bounded)\n      deriving (BorshSize, ToBorsh, FromBorsh) via (ActuallyAsEnum Register)\n\n    instance (Enum a) => ToBorsch (ActuallyAsEnum a) where\n      {- define using toEnum and fromEnum -}\n\n\nOr indeed using AsEnum from Borsh itself.",
  "title": "[ANN] hsrs -- Ergonomic Haskell Bindings for Rust"
}