resugarMultiFun :: Code Exp -> ([Var], Exp)
resugarMultiFun c = reverse `A.first` go [] c
    where go :: [Var] -> Code Exp -> ([Var], Exp)
          go args (Rec _ arg (EFun code) _) = go (arg:args) code
          go args (Rec _ arg body        _) = (arg:args, body)

-- | Class of syntax trees that can contain InL or InR constructors.  We need
--   this in Resugarable instance for Syntax, because Syntax can be
--   parameterized by Exp or Trace and in the Roll case we need a uniform way of
--   pattern matching on InL/InR.
resugarMultiFun :: Code Exp -> ([Var], Exp)
resugarMultiFun c = reverse `A.first` go [] c
    where go :: [Var] -> Code Exp -> ([Var], Exp)
          go args (Rec _ arg (EFun code) _) = go (arg:args) code
          go args (Rec _ arg body        _) = (arg:args, body)

-- | Class of syntax trees that can contain InL or InR constructors.  We need
--   this in Resugarable instance for Syntax, because Syntax can be
--   parameterized by Exp or Trace and in the Roll case we need a uniform way of
--   pattern matching on InL/InR.
resugarMultiFun c = reverse `A.first` go [] c
    where go :: [Var] -> Code Exp -> ([Var], Exp)
          go args (Rec _ arg (EFun code) _) = go (arg:args) code
          go args (Rec _ arg body        _) = (arg:args, body)

-- | Class of syntax trees that can contain InL or InR constructors.  We need
--   this in Resugarable instance for Syntax, because Syntax can be
--   parameterized by Exp or Trace and in the Roll case we need a uniform way of
--   pattern matching on InL/InR.