@@ -18,30 +18,30 @@ import poly.{~>}
1818 */
1919object PolyExercises extends FlatSpec with Matchers with org.scalaexercises.definitions.Section {
2020
21- object choose extends (Set ~> Option ) {
22- def apply [T ](s : Set [T ]) = s.headOption
21+ object choose extends (Seq ~> Option ) {
22+ def apply [T ](s : Seq [T ]) = s.headOption
2323 }
2424
25- /** `choose` is a function from Sets to Options with no type specific cases
25+ /** `choose` is a function from Seqs to Options with no type specific cases
2626 * {{{
27- * object choose extends (Set ~> Option) {
28- * def apply[T](s : Set [T]) = s.headOption
27+ * object choose extends (Seq ~> Option) {
28+ * def apply[T](s : Seq [T]) = s.headOption
2929 * }
3030 * }}}
3131 */
3232 def exerciseChoose (res0 : Option [Int ], res1 : Option [Char ]) = {
3333 import shapeless .poly ._
34- // choose is a function from Sets to Options with no type specific cases
34+ // choose is a function from Seqs to Options with no type specific cases
3535
36- choose(Set (1 , 2 , 3 )) should be(res0)
37- choose(Set ('a' , 'b' , 'c' )) should be(res1)
36+ choose(Seq (1 , 2 , 3 )) should be(res0)
37+ choose(Seq ('a' , 'b' , 'c' )) should be(res1)
3838 }
3939
4040 /** Being polymorphic, they may be passed as arguments to functions or methods and then applied to values of different types
4141 * within those functions
4242 */
4343 def exercisePairApply (res0 : Option [Int ], res1 : Option [Char ]) = {
44- def pairApply (f : Set ~> Option ) = (f(Set (1 , 2 , 3 )), f(Set ('a' , 'b' , 'c' )))
44+ def pairApply (f : Seq ~> Option ) = (f(Seq (1 , 2 , 3 )), f(Seq ('a' , 'b' , 'c' )))
4545
4646 pairApply(choose) should be(res0, res1)
4747 }
@@ -51,7 +51,7 @@ object PolyExercises extends FlatSpec with Matchers with org.scalaexercises.defi
5151 * mapped across an ordinary Scala List
5252 */
5353 def exerciseMonomorphicChoose (res0 : Option [Int ], res1 : Option [Int ]) =
54- (List (Set (1 , 3 , 5 ), Set (2 , 4 , 6 )) map choose) should be(List (res0, res1))
54+ (List (Seq (1 , 3 , 5 ), Seq (2 , 4 , 6 )) map choose) should be(List (res0, res1))
5555
5656 /** However, they are [[http://www.chuusai.com/2012/05/10/shapeless-polymorphic-function-values-2/ more general than natural transformations ]] and are able to capture type-specific cases
5757 * which, as we'll see below, makes them ideal for generic programming,
0 commit comments