10 | %language ElabReflection
44 | -- If a hole is found, always include every possible variable
72 | export
95 | `(let (Builtin.MkPair (Control.Category.Promonad.MkPromonad0 @{~(IBindVar EmptyFC cat)} {}) _) = ~(IVar EmptyFC arr)
99 | (Builtin.MkPair (Control.Category.Promonad.MkPromonad0 @{~(IBindVar EmptyFC cat)} {}) _) = ~(IVar EmptyFC arr)
101 | where
105 | optimize (ts :< `(Control.Arrow.arrow @{~ar} {a = ~a, b = ~_} ~f) :< `(Control.Arrow.arrow @{~_} {a = ~b, b = ~c} ~g)) =
106 | assert_total $ optimize (ts :< `(Control.Arrow.arrow @{~ar} {a = ~a, b = ~c} (Prelude.(.) {a = ~a, b = ~b, c = ~c} ~g ~f)))
128 | stringBind [(v,b)] = if b then IBindVar EmptyFC (UN $ Basic v.name) else Implicit EmptyFC True
129 | stringBind ((v,b) :: strings) = `(Builtin.MkPair ~(if b then IBindVar EmptyFC (UN $ Basic v.name) else Implicit EmptyFC True) ~(stringBind strings))
134 | stringLam [(v,True)] t = ILam EmptyFC MW ExplicitArg (Just $ UN $ Basic v.name) (Implicit EmptyFC False) t
146 | arrowImplLam : (ct,ar,ch : TTImp) -> SnocList TTImp -> List ArrowVar -> TTImp -> Elab (SnocList TTImp)
147 | arrowImpl' : (ct,ar,ch : TTImp) -> SnocList TTImp -> List ArrowVar -> TTImp -> Elab (SnocList TTImp)
150 | arrowImpl' ct ar ch (ts :< `(Control.Arrow.arrow @{~ar} {a=_,b=_} (\_ => Builtin.MkUnit))) [] rest
161 | (ts :< `(Control.Arrow.arrow @{~ar} {a = ~(pairTy $ MkAVar var ty :: strings), b = ~(pairTy strings')}
171 | arrowImpl' ct ar ch ts (MkAVar v ty :: strings) (ICase fc _ (IVar _ var@(MN {})) _ clauses) = do
182 | pure (PatClause fc' lhs $ mkEither i tot $ pair $ map name strings', Just $ composeImp ct $ optimize t)
207 | pure (PatClause fc' lhs $ mkEither i tot $ pair $ map name strings', Just $ composeImp ct $ optimize t)
230 | pure (PatClause fc' lhs $ mkEither i tot $ pair $ map name strings', Just $ composeImp ct $ optimize t)
243 | :< `(Control.Arrow.first @{~ar} ~(foldr1 (\t,t' => `(Control.Arrow.(\|/) @{~ch} ~t ~t')) conts'))
257 | pure (PatClause fc' lhs $ mkEither i tot $ pair $ map name strings', Just $ composeImp ct $ optimize t)
270 | :< `(Control.Arrow.first @{~ar} ~(foldr1 (\t,t' => `(Control.Arrow.(\|/) @{~ch} ~t ~t')) conts')))
286 | [] => arrowImplLam ct ar ch (ts :< `(Control.Arrow.arrow @{~ar} {a=_,b=_} (\_ => ~inp)) :< mor) [] rest
302 | (ts :< `(Control.Arrow.arrow @{~ar} {a = ~(pairTy strings), b = Builtin.Pair _ ~(pairTy strings')}
328 | (ts :< `(Control.Arrow.arrow @{~ar} {a = ~(pairTy strings), b = Builtin.Pair _ ~(pairTy strings')}
345 | ||| Enter arrow notation.
346 | |||
347 | ||| This elaboration script must be specifically invoked with
348 | ||| `%runElab`. The category is inferred from the return type.
349 | export
353 | ||| Enter arrow notation. Unlike `arrowDo`, this script allows you to
354 | ||| explicitly provide an `ArrowChoice` implementation instead of
355 | ||| searching for one.
356 | |||
357 | ||| This elaboration script must be specifically invoked with
358 | ||| `%runElab`. The category is inferred from the return type.
359 | export
360 | arrowChoiceDo : {0 arr : Hom Type0} -> (0 _ : ArrowChoice arr) => TTImp -> Elab (arr (W0 a) (W0 b))