On Wed, Aug 22, 2012 at 1:33 PM, Dave <
dave.mah...@hotmail.com> wrote:
> imo this is correct since flatten is a monadic natural transformation mu
> The inner type constructor must be the same as the outer type constructor
> otherwise you cannot do a flatten.
> It is afaik actually unboxing from boxes with equal type constructors.
>
> e.g. this works
>
> scala> Seq(Seq(1)).flatten
> res0: Seq[Int] = List(1)
> scala> Some(Some(1)).flatten
> res1: Option[Int] = Some(1)
>
> I would say that
> scala> Seq(Some(1)).flatten
> res2: Seq[Int] = List(1)
> is an error. It should raise a compile time error.
> But I don't know why this is permitted by scala.
>
> It looks like scala has different notions of flatten:
> in one meaning it means just unboxing,
> in the other meaning it means unboxing from boxes with the same type
> constructors.