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

Fix derived Inject instance for sum types #348

Merged
merged 1 commit into from
Apr 2, 2018

Commits on Apr 1, 2018

  1. Fix derived Inject instance for sum types

    Related to #346
    
    This fixes the `GenericInject` instance for a sum type with two
    constructors to include the type of the alternative constructor.  For
    example, before this change you would get the following incorrect
    conversion:
    
    ```
    $ cabal repl lib:dhall
    >>> :set -XDeriveGeneric
    >>> :set -XDeriveAnyClass
    >>> data Amount = Debit Scientific | Credit Scientific deriving (Show, Generic, Inject, Interpret)
    >>> Dhall.Core.pretty (embed inject (Debit 5.45))
    "< Debit = { _1 = 5.45 } >"
    ```
    
    ... which is missing the `Credit` alternative.
    
    After this change you get the correct result:
    
    ```
    < Debit = { _1 = 5.45 } | Credit : { _1 : Double } >
    ```
    Gabriella439 committed Apr 1, 2018
    Configuration menu
    Copy the full SHA
    19d89c2 View commit details
    Browse the repository at this point in the history