Aleksey Khudyakov avatar Aleksey Khudyakov committed 4a5ddff

Remove old fusion code

Comments (0)

Files changed (1)

Data/Vector/Fixed/Internal.hs

   , VectorN
   , length
   , Id(..)
-    -- * Deforestation
-    -- $deforestation
-  , Cont(..)
-  , create
-  , inspectV
   ) where
 
 import Data.Complex
 
 
 ----------------------------------------------------------------
--- Fusion
-----------------------------------------------------------------
-
--- $deforestation
---
--- Explicit deforestation is less important for ADT based vectors
--- since GHC is able to eliminate intermediate data structures. But it
--- cannot do so for array-based ones so intermediate vector have to be
--- removed with RULES. Following identity is used. Of course @f@ must
--- be polymorphic in continuation result type.
---
--- > inspect (f construct) g = f g
---
--- But 'construct' function is located somewhere deep in function
--- application stack so it cannot be matched using rule. Function
--- 'create' is needed to move 'construct' to the top.
---
--- As a rule function which are subject to deforestation should be
--- written using 'create' and 'inspectV' functions.
-
-
--- | Continuation with arbitrary result.
-newtype Cont n a = Cont (forall r. Fun n a r -> r)
-
--- | Construct vector. It should be used instead of 'construct' to get
---   deforestation. Example of usage:
---
--- > cont1 $ cont2 $ construct
---
---   becomes
---
--- > create $ Cont $ cont1 . cont2
-create :: (Arity (Dim v), Vector v a) => Cont (Dim v) a -> v a
-{-# INLINE[1] create #-}
-create (Cont f) = f construct
-
--- | Wrapper for 'inspect'. It's inlined later and is needed in order
---   to give deforestation rule chance to fire.
-inspectV :: (Arity (Dim v), Vector v a) => v a -> Fun (Dim v) a b -> b
-{-# INLINE[1] inspectV #-}
-inspectV = inspect
-
-app :: Cont n a -> Fun n a b -> b
-{-# INLINE app #-}
-app (Cont f) g = f g
-
-{-# RULES "inspect/construct"
-      forall f g. inspectV (create f) g = app f g
-  #-}
-
-
-
-----------------------------------------------------------------
 -- Instances
 ----------------------------------------------------------------
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.