0 | module Evince.Async.Hoist
 1 |
 2 | import Data.SnocList
 3 | import Evince.Core
 4 |
 5 | mutual
 6 |   hoistTree : ({0 x : Type} -> f x -> g x) -> SpecTree f a -> SpecTree g a
 7 |   hoistTree nt (Describe label children) = Describe label (hoistTrees nt children)
 8 |   hoistTree nt (It label loc test) = It label loc (\res => nt (test res))
 9 |   hoistTree nt (Pending label reason) = Pending label reason
10 |   hoistTree nt (Focused t) = Focused (hoistTree nt t)
11 |   hoistTree nt (WithCleanup cleanup children) = WithCleanup (nt cleanup) (hoistTrees nt children)
12 |
13 |   hoistTrees : ({0 x : Type} -> f x -> g x) -> List (SpecTree f a) -> List (SpecTree g a)
14 |   hoistTrees nt [] = []
15 |   hoistTrees nt (t :: ts) = hoistTree nt t :: hoistTrees nt ts
16 |
17 | ||| Re-target a spec from one effect monad to another, mapping every test
18 | ||| action and cleanup through the given natural transformation. Lets a spec
19 | ||| written as `Spec IO` run under the async driver via `liftIO`.
20 | export
21 | hoistSpec : ({0 x : Type} -> f x -> g x) -> Spec f a b -> Spec g a b
22 | hoistSpec nt (MkSpec trees x) = MkSpec (map (hoistTree nt) trees) x
23 |