@@ -39,13 +39,13 @@ object Instances extends Common with
39
39
if (fst != 0 ) fst else xs1.compareTo(ys1)
40
40
end listOrd
41
41
42
- given stringOps : with
43
- def ( xs : Seq [ String ]) longestStrings : Seq [String ] =
42
+ given stringOps : ( xs : Seq [ String ]) with
43
+ def longestStrings : Seq [String ] =
44
44
val maxLength = xs.map(_.length).max
45
45
xs.filter(_.length == maxLength)
46
46
47
- given with
48
- def ( xs : List [ T ]) second[ T ] = xs.tail.head
47
+ given [ T ]( xs : List [ T ]) with
48
+ def second = xs.tail.head
49
49
50
50
given listMonad : Monad [List ] with
51
51
def (xs : List [A ]) flatMap[A , B ] (f : A => List [B ]): List [B ] =
@@ -130,15 +130,11 @@ end Instances
130
130
object PostConditions with
131
131
opaque type WrappedResult [T ] = T
132
132
133
- private given WrappedResult : with
134
- def apply [T ](x : T ): WrappedResult [T ] = x
135
- def (x : WrappedResult [T ]) unwrap[T ]: T = x
133
+ def result [T ](given x : WrappedResult [T ]): T = x
136
134
137
- def result [T ](given wrapped : WrappedResult [T ]): T = wrapped.unwrap
138
-
139
- given with
140
- def (x : T ) ensuring[T ] (condition : (given WrappedResult [T ]) => Boolean ): T =
141
- assert(condition(given WrappedResult (x)))
135
+ given [T ](x : T ) with
136
+ def ensuring (condition : (given WrappedResult [T ]) => Boolean ): T =
137
+ assert(condition(given x ))
142
138
x
143
139
end PostConditions
144
140
0 commit comments