Difference between Haskell and Idris: Reflection of Runtime/Compiletime in the type universes

Yes, you’re right to observe that the types versus values distinction in Idris does not align with the compiletime-only versus runtime-and-compiletime distinction. That’s a good thing. It is useful to have values which exist only at compiletime, just as in program logics we have “ghost variables” used only in specifications. It is useful also to … Read more

What are some examples of type-level programming? [closed]

You’re already familiar with “value-level” programming, whereby you manipulate values such as42 :: Int or ‘a’ :: Char. In languages like Haskell, Scala, and many others, type-level programming allows you to manipulate types like Int :: * or Char :: * where * is the kind of a concrete type (Maybe a or [a] are … Read more

Using the “Prolog in Scala” to find available type class instances

This can be done (at least in some cases) with compiler internals import scala.language.experimental.macros import scala.reflect.internal.util import scala.reflect.macros.{blackbox, contexts} object Macros { def allImplicits[A]: List[String] = macro impl[A] def impl[A: c.WeakTypeTag](c: blackbox.Context): c.Tree = { import c.universe._ val context = c.asInstanceOf[contexts.Context] val global: context.universe.type = context.universe val analyzer: global.analyzer.type = global.analyzer val callsiteContext = context.callsiteTyper.context … Read more

Why is the Aux technique required for type-level computations?

There are two separate questions here: Why does Shapeless use type members instead of type parameters in some cases in some type classes? Why does Shapeless include Aux type aliases in the companion objects of these type classes? I’ll start with the second question because the answer is more straightforward: the Aux type aliases are … Read more

Testing an assertion that something must not compile

Not a framework, but Jorge Ortiz (@JorgeO) mentioned some utilities he added to the tests for Foursquare’s Rogue library at NEScala in 2012 which support tests for non-compilation: you can find examples here. I’ve been meaning to add something like this to shapeless for quite a while. More recently, Roland Kuhn (@rolandkuhn) has added a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)