Type level as-patterns
Hello! I would love to see type level as-patterns in Haskell. They would be very helpfull when writing complex type families. Here is a good example:
type family XOut m1 m2 where
XOut (ValueS vbase vs) (MonadCtx2Dummy' m2 s2 env set m s) = MonadCtx2Dummy' m2 s2 (XEnv env (ValueS vbase vs)) (XSet set (ValueS vbase vs)) m (XSafety s (ValueS vbase vs))
could then be written as:
type family XOut m1 m2 where
XOut a@(ValueS vbase vs) (MonadCtx2Dummy' m2 s2 env set m s) = MonadCtx2Dummy' m2 s2 (XEnv env a) (XSet set a) m (XSafety s a)
which is much cleaner, less verbose and lot safer than the first one. (Safer in terms of accidental typos when refactoring etc).
Cheers, Wojciech
Edited by danilo2