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

Proposal: allow automatic derivation of HFunctor instances. #170

Merged
merged 5 commits into from
May 7, 2019

Commits on May 6, 2019

  1. Proposal: allow automatic derivation of HFunctor instances.

    Generally speaking, the majority of effects do not require scoping,
    and as a result we encounter often this definition of `HFunctor`:
    
    ```haskell
    instance HFunctor MyEffect where
      hmap _ = coerce
    ```
    
    This definition is valid as long as there are no occurrences of a
    higher-order (i.e. scoped) variable in the effect. The `Coercible`
    typeclass allows us to express this in the type system:
    
    ```haskell
    default hmap :: Coercible (h m a) (h n a)
                 => (forall x . m x -> n x)
                 -> (h m a -> h n a)
    hmap _ = coerce
    ```
    
    By providing this as a valid default implementation of `hmap`, and
    enabling `DeriveAnyClass`/`DerivingStrategies` in effect definitions,
    we save cruft and boilerplate without any impact to backwards
    compatibility or performance.
    patrickt committed May 6, 2019
    Configuration menu
    Copy the full SHA
    a28304e View commit details
    Browse the repository at this point in the history

Commits on May 7, 2019

  1. Configuration menu
    Copy the full SHA
    fd5f24d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    faca34e View commit details
    Browse the repository at this point in the history
  3. Fix Teletype example.

    patrickt committed May 7, 2019
    Configuration menu
    Copy the full SHA
    2d3f6f6 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    a8141b0 View commit details
    Browse the repository at this point in the history