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