1. 2
  1.  

  2. 1

    Singleton values should belong to Identity, that way they’d be a part of Traversable, Foldable, Functor, Monad, etc. Scala kind-of allows this, but not completely implicitly:

    // Following works!
    val three: Id[Int] = 3
    three.map(_ + 1)
    
    // Sadly this doesn't:
    3.map(_ + 1)
    
    1. 1

      from what I understand, R does just that without any macroscopic issue

      > a <- 1
      > b <- c(1,2,3)
      > class(a)
      [1] "numeric"
      > class(b)
      [1] "numeric"
      > a+b
      [1] 2 3 4
      > sum(a)
      [1] 1
      > sum(b)
      [1] 6
      > for(e in a) print(e)
      [1] 1
      > for(e in b) print(e)
      [1] 1
      [1] 2
      [1] 3