Id
documentation states
The identity monad ... is ambient in the sense that plain pure values are values of
Id
.
What is an ambient? How is the term ambient related to the meaning of pure values? Why can we say pure value of Id
, when Id
is a type constructor? Then again, is Id
actually a type constructor or a proper type because :kind
commands gives no output
scala> type Id[A] = A
type Id
scala> :kind -v Id
scala>
ambient
is not a term related to FP or type system, but rather metaphor.
Saying ambient
they probably mean that it is wrapping existing type without actually effecting it too much.
val i:Id[Int] = 3
val i2:Int = i // Id[Int]==Int
Saying plain pure values are values of Id
they mean that any value of type X
is also a value of Id[X]
.
val i:Id[Int] = 3:Int
val s:Id[String] = "3":String
You can think of type Id[A] = A
as a "function on type level" that returns its parameter A
.
Something like this, but on type level:
def Id[T](i:T):T = i
There is no such term as "function on type level", but each type constructor is analogue of function on the type system level.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With