Fun idea: Dynamically generated structs #584
ivanperez-keera
started this conversation in
Ideas
Replies: 1 comment
-
My attempt at defining dynamically typed structs can be found in this gist. The key data type is data DynStruct (name :: Symbol) (fields :: [(Symbol, Type)]) -- Exported abstractly Along with a withDynStruct :: String -> [Value ()] -> (forall name fields. DynStruct name fields -> r) -> r If Ogma were to use this, then all Ogma would have to do is compute the struct name at runtime, as well as the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to link Copilot inside Ogma so that users don't have to execute runhaskell.
I'm finding a limitation: Ogma reads a data structure definition from a C file, and can currently generate the equivalent in Haskell. However, of Ogma runs Copilot for the user, then that struct would have to be generated dynamically.
I think this can be done with heterogeneous lists and some datatype representing dynamic structs. We'd lose some type safety along the way, but Ogma could guarantee that it generates code that always uses structs correctly, so I expect that not to be a problem.
If anybody has a clear idea of how this could be done, that'd really help.
Beta Was this translation helpful? Give feedback.
All reactions