Unable to map on HList

There’s an easy fix: just define your function as an object instead of a val: object f extends (({ type O2[+A] = (Option[A], Option[A]) })#O2 ~> Option) { def apply[A](x: (Option[A], Option[A])): Option[A] = x._1 orElse x._2 } (Note that I’ve named the function f instead of mapper to avoid confusion with the mapper implicit … Read more

Compile-time and runtime casting c#

Upcasts can be checked at compile time – the type system guarantees that the cast succeeds. Downcasts cannot (in general) be checked at compile time, so they are always checked at runtime. Unrelated types cannot be cast to each other. The compiler considers only the static types. The runtime checks the dynamic (runtime) type. Looking … Read more

What are some compelling use cases for dependent method types?

More or less any use of member (ie. nested) types can give rise to a need for dependent method types. In particular, I maintain that without dependent method types the classic cake pattern is closer to being an anti-pattern. So what’s the problem? Nested types in Scala are dependent on their enclosing instance. Consequently, in … Read more