Exploring the existing Jotai Re-Script bindings and found a potential bug. A detailed report can be found at [BUG]: TypeError when creating a derived atom from a derived atom · Issue #9 · gaku-sei/re-jotai · GitHub but the short version is:
- You can define a reactive atom with a value that is readable and writable
- You can define a derived value that is readable from a readable and writable atom
- You CANNOT define a derived value from another readable derived value
In the original Jotai implementation, it is intended to support Readable → Readable derivatives. A quick test can be found at: jotai-demo (forked) - CodeSandbox.
I’m not very confident in my ReScript so upon looking around I have a suspect:
Specifically I’m thinking it’s the
[> Permissions.r] part that seems to work as expected when you provide a default readable + writable as the source to
get but not a readable.
Where I got stuck is I don’t recognize that syntax, despite my efforts I was unable to find a similar sample mentioned in the docs. I think it’s part of the destructuring\pattern-matching syntax but I’m not quite sure? Seems to act as some kind of guard?
I would like to know more about this so I can look into fixing it, even if the author is able to patch it before I can find a solution, it seems like a good learning opportunity. Is this something I just overlooked in the docs or some implied combination of the pre-existing concepts?