Last active
December 31, 2015 00:09
-
-
Save lukehoersten/7905146 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Uncaught exception: 'getPromise: dereferenced empty key (id 0)' | |
manyWithSplices :: Monad n | |
=> Splice n | |
-- ^ Splice to be run | |
-> Splices (RuntimeSplice n a -> Splice n) | |
-- ^ Splices to be bound to each runtime data first | |
-> RuntimeSplice n [a] | |
-- ^ Runtime data needed by the above splices | |
-> Splice n | |
manyWithSplices splice splices runtimeAction = | |
manyWithSplices' splice noSplices splices runtimeAction | |
manyWithSplices' :: Monad n | |
=> Splice n | |
-- ^ Splice to be run | |
-> Splices (RuntimeSplice n [a] -> Splice n) | |
-- ^ Splices to be bound to all runtime data first | |
-> Splices (RuntimeSplice n a -> Splice n) | |
-- ^ Splices to be bound to each runtime data first | |
-> RuntimeSplice n [a] | |
-- ^ Runtime data needed by the above splices | |
-> Splice n | |
manyWithSplices' splice listSplices singleSplices runtimeAction = do | |
p <- newEmptyPromise | |
ps <- newEmptyPromise | |
let splices' = mapS ($ getPromise p) singleSplices <> (listSplices $$ getPromise ps) | |
chunks <- withLocalSplices splices' noSplices splice | |
return $ yieldRuntime $ do | |
items <- runtimeAction | |
res' <- putPromise ps items >> codeGen chunks | |
res <- forM items $ \item -> putPromise p item >> codeGen chunks | |
return . mconcat $ res' : res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment