-- Let's test it:

-- testBoxArg = equal (typ :>: (fromRight $ withTac, orig)) (B0,5)
--     where a = N (P ([("",0)] := DECL :<: SET))
--           f = N (P ([("",1)] := DECL :<: ARR a desc))
--           d = N (P ([("",2)] := DECL :<: SET))
--           p = N (P ([("",3)] := DECL :<: ARR d SET))
--           v = N (P ([("",4)] := DECL :<: descOp @@ [ARG a f, p]))
--           typ = SET
--           withTac = opRun boxOp [ARG a f, d, p, v]
--           orig = boxArgRun a f d p v

-- Box on an Ind is supposed to build this term:

-- boxIndRun h x d p v =
--         eval [.h.x.d.p.v.
--              TIMES (C (Pi (NV h) . L $ "" :. [.y.
--                                    N (V p :$ A (N (V v :$ Fst :$ A (NV y))))]))
--                   (N (boxOp :@ [NV x,NV d,NV p,N (V v :$ Snd)]))
--              ] $ B0 :< h :< x :< d :< p :< v

-- Let's test it:

-- testBoxInd = equal (typ :>: (fromRight $ withTac, orig)) (B0,5)
--     where h = N (P ([("",0)] := DECL :<: SET))
--           x = N (P ([("",1)] := DECL :<: desc))
--           d = N (P ([("",2)] := DECL :<: SET))
--           p = N (P ([("",3)] := DECL :<: ARR d SET))
--           v = N (P ([("",4)] := DECL :<: descOp @@ [IND h x, p]))
--           typ = SET
--           withTac = opRun boxOp [IND h x, d, p, v]
--           orig = boxIndRun h x d p v

-- Just check that box does something on Ind1:

-- testBoxInd1 = isRight withTac
--     where x = N (P ([("",1)] := DECL :<: desc))
--           d = N (P ([("",2)] := DECL :<: SET))
--           p = N (P ([("",3)] := DECL :<: ARR d SET))
--           v = N (P ([("",4)] := DECL :<: descOp @@ [IND1 x, p]))
--           typ = SET
--           withTac = opRun boxOp [IND1 x, d, p, v]

-- Mapbox on an Arg is supposed to build this term:

mapboxArgRun a f d bp p v =
  mapBoxOp @@ [f $$ (A (v $$ Fst)),d,bp,p,v $$ Snd]
mapboxArgRun a f d bp p v =
  mapBoxOp @@ [f $$ (A (v $$ Fst)),d,bp,p,v $$ Snd]
mapboxArgRun a f d bp p v =
  mapBoxOp @@ [f $$ (A (v $$ Fst)),d,bp,p,v $$ Snd]