-- | Find the kernelspec for a kernel with a given language name.
--
-- If no such kernel exists, then 'Nothing' is returned. If an error occurs
-- while searching for Jupyter kernels, a 'JupyterKernelspecException' is thrown.
findKernel :: Text -> IO (Maybe Kernelspec)
findKernel language = do
  Kernelspecs kernelspecs <- findKernelsInternal
  maybe (return Nothing)
        (fmap Just . checkKernelspecFiles)
        (Map.lookup language kernelspecs)

-- | Find all kernelspecs that the Jupyter installation is aware of,
-- using the @jupyter kernelspec list@ command.
--
-- If an error occurs while searching for Jupyter kernels, a 'JupyterKernelspecException' is thrown.
findKernel :: Text -> IO (Maybe Kernelspec)
findKernel language = do
  Kernelspecs kernelspecs <- findKernelsInternal
  maybe (return Nothing)
        (fmap Just . checkKernelspecFiles)
        (Map.lookup language kernelspecs)

-- | Find all kernelspecs that the Jupyter installation is aware of,
-- using the @jupyter kernelspec list@ command.
--
-- If an error occurs while searching for Jupyter kernels, a 'JupyterKernelspecException' is thrown.
findKernel language = do
  Kernelspecs kernelspecs <- findKernelsInternal
  maybe (return Nothing)
        (fmap Just . checkKernelspecFiles)
        (Map.lookup language kernelspecs)

-- | Find all kernelspecs that the Jupyter installation is aware of,
-- using the @jupyter kernelspec list@ command.
--
-- If an error occurs while searching for Jupyter kernels, a 'JupyterKernelspecException' is thrown.