+isValue env (Lam b e)
+ | isTyVar b = isValue env e
+ | otherwise = Just LambdaVal
+
+isValue env expr -- Maybe it's a constructor application
+ | (Var fun, args) <- collectArgs expr
+ = case isDataConWorkId_maybe fun of
+
+ Just con | args `lengthAtLeast` dataConRepArity con
+ -- Check saturated; might be > because the
+ -- arity excludes type args
+ -> Just (ConVal (DataAlt con) args)
+
+ other | valArgCount args < idArity fun
+ -- Under-applied function
+ -> Just LambdaVal -- Partial application
+
+ other -> Nothing
+
+isValue env expr = Nothing