You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, @Iltotore thanks for a great library, it's a real pleasure to use iron.
I have a case where I want a string validated as composed of only certain characters, which I define as a union of constraints, but I'm having a tough time getting a value refined by a particular constraint in that union to be recognised as satisfying the union of constraints.
This came up originally when creating a org.scalacheck.Arbitrary instance for the narrower type, but here's a reduced example after some tinkering in the REPL...
importio.github.iltotore.iron.:|importio.github.iltotore.iron.constraint.any.StrictEqualimportio.github.iltotore.iron.constraint.char.{ Digit, Letter }
importio.github.iltotore.iron.scalacheck.char.given// I want only alphanumeric or a common field delimited.typeGoodChar=Digit|Letter|StrictEqual["_"] |StrictEqual["-"]
// compilesvalhyphen:Char:|StrictEqual['-'] = {
importio.github.iltotore.iron.autoRefine'-'
}
// compilesvallistOfHyphen:List[Char:|StrictEqual['-']] =List(hyphen, hyphen)
// doesn't compilevallistOfGoodChar:List[Char:|GoodChar] = {
importio.github.iltotore.iron.autoRefine
listOfHyphen
}
// compilesvalletterA:Char:|Letter= {
importio.github.iltotore.iron.autoRefine'A'
}
// doesn't compilevalwiderA:Char:|GoodChar= letterA
The text was updated successfully, but these errors were encountered:
My thought was that I perhaps need an Implication in scope relating the wider, union constraint to one of its individual, component constraints, but I wasn't sure if this...
a) should already be automatic
b) requires additional import(s)
c) requires manual definition of the implication relation
d) none of the above
?
Ah, it was autoCastIron that was missing. With that imported, I get the expected subtyping relation with the union and one of its components. Sorry for the noise.
Hello, @Iltotore thanks for a great library, it's a real pleasure to use
iron
.I have a case where I want a string validated as composed of only certain characters, which I define as a union of constraints, but I'm having a tough time getting a value refined by a particular constraint in that union to be recognised as satisfying the union of constraints.
This came up originally when creating a
org.scalacheck.Arbitrary
instance for the narrower type, but here's a reduced example after some tinkering in the REPL...The text was updated successfully, but these errors were encountered: