mirror of
https://github.com/github/semantic.git
synced 2024-12-23 06:41:45 +03:00
Note the awful complexity of rToCV.
This commit is contained in:
parent
440cc2e792
commit
5b32f9d1b6
@ -123,6 +123,8 @@ fToR :: Functor (Base t) => FAlgebra t a -> RAlgebra t a
|
|||||||
fToR f = f . fmap snd
|
fToR f = f . fmap snd
|
||||||
|
|
||||||
-- | Promote an RAlgebra into a CVAlgebra (by dropping all values except the most recent).
|
-- | Promote an RAlgebra into a CVAlgebra (by dropping all values except the most recent).
|
||||||
|
--
|
||||||
|
-- Note that this is in general O(n), since it must visit each node of the term in order to reconstruct the original term; and thus, a histomorphism performed with the resulting algebra will be O(n²).
|
||||||
rToCV :: (Functor (Base t), Corecursive t) => RAlgebra t a -> CVAlgebra t a
|
rToCV :: (Functor (Base t), Corecursive t) => RAlgebra t a -> CVAlgebra t a
|
||||||
rToCV r = r . fmap (cata (embed . tailF) &&& extract)
|
rToCV r = r . fmap (cata (embed . tailF) &&& extract)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user