Skip to content

Commit

Permalink
Improve given style
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jun 12, 2024
1 parent 2a3ee4a commit 3c14179
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/core/wisteria.ContextRequirement.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import vacuous.*
import scala.compiletime.*

object ContextRequirement:
given required: ContextRequirement with
given ContextRequirement as required:
type Optionality[Type] = Type
type Required = true
def wrap[ValueType](optional: Optional[ValueType]): ValueType = optional.vouch(using Unsafe)
Expand Down
5 changes: 3 additions & 2 deletions src/core/wisteria.Derivation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import scala.compiletime.*
trait Derivation[TypeclassType[_]]
extends ProductDerivationMethods[TypeclassType], SumDerivationMethods[TypeclassType]:

inline given derived[DerivationType](using Reflection[DerivationType])
: TypeclassType[DerivationType] =
inline given [DerivationType](using Reflection[DerivationType])
=> TypeclassType[DerivationType] as derived =

inline summon[Reflection[DerivationType]] match
case reflection: ProductReflection[derivationType] =>
join[derivationType](using reflection).asMatchable match
Expand Down
6 changes: 3 additions & 3 deletions src/core/wisteria.ProductDerivationMethods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ trait ProductDerivationMethods[TypeclassType[_]]:
accumulator =>
[FieldType] => context ?=>
bind(accumulator): accumulator2 =>
bind(lambda[FieldType](context)): result =>
bind(lambda[FieldType](context)): result =>
pure(result *: accumulator2)

bind(tuple): tuple =>
bind(tuple): tuple =>
pure(reflection.fromProduct(tuple.reverse))

protected transparent inline def contexts[DerivationType <: Product]
Expand Down Expand Up @@ -145,7 +145,7 @@ trait ProductDerivationMethods[TypeclassType[_]]:
IArray.create[ResultType](tuple.size): array =>
fold[DerivationType, Fields, Labels, Unit](tuple, (), 0): unit =>
[FieldType] => field =>
given typeclass: requirement.Optionality[TypeclassType[FieldType]] =
given requirement.Optionality[TypeclassType[FieldType]] as typeclass =
requirement.wrap(context)

array(index) = lambda[FieldType](field)
Expand Down

0 comments on commit 3c14179

Please sign in to comment.