Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proto3 enums #137

Merged
merged 8 commits into from
Sep 12, 2017
Merged

Proto3 enums #137

merged 8 commits into from
Sep 12, 2017

Commits on Sep 7, 2017

  1. Bundle enum pattern synonyms exports with their type.

    This change removes support for `ghc-7.10`.  The feature we're using
    was only added in `ghc-8.0.1`, and there are already a few other shims for
    that older version of GHC.
    
    This change uses explicit export lists in the generated proto modules (but
    only for `Proto.Foo.Bar`, not `Proto.Foo.Bar'Fields`).  The same names should
    be exported as before, the only difference is that for enum aliases:
    ```
    enum Foo {
      option allow_alias = true;
      Foo = 1;
      Bar = 2;
      BarA = 2;
    }
    ```
    which produce the Haskell code:
    ```
    data Foo = Foo | Bar
    pattern BarA :: Foo
    pattern BarA = Bar
    ```
    we now export explicitly `Foo(.., BarA)`, rather than exporting `BarA` as a
    separate name.  That way, if someone writes `import Proto.File (Foo(..))` then
    they also get `BarA` automatically.
    judah committed Sep 7, 2017
    Configuration menu
    Copy the full SHA
    8605326 View commit details
    Browse the repository at this point in the history
  2. Implement proto3-style "open" enums.

    For example:
    
    ```
    enum Foo {
      Foo0 = 0;
      Foo1 = 1;
    }
    ```
    
    becomes
    
    ```
    newtype Foo = Foo Int32
    pattern Foo0 :: Foo
    pattern Foo0 :: Foo 0
    pattern Foo1 :: Foo
    pattern Foo1 :: Foo 1
    ```
    
    Additionally, proto3 enums are exported from the `Proto.*` module with the
    form `Foo(Foo0, Foo1)`, so that they can be imported as `Foo(..)` to get the
    patterns.
    judah committed Sep 7, 2017
    Configuration menu
    Copy the full SHA
    176a5d5 View commit details
    Browse the repository at this point in the history
  3. Fix formatting typo

    judah committed Sep 7, 2017
    Configuration menu
    Copy the full SHA
    bccef23 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    1d716f0 View commit details
    Browse the repository at this point in the history

Commits on Sep 8, 2017

  1. Remove unused line

    judah committed Sep 8, 2017
    Configuration menu
    Copy the full SHA
    da6d4db View commit details
    Browse the repository at this point in the history

Commits on Sep 12, 2017

  1. fix comment

    judah committed Sep 12, 2017
    Configuration menu
    Copy the full SHA
    9d1a76d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    eb4f5e4 View commit details
    Browse the repository at this point in the history
  3. fix

    judah committed Sep 12, 2017
    Configuration menu
    Copy the full SHA
    2d0974b View commit details
    Browse the repository at this point in the history