locked
What is MGraph, and how does it relate to MSchema and MGrammar?

    Question

  • In the first post on the M Language Blog MWinehardt wrote:
    "M" is a core feature of "Oslo" and is a language for textually describing and authoring domains. "M" comprises the following: MGraph, MSchema, and MGrammar. MGraph is for serializing data values to a graph structure similar to syntaxes like JSON. MSchema builds on MGraph by providing a structural type system, extent declarations for storing values, and computed values, which are queries over values and extents. MGrammar is used to describe domain-specific languages in terms of rules that are used to transform input text to MGraph.
    I still got a few questions:
    1. Does MGraph have a concrete textual representation?
    2. If yes, does the MGrammar result pane show MGraph?
    3. Or is MGraph what I type as values in M (together with my schemas)?
    Monday, November 17, 2008 4:48 PM

Answers

  • Hi Lars,

    These are great questions.

    > I've been using MSchema and MGrammar - both have a nice specification document defining syntax and how to use it. So my question was, if MGraph is or has a textual DSL, too?

    Yes, MGraph has a textual form. Today, it doesn't show in a finished form, but the right-hand-side of MGrammar rules and the initializers for MSchema extents are MGraph instances. They are indeed just nested labeled graphs as you describe below.


    > When writing MGrammar the results are mapped to a label-directed graph - very JSON-like. Labels, Brackets for sorted children, braces for unsorted successors - and values. Not more. [...] Is this MGraph?

    Yes. One point though: even ordered/sorted children are encoded by convention. So, the use of square brackets is itself a tiny layer of rewritable syntax:

    Children [ {Name {"Mike"}, Age {7}}, {Name {"Anna"}, Age {5}} ]

    is shorthand for

    Children { 0{Name {"Mike"}, Age {7}}, 1{Name {"Anna"}, Age {5}} }

    That is, we use integer labels to indicate sorted lists of successors.


    > When writing values/instances within a MSchema-module there is a different syntax. Values are defined within extents, and there is a notion of fields and initializers, while labels are for internal referencing. [...] Is this meant to be MGraph?

    The equality notation is also a tiny layer of rewritable syntax:

    Name = "Mike"

    is shorthand for

    Name {"Mike"}

    That is, we support equality syntax for the common special case of a singleton successor.


    > Or is it just about the API and the in-memory object-model, as Jon answered? How can I then get the same representation of data that I want to define within my schema and my MGrammar? How could I even link between them?

    With the above details you can see how both square bracket and equality syntax are just "sugar". At the API level, the key type is IGraphBuilder - it only knows about labels and successors. That interface corresponds to the fully desugared MGraph syntax. There's also GraphBuilder, a simple implementation of IGraphBuilder that also implements IEntityBuilder and ISequenceBuilder - two optional "fast path" interfaces that allow a graph builder to chose optimal representations for entities (mappings from field names to singleton successors) and for sequences (sorted lists of successors), rather than forcing inefficient "normalized" encodings.

    Does that help?

    Clemens

    • Marked as answer by lcorneliussen Tuesday, November 25, 2008 3:17 PM
    • Unmarked as answer by lcorneliussen Wednesday, November 26, 2008 9:45 AM
    • Marked as answer by lcorneliussen Tuesday, December 02, 2008 8:25 AM
    Tuesday, November 25, 2008 3:11 PM
  • Great questions, and insightful feature requests :)

    We want the same thing. As Doug said in a recent blog post, we are hyper early showing the languages, and have lots of work to do to integrate MSchema and MGrammar.

    Specifically, we expect MGrammar and MSchema to align on both syntax, data types (e.g., integer32 and logical), and API/framework.

    MGraph references works today in MSchema, but not yet in MGrammar. Referencing actually starts to lead us down the path of whether we'll have evaluation capabilities for MGraphs such that you can write expressions (including references) and have them evaluated by the backend. With MSchema->SQL translation we have that. However, we're not sure how far we can get with MGrammar. Stay tuned.
    -- pinky --/ http://www.tinyfinger.com/
    • Marked as answer by lcorneliussen Tuesday, December 02, 2008 8:24 AM
    Monday, December 01, 2008 10:28 PM

All replies

  • My understanding is that MGraph is the in-memory object model that represents the projection of a instance document through MGrammar.  

    MSchema uses this object model to generate SQL.  I believe MGraph refers to the set of types in System.DataFlow  (like GraphBuilder).

    Not sure - but I think the "Sematic Graph" text output shown by IPad (under MMode) may be the serialized format exposed by MGraph (on this part I'm not 100% sure)


    Jon

    http://www.masteringbiztalk.com/blogs/jon/default.aspx
    Monday, November 17, 2008 5:15 PM
  • Pinky did a write-up of MGraph here. Let us know if you need more info.
    Monday, November 17, 2008 5:30 PM
  • Hi Mike,

    > GraphBuilder is fairly straightforward to use. It and Mgraphs are at the base of the modeling platform, ...
    Pinky focusses on "It", the MGraphBuilder, but his post answers neither of my questions. Or am I just too confused? :-)

    Again, in more detail.

    1. I've been using MSchema and MGrammar - both have a nice specification document defining syntax and how to use it. So my question was, if MGraph is or has a textual DSL, too?

    2. When writing MGrammar the results are mapped to a label-directed graph - very JSON-like. Labels, Brackets for sorted children, braces for unsorted successors - and values. Not more.

      Could be:
      Dad { 
        Name { "George" }, 
        Children [ 
          {Name {"Mike"}, Age {7}}, 
          {Name {"Anna"}, Age {5}} 
        ] 
       
      Is this MGraph?

    3. When writing values/instances within a MSchema-module there is a different syntax. Values are defined within extents, and there is a notion of fields and initializers, while labels are for internal referencing.

      The same data as above:

      Dad { 
        Name = "George"
        Children { 
          {Name = "Mike", Age = 7}, 
          {Name = "Anna", Age = 5} 
        } 
       
      Is this meant to be MGraph?

    4. Or is it just about the API and the in-memory object-model, as Jon answered? How can I then get the same representation of data that I want to define within my schema and my MGrammar? How could I even link between them?


    • Edited by lcorneliussen Tuesday, November 18, 2008 9:37 AM improved formatting
    Tuesday, November 18, 2008 6:32 AM
  • Hi Lars,

    These are great questions.

    > I've been using MSchema and MGrammar - both have a nice specification document defining syntax and how to use it. So my question was, if MGraph is or has a textual DSL, too?

    Yes, MGraph has a textual form. Today, it doesn't show in a finished form, but the right-hand-side of MGrammar rules and the initializers for MSchema extents are MGraph instances. They are indeed just nested labeled graphs as you describe below.


    > When writing MGrammar the results are mapped to a label-directed graph - very JSON-like. Labels, Brackets for sorted children, braces for unsorted successors - and values. Not more. [...] Is this MGraph?

    Yes. One point though: even ordered/sorted children are encoded by convention. So, the use of square brackets is itself a tiny layer of rewritable syntax:

    Children [ {Name {"Mike"}, Age {7}}, {Name {"Anna"}, Age {5}} ]

    is shorthand for

    Children { 0{Name {"Mike"}, Age {7}}, 1{Name {"Anna"}, Age {5}} }

    That is, we use integer labels to indicate sorted lists of successors.


    > When writing values/instances within a MSchema-module there is a different syntax. Values are defined within extents, and there is a notion of fields and initializers, while labels are for internal referencing. [...] Is this meant to be MGraph?

    The equality notation is also a tiny layer of rewritable syntax:

    Name = "Mike"

    is shorthand for

    Name {"Mike"}

    That is, we support equality syntax for the common special case of a singleton successor.


    > Or is it just about the API and the in-memory object-model, as Jon answered? How can I then get the same representation of data that I want to define within my schema and my MGrammar? How could I even link between them?

    With the above details you can see how both square bracket and equality syntax are just "sugar". At the API level, the key type is IGraphBuilder - it only knows about labels and successors. That interface corresponds to the fully desugared MGraph syntax. There's also GraphBuilder, a simple implementation of IGraphBuilder that also implements IEntityBuilder and ISequenceBuilder - two optional "fast path" interfaces that allow a graph builder to chose optimal representations for entities (mappings from field names to singleton successors) and for sequences (sorted lists of successors), rather than forcing inefficient "normalized" encodings.

    Does that help?

    Clemens

    • Marked as answer by lcorneliussen Tuesday, November 25, 2008 3:17 PM
    • Unmarked as answer by lcorneliussen Wednesday, November 26, 2008 9:45 AM
    • Marked as answer by lcorneliussen Tuesday, December 02, 2008 8:25 AM
    Tuesday, November 25, 2008 3:11 PM
  • Absolutely! Thanks for your answer!

    (Update: I remarked your post as "helpful" instead of "answer)
    Tuesday, November 25, 2008 3:19 PM
  • Thanks again for the first level of clarification :-)

    >Today, it doesn't show in a finished form, but the right-hand-side of MGrammar rules
    >and the initializers for MSchema extents are MGraph instances.

    In the AST of "M" the extents are shown as GraphExpressions. They support operators, references, ... and seem to be "processed" into MGraph's. A "-" is not expressed as a simple integer value, but as an UInt64 preceeded by a minus-operator.

    In MGrammar projections "=" is not supported, while "M" does neither support brackets nor integer labels to indicate sorted successors.

    So, my next questions...
    1. Will GraphExpressions be part of the MGraph-Specification and also be available in MGrammar projections?
    2. Will the Syntax be unified between MGrammar projections an extent-initializers?
    3. What about referencing between MGraph successors? Will there be a notion for that?
    Thanks for your answers!
    Wednesday, November 26, 2008 9:44 AM
  • Great questions, and insightful feature requests :)

    We want the same thing. As Doug said in a recent blog post, we are hyper early showing the languages, and have lots of work to do to integrate MSchema and MGrammar.

    Specifically, we expect MGrammar and MSchema to align on both syntax, data types (e.g., integer32 and logical), and API/framework.

    MGraph references works today in MSchema, but not yet in MGrammar. Referencing actually starts to lead us down the path of whether we'll have evaluation capabilities for MGraphs such that you can write expressions (including references) and have them evaluated by the backend. With MSchema->SQL translation we have that. However, we're not sure how far we can get with MGrammar. Stay tuned.
    -- pinky --/ http://www.tinyfinger.com/
    • Marked as answer by lcorneliussen Tuesday, December 02, 2008 8:24 AM
    Monday, December 01, 2008 10:28 PM