-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Labels
Description
The following type family is often useful:
type LazyTake :: Nat -> [k] -> [k]
type family LazyTake n xs where
LazyTake 0 _ = '[]
LazyTake n xs = Head xs ': LazyTake (n - 1) (Tail xs)This is a promoted version of the (partial) function
lazyTake :: Natural -> [a] -> [a]
lazyTake 0 _ = []
lazyTake n xs = head xs : lazyTake (n - 1) (tail xs)It's useful in constructions like
type LengthAtLeast n xs = xs ~ LazyTake n xs ++ Drop n xsI imagine this package is not the one such a thing belongs in; any guess where I might find it, or where it might fit?