packageBasedCmd :: IP.IdrisParser a -> ([PkgName] -> a -> Command)
                -> String -> IP.IdrisParser (Either String Command)
packageBasedCmd valParser cmd name =
  P.try (do IP.lchar '('
            pkgs <- P.sepBy (pkg <* IP.whiteSpace) (IP.lchar ',')
            IP.lchar ')'
            val <- valParser
            return (Right (cmd pkgs val)))
   <|> do val <- valParser
          return (Right (cmd [] val))
  where
    pkg = either fail pure . pkgName =<< IP.packageName
packageBasedCmd :: IP.IdrisParser a -> ([PkgName] -> a -> Command)
                -> String -> IP.IdrisParser (Either String Command)
packageBasedCmd valParser cmd name =
  P.try (do IP.lchar '('
            pkgs <- P.sepBy (pkg <* IP.whiteSpace) (IP.lchar ',')
            IP.lchar ')'
            val <- valParser
            return (Right (cmd pkgs val)))
   <|> do val <- valParser
          return (Right (cmd [] val))
  where
    pkg = either fail pure . pkgName =<< IP.packageName
packageBasedCmd valParser cmd name =
  P.try (do IP.lchar '('
            pkgs <- P.sepBy (pkg <* IP.whiteSpace) (IP.lchar ',')
            IP.lchar ')'
            val <- valParser
            return (Right (cmd pkgs val)))
   <|> do val <- valParser
          return (Right (cmd [] val))
  where
    pkg = either fail pure . pkgName =<< IP.packageName