Skip to content

Commit

Permalink
Update indentation style
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Nov 11, 2024
1 parent e2b93f4 commit fe36b63
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 108 deletions.
128 changes: 61 additions & 67 deletions src/core/wisteria.ProductDerivationMethods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ import scala.compiletime.*

trait ProductDerivationMethods[TypeclassType[_]]:
protected transparent inline def construct[DerivationType <: Product]
(using reflection: ProductReflection[DerivationType], requirement: ContextRequirement)
(inline lambda: [FieldType] =>
(using reflection: ProductReflection[DerivationType], requirement: ContextRequirement)
(inline lambda: [FieldType] =>
requirement.Optionality[TypeclassType[FieldType]] =>
(typeclass: requirement.Optionality[TypeclassType[FieldType]],
default: Default[Optional[FieldType]],
label: Text,
index: Int & FieldIndex[FieldType]) ?=>
FieldType)
(typeclass: requirement.Optionality[TypeclassType[FieldType]],
default: Default[Optional[FieldType]],
label: Text,
index: Int & FieldIndex[FieldType]) ?=> FieldType)
: DerivationType =

type Fields = reflection.MirroredElemTypes
Expand All @@ -44,20 +43,19 @@ trait ProductDerivationMethods[TypeclassType[_]]:
.reverse

protected transparent inline def constructWith[ConstructorType[_]]
(using requirement: ContextRequirement)
[DerivationType <: Product]
(using reflection: ProductReflection[DerivationType])
(inline bind: [InputType, OutputType] => ConstructorType[InputType] =>
(InputType => ConstructorType[OutputType]) =>
ConstructorType[OutputType],
inline pure: [MonadicType] => MonadicType => ConstructorType[MonadicType],
inline lambda: [FieldType] =>
requirement.Optionality[TypeclassType[FieldType]] =>
(typeclass: requirement.Optionality[TypeclassType[FieldType]],
default: Default[Optional[FieldType]],
label: Text,
index: Int & FieldIndex[FieldType]) ?=>
ConstructorType[FieldType])
(using requirement: ContextRequirement)
[DerivationType <: Product]
(using reflection: ProductReflection[DerivationType])
(inline bind: [InputType, OutputType] => ConstructorType[InputType] =>
(InputType => ConstructorType[OutputType]) => ConstructorType[OutputType],
inline pure: [MonadicType] => MonadicType => ConstructorType[MonadicType],
inline lambda: [FieldType] =>
requirement.Optionality[TypeclassType[FieldType]] =>
(typeclass: requirement.Optionality[TypeclassType[FieldType]],
default: Default[Optional[FieldType]],
label: Text,
index: Int & FieldIndex[FieldType]) ?=>
ConstructorType[FieldType])
: ConstructorType[DerivationType] =

type Fields = reflection.MirroredElemTypes
Expand All @@ -75,16 +73,15 @@ trait ProductDerivationMethods[TypeclassType[_]]:
pure(reflection.fromProduct(tuple.reverse))

protected transparent inline def contexts[DerivationType <: Product]
(using reflection: ProductReflection[DerivationType], requirement: ContextRequirement)
[ResultType]
(inline lambda: [FieldType] =>
requirement.Optionality[TypeclassType[FieldType]] =>
(typeclass: requirement.Optionality[TypeclassType[FieldType]],
default: Default[Optional[FieldType]],
label: Text,
dereference: DerivationType => FieldType,
index: Int & FieldIndex[FieldType]) ?=>
ResultType)
(using reflection: ProductReflection[DerivationType], requirement: ContextRequirement)
[ResultType]
(inline lambda: [FieldType] =>
requirement.Optionality[TypeclassType[FieldType]] =>
(typeclass: requirement.Optionality[TypeclassType[FieldType]],
default: Default[Optional[FieldType]],
label: Text,
dereference: DerivationType => FieldType,
index: Int & FieldIndex[FieldType]) ?=> ResultType)
: IArray[ResultType] =

type Fields = reflection.MirroredElemTypes
Expand All @@ -109,10 +106,10 @@ trait ProductDerivationMethods[TypeclassType[_]]:
case _ => false

protected transparent inline def complement[DerivationType <: Product, FieldType]
(product: DerivationType)
(using fieldIndex: Int & FieldIndex[FieldType],
reflection: ProductReflection[DerivationType],
requirement: ContextRequirement)
(product: DerivationType)
(using fieldIndex: Int & FieldIndex[FieldType],
reflection: ProductReflection[DerivationType],
requirement: ContextRequirement)
: FieldType =

type Labels = reflection.MirroredElemLabels
Expand All @@ -125,16 +122,15 @@ trait ProductDerivationMethods[TypeclassType[_]]:
.vouch(using Unsafe)

protected transparent inline def fields[DerivationType <: Product](inline product: DerivationType)
(using requirement: ContextRequirement)
(using reflection: ProductReflection[DerivationType])
[ResultType]
(inline lambda: [FieldType] =>
FieldType =>
(context: requirement.Optionality[TypeclassType[FieldType]],
default: Default[Optional[FieldType]],
label: Text,
index: Int & FieldIndex[FieldType]) ?=>
ResultType)
(using requirement: ContextRequirement)
(using reflection: ProductReflection[DerivationType])
[ResultType]
(inline lambda: [FieldType] =>
FieldType =>
(context: requirement.Optionality[TypeclassType[FieldType]],
default: Default[Optional[FieldType]],
label: Text,
index: Int & FieldIndex[FieldType]) ?=> ResultType)
: IArray[ResultType] =

summonInline[ClassTag[ResultType]].give:
Expand All @@ -155,17 +151,16 @@ trait ProductDerivationMethods[TypeclassType[_]]:
// erasedness of the tuple.

private transparent inline def fold
[DerivationType <: Product, FieldsType <: Tuple, LabelsType <: Tuple, ResultType]
(using requirement: ContextRequirement)
(inline tuple: FieldsType, accumulator: ResultType, index: Int)
(inline lambda: ResultType =>
[FieldType] =>
FieldType =>
(context: Optional[TypeclassType[FieldType]],
default: Default[Optional[FieldType]],
label: Text,
index: Int & FieldIndex[FieldType]) ?=>
ResultType)
[DerivationType <: Product, FieldsType <: Tuple, LabelsType <: Tuple, ResultType]
(using requirement: ContextRequirement)
(inline tuple: FieldsType, accumulator: ResultType, index: Int)
(inline lambda: ResultType =>
[FieldType] =>
FieldType =>
(context: Optional[TypeclassType[FieldType]],
default: Default[Optional[FieldType]],
label: Text,
index: Int & FieldIndex[FieldType]) ?=> ResultType)
: ResultType =

inline tuple match
Expand All @@ -192,17 +187,16 @@ trait ProductDerivationMethods[TypeclassType[_]]:
(lambda)

private transparent inline def fold
[DerivationType <: Product, FieldsType <: Tuple, LabelsType <: Tuple, ResultType]
(using requirement: ContextRequirement)
(inline accumulator: ResultType, index: Int)
(inline lambda: ResultType =>
[FieldType] =>
requirement.Optionality[TypeclassType[FieldType]] =>
(default: Default[Optional[FieldType]],
label: Text,
dereference: DerivationType => FieldType,
index: Int & FieldIndex[FieldType]) ?=>
ResultType)
[DerivationType <: Product, FieldsType <: Tuple, LabelsType <: Tuple, ResultType]
(using requirement: ContextRequirement)
(inline accumulator: ResultType, index: Int)
(inline lambda: ResultType =>
[FieldType] =>
requirement.Optionality[TypeclassType[FieldType]] =>
(default: Default[Optional[FieldType]],
label: Text,
dereference: DerivationType => FieldType,
index: Int & FieldIndex[FieldType]) ?=> ResultType)
: ResultType =

inline erasedValue[FieldsType] match
Expand Down
78 changes: 39 additions & 39 deletions src/core/wisteria.SumDerivationMethods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ trait SumDerivationMethods[TypeclassType[_]]:
case _ => false

protected transparent inline def complement[DerivationType, VariantType](sum: DerivationType)
(using variantIndex: Int & VariantIndex[VariantType],
reflection: SumReflection[DerivationType])
(using variantIndex: Int & VariantIndex[VariantType],
reflection: SumReflection[DerivationType])
: Optional[VariantType] =

type Labels = reflection.MirroredElemLabels
Expand All @@ -51,20 +51,20 @@ trait SumDerivationMethods[TypeclassType[_]]:
if index == variantIndex then field.asInstanceOf[VariantType] else Unset

protected inline def variantLabels[DerivationType]
(using reflection: SumReflection[DerivationType])
(using reflection: SumReflection[DerivationType])
: List[Text] =

constValueTuple[reflection.MirroredElemLabels].toList.map(_.toString.tt)

protected transparent inline def delegate[DerivationType](label: Text)
(using reflection: SumReflection[DerivationType], requirement: ContextRequirement)
[ResultType]
(inline lambda: [VariantType <: DerivationType] =>
requirement.Optionality[TypeclassType[VariantType]] =>
(context: requirement.Optionality[TypeclassType[VariantType]],
label: Text,
index: Int & VariantIndex[VariantType]) ?=>
ResultType)
(using reflection: SumReflection[DerivationType], requirement: ContextRequirement)
[ResultType]
(inline lambda: [VariantType <: DerivationType] =>
requirement.Optionality[TypeclassType[VariantType]] =>
(context: requirement.Optionality[TypeclassType[VariantType]],
label: Text,
index: Int & VariantIndex[VariantType]) ?=>
ResultType)
: ResultType =

type Labels = reflection.MirroredElemLabels
Expand All @@ -79,14 +79,14 @@ trait SumDerivationMethods[TypeclassType[_]]:
.vouch(using Unsafe)

protected transparent inline def variant[DerivationType](sum: DerivationType)
(using reflection: SumReflection[DerivationType], requirement: ContextRequirement)
[ResultType]
(inline lambda: [VariantType <: DerivationType] =>
VariantType =>
(context: requirement.Optionality[TypeclassType[VariantType]],
label: Text,
index: Int & VariantIndex[VariantType]) ?=>
ResultType)
(using reflection: SumReflection[DerivationType], requirement: ContextRequirement)
[ResultType]
(inline lambda: [VariantType <: DerivationType] =>
VariantType =>
(context: requirement.Optionality[TypeclassType[VariantType]],
label: Text,
index: Int & VariantIndex[VariantType]) ?=>
ResultType)
: ResultType =

type Labels = reflection.MirroredElemLabels
Expand All @@ -99,16 +99,16 @@ trait SumDerivationMethods[TypeclassType[_]]:
.vouch(using Unsafe)

private transparent inline def fold[DerivationType, VariantsType <: Tuple, LabelsType <: Tuple]
(inline inputLabel: Text, size: Int, index: Int, fallible: Boolean)
(using reflection: SumReflection[DerivationType], requirement: ContextRequirement)
(inline predicate: (label: Text, index: Int & VariantIndex[DerivationType]) ?=> Boolean)
[ResultType]
(inline lambda: [VariantType <: DerivationType] =>
requirement.Optionality[TypeclassType[VariantType]] =>
(context: requirement.Optionality[TypeclassType[VariantType]],
label: Text,
index: Int & VariantIndex[VariantType]) ?=>
ResultType)
(inline inputLabel: Text, size: Int, index: Int, fallible: Boolean)
(using reflection: SumReflection[DerivationType], requirement: ContextRequirement)
(inline predicate: (label: Text, index: Int & VariantIndex[DerivationType]) ?=> Boolean)
[ResultType]
(inline lambda: [VariantType <: DerivationType] =>
requirement.Optionality[TypeclassType[VariantType]] =>
(context: requirement.Optionality[TypeclassType[VariantType]],
label: Text,
index: Int & VariantIndex[VariantType]) ?=>
ResultType)
: Optional[ResultType] =

inline erasedValue[VariantsType] match
Expand Down Expand Up @@ -138,16 +138,16 @@ trait SumDerivationMethods[TypeclassType[_]]:
else throw Panic(m"Should be unreachable")

private transparent inline def fold[DerivationType, VariantsType <: Tuple, LabelsType <: Tuple]
(inline sum: DerivationType, size: Int, index: Int, fallible: Boolean)
(using reflection: SumReflection[DerivationType], requirement: ContextRequirement)
(inline predicate: (label: Text, index: Int & VariantIndex[DerivationType]) ?=> Boolean)
[ResultType]
(inline lambda: [VariantType <: DerivationType] =>
VariantType =>
(context: requirement.Optionality[TypeclassType[VariantType]],
label: Text,
index: Int & VariantIndex[VariantType]) ?=>
ResultType)
(inline sum: DerivationType, size: Int, index: Int, fallible: Boolean)
(using reflection: SumReflection[DerivationType], requirement: ContextRequirement)
(inline predicate: (label: Text, index: Int & VariantIndex[DerivationType]) ?=> Boolean)
[ResultType]
(inline lambda: [VariantType <: DerivationType] =>
VariantType =>
(context: requirement.Optionality[TypeclassType[VariantType]],
label: Text,
index: Int & VariantIndex[VariantType]) ?=>
ResultType)
: Optional[ResultType] =

inline erasedValue[VariantsType] match
Expand Down
4 changes: 2 additions & 2 deletions src/core/wisteria.VariantError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import scala.compiletime.*

object VariantError:
inline def apply[DerivationType](inputLabel: Text)
(using reflection: SumReflection[DerivationType], diagnostics: Diagnostics)
(using reflection: SumReflection[DerivationType], diagnostics: Diagnostics)
: VariantError =

val variants = constValueTuple[reflection.MirroredElemLabels].toList.map(_.toString.tt)
Expand All @@ -35,4 +35,4 @@ object VariantError:

case class VariantError(inputLabel: Text, sum: Text, validVariants: List[Text])(using Diagnostics)
extends Error
(m"""the specified variant ($inputLabel) is not one of the valid variants (${validVariants.mkString(", ").tt}) of sum type $sum""")
(m"""the specified variant ($inputLabel) is not one of the valid variants (${validVariants.mkString(", ").tt}) of sum type $sum""")

0 comments on commit fe36b63

Please sign in to comment.