{-# LANGUAGE CPP #-}{-| Functions for inserting implicit arguments at the right places.
-}moduleAgda.TypeChecking.ImplicitwhereimportAgda.Syntax.Common#include "../undefined.h"importAgda.Utils.ImpossibledataImplicitInsertion=ImpInsertInt-- ^ this many implicits have to be inserted|BadImplicits-- ^ hidden argument where there should have been a non-hidden arg|NoSuchNameString-- ^ bad named argument|NoInsertNeededderiving(Show)impInsert::Int->ImplicitInsertionimpInsert0=NoInsertNeededimpInsertn=ImpInsertn-- | The list should be non-empty.insertImplicit::NamedArge->[ArgString]->ImplicitInsertioninsertImplicit_[]=__IMPOSSIBLE__insertImplicitats|argHidinga==NotHidden=impInsert$nofHiddentswherenofHidden::[Arga]->IntnofHidden=length.takeWhile((Hidden==).argHiding)insertImplicitats@(t:_)=caseargHidingtofNotHidden->BadImplicitsHidden->casenameOf(unArga)ofNothing->impInsert0Justx->find0xtswherefindix(ArgHiddenry:ts)|x==y=impInserti|otherwise=find(i+1)xtsfindix(ArgNotHidden__:_)=NoSuchNamexfindix[]=NoSuchNamex