packages feed

hs-0.1.0.0: src/HS/Cmd/List.hs

{-# LANGUAGE DeriveAnyClass             #-}
{-# LANGUAGE DeriveGeneric              #-}
{-# LANGUAGE DerivingStrategies         #-}
{-# LANGUAGE DerivingVia                #-}
{-# LANGUAGE ExistentialQuantification  #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE FunctionalDependencies     #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase                 #-}
{-# LANGUAGE MultiWayIf                 #-}
{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE PackageImports             #-}
{-# LANGUAGE QuasiQuotes                #-}
{-# LANGUAGE RankNTypes                 #-}
{-# LANGUAGE RecordWildCards            #-}
{-# LANGUAGE ScopedTypeVariables        #-}
{-# LANGUAGE StandaloneDeriving         #-}
{-# LANGUAGE TemplateHaskell            #-}
{-# LANGUAGE TupleSections              #-}

module HS.Cmd.List where

import qualified Data.Map         as Map
import           Data.Maybe
import           HS.Types


-- | command driver to list all the installations
cmdList :: Cfg -> Maybe Compiler -> IO ()
cmdList Cfg{..} mb = sequence_
    [ fmtLn $ build iln
      | iln <- Map.elems _cfg_installations
      , isNothing mb || mb == Just (Compiler $ Just $ _iln_compiler iln)
      ]