Dynamic decoders for opaque types
I'm having lots of fun learning gleam, by writing a TUI app to manage my reading lists and bookmarks. However I am a bit stuck while writing a decoder for my types:
pub type State {
Valid(time: Timestamp, previous: State)
Created(time: Timestamp)
Invalid(time: Timestamp, previous: State)
}
pub type Link {
Link(uri: Uri, title: String, description: String, state: State)
}
I think I got how to make a recursive decoder, but no idea how to decode Timestamp (from package gleam/time) because it is opaque.
My goal is to use a DETS for persistence (ideally using shelf) and I must provide decoders for keys and values.
What should I try ?
Posted Aug 3, 2026, 10:36 AM UTC
38