mirror of
https://github.com/github/semantic.git
synced 2024-12-24 23:42:31 +03:00
Decompose sequences deeply.
This commit is contained in:
parent
4b11270791
commit
6e5d4baa5f
@ -7,6 +7,7 @@ module Data.Core
|
||||
, lams
|
||||
, unlam
|
||||
, unseq
|
||||
, unseqs
|
||||
, ($$*)
|
||||
, unapply
|
||||
, unapplies
|
||||
@ -20,6 +21,7 @@ module Data.Core
|
||||
import Control.Applicative (Alternative (..))
|
||||
import Control.Monad (ap)
|
||||
import Data.Foldable (foldl')
|
||||
import Data.List.NonEmpty
|
||||
import Data.Loc
|
||||
import Data.Name
|
||||
import Data.Stack
|
||||
@ -82,6 +84,12 @@ unseq :: Alternative m => Core a -> m (Core a, Core a)
|
||||
unseq (a :>> b) = pure (a, b)
|
||||
unseq _ = empty
|
||||
|
||||
unseqs :: Core a -> NonEmpty (Core a)
|
||||
unseqs = go
|
||||
where go t = case unseq t of
|
||||
Just (l, r) -> go l <> go r
|
||||
Nothing -> t :| []
|
||||
|
||||
-- | Application of a function to a sequence of arguments.
|
||||
($$*) :: Foldable t => Core a -> t (Core a) -> Core a
|
||||
($$*) = foldl' (:$)
|
||||
|
Loading…
Reference in New Issue
Block a user