⊹ (from SemigroupOps) not defined for Some/None

24 views
Skip to first unread message

Andreas Joseph Krogh

unread,
Mar 17, 2016, 6:18:28 AM3/17/16
to scalaz
Hi.

Why doesn't the following work?

import scalaz.syntax.semigroup.ToSemigroupOps
import scalaz.std.AllInstances._

val fisk = Some(1) None

Error:(46, 22) value ⊹ is not a member of Some[Int]
        val fisk = Some(1) ⊹ None
                           ^

I know that it works for Option[Int], but why not Some[Int]? and None?

Thanks.

--
Andreas

Gary Pamparà

unread,
Mar 17, 2016, 6:30:02 AM3/17/16
to scalaz
In scala, Some and None are regarded as types, but they are really data constructors that create data of type Option[A]. This is why the semigroup works for Option, but not it's constructors

--
You received this message because you are subscribed to the Google Groups "scalaz" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalaz+un...@googlegroups.com.
To post to this group, send email to sca...@googlegroups.com.
Visit this group at https://groups.google.com/group/scalaz.
For more options, visit https://groups.google.com/d/optout.

Andreas Joseph Krogh

unread,
Mar 17, 2016, 6:32:12 AM3/17/16
to scalaz
Thanks.

Is there a way (or a plan) to make them work for constructors?

Kevin Wright

unread,
Mar 17, 2016, 6:35:47 AM3/17/16
to sca...@googlegroups.com
In practice, you’d *never* see an instance of None.type - it would always be an Option[T] to which the value None had been assigned.

For Some, the convention in scalar is to use 1.some (which returns an Option[Int]) instead of Some(1) (which returns Some[Int])

Andreas Joseph Krogh

unread,
Mar 17, 2016, 6:40:04 AM3/17/16
to scalaz
Ah, good to know about the 1.some convention, thanks.
Reply all
Reply to author
Forward
0 new messages