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

Set up Machinist, use macros for Eq through Order syntax. #79

Merged
merged 4 commits into from
Feb 5, 2015

Conversation

non
Copy link
Contributor

@non non commented Feb 5, 2015

This commit adds cats-macros, upon which cats depends.
Right now, the only macros being used are Machinist's
operator macros, which are configured in cats.macros.Ops.

The punchline of doing this is that:

def xyz[A: Eq](x: A, y: A): Boolean =
  x === y

is now exactly the same as:

def xyz[A](x: A, y: A)(implicit A: Eq[A]): Boolean =
  A.eqv(x, y)

i.e. the syntax implicit conversions are completely erased.
This eliminates the performance penalty that syntax normally
implies. It also means the syntax classes don't need to be
value classes (or specialized) since they are not used at
runtime.

This commit adds cats-macros, upon which cats depends.
Right now, the only macros being used are Machinist's
operator macros, which are configured in cats.macros.Ops.

The punchline of doing this is that:

    def xyz[A: Eq](x: A, y: A): Boolean =
      x === y

is now exactly the same as:

    def xyz[A](x: A, y: A)(implicit A: Eq[A]): Boolean =
      A.eqv(x, y)

i.e. the syntax implicit conversions are completely erased.
This eliminates the performance penalty that syntax normally
implies. It also means the syntax classes don't need to be
value classes (or specialized) since they are not used at
runtime.
@non non added the in progress label Feb 5, 2015
@non
Copy link
Contributor Author

non commented Feb 5, 2015

(This fixes #78.)

This commit:

  1. Adds -language:experimental.macros
  2. Removes a bunch of imports
  3. Fixes the algebra -> cats type aliases
@travisbrown
Copy link
Contributor

This looks good to me, so I'd be happy to have it merged and just close #80.

@stew
Copy link
Contributor

stew commented Feb 5, 2015

oh oops, I just merged #80

@non
Copy link
Contributor Author

non commented Feb 5, 2015

@travisbrown @stew I think the commit I just pushed cleans it up. If this is green I think it's ready.

@travisbrown
Copy link
Contributor

👍

stew added a commit that referenced this pull request Feb 5, 2015
Set up Machinist, use macros for Eq through Order syntax.
@stew stew merged commit 85930c4 into master Feb 5, 2015
@stew stew removed the in progress label Feb 5, 2015
@ceedubs ceedubs mentioned this pull request Feb 6, 2015
@non non deleted the topic/machinist-syntax branch February 18, 2015 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants