-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazy Take? #539
Comments
I'm not aware of any package that provides this. Out of curiosity, does defining this lazily actually make a difference in practice on the type level? I was under the impression that the order of evaluation in type family equations wasn't specified. |
Oh yes, definitely. The reduction semantics are not fully specified: type family Loop :: [Bool] where
Loop = Loop
> :kind LazyTake 0 Loop
-- unspecified result However, type family Stuck :: [Bool] where
> :kind! LazyTake 0 Stuck
'[]
> :kind! LazyTake 2 Stuck
'[Head Stuck, Head (Tail Stuck)] If I'm not very much mistaken, > :kind! LazyTake 0 (TypeError ...)
'[]
> :kind! Length (LazyTake 2 (TypeError ...))
2
> :kind! LazyTake 2 (TypeError ...)
<Uh oh some errors> In practice, the irretrievably stuck and type error cases are rather dull; reduction will make progress but usually fail somewhere else. But the ambiguous and polymorphic cases can allow useful type information to flow. |
I see, that is surprisingly nuanced. To be honest, I'm not even sure if there is a Haskell library that provides a term-level |
Not everything useful at the type level is equally useful at the term level. I rarely want Disclosure: in what I'm actually working on, we're using inductive naturals instead of garbage ones (except at the edges of the API), so I wouldn't likely use a GHC |
The following type family is often useful:
This is a promoted version of the (partial) function
It's useful in constructions like
I imagine this package is not the one such a thing belongs in; any guess where I might find it, or where it might fit?
The text was updated successfully, but these errors were encountered: