Morphir File based layout #214
Replies: 2 comments 4 replies
-
I assume these are just some notes from our meeting, but we can use this discussion to work out the details. From our discussions it sounded like one of the most important benefits we are hoping to get out of the new format is the ability to break the IR up into smaller files. The benefit of this would be that some of the IR's structure would be represented by a directory/file structure which is easier to navigate without specialized JSON tooling. This would be very beneficial but it comes at the price of having to define both a directory layout and a JSON format for the file contents and the two should form a cohesive specification. Also, the Morphir tools will need to now navigate the file system as well as the contents of the JSON so they become more complex compared to the current state of just having to deal with a single JSON file. As we can see, both approaches have benefits, so I started to think about how we could combine them, and I think there's a way to get the best of both worlds. To demonstrate the approach let's start with a sample JSON file: // main.json
{
"foo": {
"foo child 1": [ "a", "b", "c" ],
"foo child 2": {
"width": 12,
"height": 34
}
},
"bar": {
"baz": {},
"bat": 123
}
} What would be the easiest way of breaking this up into files? One simple approach would be this: // main
// - foo.json
{
"foo child 1": [ "a", "b", "c" ],
"foo child 2": {
"width": 12,
"height": 34
}
}
// - bar.json
{
"baz": {},
"bat": 123
} Or you can go even further and break up // main
// - foo
// - foo child 1.json
[ "a", "b", "c" ]
// - foo child 2.json
{
"width": 12,
"height": 34
}
// - bar.json
{
"baz": {},
"bat": 123
} The rules that I applied are simple:
With this approach we could have the best of both worlds:
@stephengoldbaum, @DamianReeves, what do you think? |
Beta Was this translation helpful? Give feedback.
-
Looks sensible. Where would we draw the line on granularity? And where do you put the information associated with the folder? Using a simplified IR example, given:
Which would be folders vs files and where would we put the module information for |
Beta Was this translation helpful? Give feedback.
-
What would the structure of the file based morphir look like:
Distribution
Module
Encoding distribution:
PackageName of Distribution:
distribution.json : contains PackageName folder
Module :
module.json
Beta Was this translation helpful? Give feedback.
All reactions