-
Notifications
You must be signed in to change notification settings - Fork 2
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
Restrict value type of Relations to (AnyVal ∨ String) #33
Comments
What about dates, timestamps and so on? |
I see two possible solutions for dates and times:
I personally prefer the first option. |
I try to avoid using the old This will lead to a more complex context-bound as well: object ColumnDef {
type ¬[A] = A => Nothing // ~ type-negation
type ¬¬[A] = ¬[¬[A]] // ~ type-double-negation to compensate for union-notation
// recursive definition
trait Disj[T] {
type or[S] = Disj[T with ¬[S]]
type apply[X] = ¬¬[X] <:< ¬[T]
}
// for convenience
type |∨|[T] = { type or[S] = Disj[¬[T]]#or[S] }
def apply[T: |∨|[AnyVal]#or[String]#or[ZonedDateTime]#apply](name: String)(implicit ct: ClassTag[T]): ColumnDef[T] =
new ColumnDef[T](name)(ct)
} This time I used a recursive definition of the union of two types. |
As of PR #102 the type-bound for cell types is explicitly set to class ColumnDef[+T <: Any](... It is also covariant to comply with our map-based implementation for |
Issue
I suggest using type constraints to restrict the domain of possible value types (
T
) for the creation ofColumnDef[T]
s to(AnyVal ∨ String)
. This would allow following types:AnyVal
,Byte
,Short
,Int
,Long
,Float
,Double
,Char
,Boolean
String
(asString -> CharSequence -> Object -> Any
, we need to include it separately)T extends AnyVal
)Problem Description
Currently, it is possible to create arbitrary complex types for usage in
Relation
s. E.g.:Supporting Information
Possible implementation for restricting the value type of relations via the factory method in the companion object of
ColumnDef[T]
:see Miles Sabin (2009): Unboxed union types in Scala via the Curry-Howard isomorphism
The text was updated successfully, but these errors were encountered: