-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Infer better type for regular operations on Rule1[_] (#48)
- Loading branch information
Showing
4 changed files
with
38 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/scala/com/github/zenpie/macrowave/support/SingletonRule.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.github.zenpie.macrowave.support | ||
|
||
import com.github.zenpie.macrowave._ | ||
|
||
trait SingletonRule[T] { | ||
type Out | ||
} | ||
|
||
object SingletonRule extends SingletonRuleLowPriorityImplicits { | ||
|
||
type Aux[T, Out0] = SingletonRule[T] { | ||
type Out = Out0 | ||
} | ||
|
||
implicit val hnil: SingletonRule.Aux[HNil, HNil] = new SingletonRule[HNil] { | ||
type Out = HNil | ||
} | ||
|
||
implicit def hcons1[T]: SingletonRule.Aux[T :: HNil, T] = new SingletonRule[T :: HNil] { | ||
type Out = T | ||
} | ||
|
||
} | ||
|
||
trait SingletonRuleLowPriorityImplicits { | ||
|
||
implicit def hconsN[H, T <: HList]: SingletonRule.Aux[H :: T, H :: T] = new SingletonRule[H :: T] { | ||
type Out = H :: T | ||
} | ||
|
||
} |