669 fun imp_monad_bind'' ts = (SOME dummy_name, unitT) `|=> |
669 fun imp_monad_bind'' ts = (SOME dummy_name, unitT) `|=> |
670 ICase { term = IVar (SOME dummy_name), typ = unitT, clauses = [(unitt, tr_bind'' ts)], primitive = dummy_case_term } |
670 ICase { term = IVar (SOME dummy_name), typ = unitT, clauses = [(unitt, tr_bind'' ts)], primitive = dummy_case_term } |
671 fun imp_monad_bind' (const as { sym = Code_Symbol.Constant c, dom = dom, ... }) ts = if is_bind c then case (ts, dom) |
671 fun imp_monad_bind' (const as { sym = Code_Symbol.Constant c, dom = dom, ... }) ts = if is_bind c then case (ts, dom) |
672 of ([t1, t2], ty1 :: ty2 :: _) => imp_monad_bind'' [(t1, ty1), (t2, ty2)] |
672 of ([t1, t2], ty1 :: ty2 :: _) => imp_monad_bind'' [(t1, ty1), (t2, ty2)] |
673 | ([t1, t2, t3], ty1 :: ty2 :: _) => imp_monad_bind'' [(t1, ty1), (t2, ty2)] `$ t3 |
673 | ([t1, t2, t3], ty1 :: ty2 :: _) => imp_monad_bind'' [(t1, ty1), (t2, ty2)] `$ t3 |
674 | (ts, _) => imp_monad_bind (eta_expand 2 (const, ts)) |
674 | (ts, _) => imp_monad_bind (satisfied_application 2 (const, ts)) |
675 else IConst const `$$ map imp_monad_bind ts |
675 else IConst const `$$ map imp_monad_bind ts |
676 and imp_monad_bind (IConst const) = imp_monad_bind' const [] |
676 and imp_monad_bind (IConst const) = imp_monad_bind' const [] |
677 | imp_monad_bind (t as IVar _) = t |
677 | imp_monad_bind (t as IVar _) = t |
678 | imp_monad_bind (t as _ `$ _) = (case unfold_app t |
678 | imp_monad_bind (t as _ `$ _) = (case unfold_app t |
679 of (IConst const, ts) => imp_monad_bind' const ts |
679 of (IConst const, ts) => imp_monad_bind' const ts |