Indeed as @tomjaguarpaw says my th-deepstrict
library already implements this.
Currently th-deepstrict
only works with fully concrete types (Maybe Int
rather than Maybe a
), but I’m planning on eventually implementing something like what you sketch. It’s a bit more work to implement, and in practice I haven’t found myself needing it, so it might be a while before I get to it.
We can access this information through TemplateHaskell’s reify
interface. It can show you the definition of any datatype in your dependency tree, even if the constructors weren’t exported.
We don’t have to specify the strictness properties of any types at all (though some datatype might need manual overrides because Array#
etc are not deep strict), and things will just be inferred. Eg, even builtin things like Int
don’t need to be specified to be deep strict, we can see that it’s deep strict because it has one field with an unlifted type.
I’m happy to answer any questions about it