[Haskell-cafe] Type-level lazy bool operations

Dmitry Olshansky olshanskydr at gmail.com
Sun Nov 15 13:13:31 UTC 2015


Hello, cafe!

There are some type-level boolean operation (If, &&, ||, Not) in Data.Type.Bool.
Are they lazy enough?

I faced with problem and it seems that the reason is non-lazy "If".
I.e. both (on-True and on-False) types are trying to be calculated.
Does it work in this way really? Could it be changed?

Then, looking into source I see such definition for (&&)

-- | Type-level "and"
type family a && b where
  'False && a      = 'False
  'True  && a      = a
  a      && 'False = 'False
  a      && 'True  = a
  a      && a      = a

Why we need the last three rules? Does it mean that an order of type
calculation is totaly undefined?

Dmitry


More information about the Haskell-Cafe mailing list