    {-# LANGUAGE NamedFieldPuns #-}
    {-# LANGUAGE RecordWildCards #-}

    module GHC.Toolchain.Tools.Nm (Nm(..), findNm) where

    import Control.Monad

    import GHC.Toolchain.Prelude
    import GHC.Toolchain.Program

    newtype Nm = Nm { Nm -> Program
    nmProgram :: Program
                    }
        deriving (Int -> Nm -> ShowS
    [Nm] -> ShowS
    Nm -> String
    (Int -> Nm -> ShowS)
    -> (Nm -> String) -> ([Nm] -> ShowS) -> Show Nm
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Nm -> ShowS
    showsPrec :: Int -> Nm -> ShowS
    $cshow :: Nm -> String
    show :: Nm -> String
    $cshowList :: [Nm] -> ShowS
    showList :: [Nm] -> ShowS
    Show, ReadPrec [Nm]
    ReadPrec Nm
    Int -> ReadS Nm
    ReadS [Nm]
    (Int -> ReadS Nm)
    -> ReadS [Nm] -> ReadPrec Nm -> ReadPrec [Nm] -> Read Nm
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Nm
    readsPrec :: Int -> ReadS Nm
    $creadList :: ReadS [Nm]
    readList :: ReadS [Nm]
    $creadPrec :: ReadPrec Nm
    readPrec :: ReadPrec Nm
    $creadListPrec :: ReadPrec [Nm]
    readListPrec :: ReadPrec [Nm]
    Read, Nm -> Nm -> Bool
    (Nm -> Nm -> Bool) -> (Nm -> Nm -> Bool) -> Eq Nm
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Nm -> Nm -> Bool
    == :: Nm -> Nm -> Bool
    $c/= :: Nm -> Nm -> Bool
    /= :: Nm -> Nm -> Bool
    Eq, Eq Nm
    Eq Nm =>
    (Nm -> Nm -> Ordering)
    -> (Nm -> Nm -> Bool)
    -> (Nm -> Nm -> Bool)
    -> (Nm -> Nm -> Bool)
    -> (Nm -> Nm -> Bool)
    -> (Nm -> Nm -> Nm)
    -> (Nm -> Nm -> Nm)
    -> Ord Nm
    Nm -> Nm -> Bool
    Nm -> Nm -> Ordering
    Nm -> Nm -> Nm
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Nm -> Nm -> Ordering
    compare :: Nm -> Nm -> Ordering
    $c< :: Nm -> Nm -> Bool
    < :: Nm -> Nm -> Bool
    $c<= :: Nm -> Nm -> Bool
    <= :: Nm -> Nm -> Bool
    $c> :: Nm -> Nm -> Bool
    > :: Nm -> Nm -> Bool
    $c>= :: Nm -> Nm -> Bool
    >= :: Nm -> Nm -> Bool
    $cmax :: Nm -> Nm -> Nm
    max :: Nm -> Nm -> Nm
    $cmin :: Nm -> Nm -> Nm
    min :: Nm -> Nm -> Nm
    Ord)

    findNm :: ProgOpt -> M Nm
    findNm :: ProgOpt -> M Nm
    findNm ProgOpt
    progOpt = String -> M Nm -> M Nm
    forall a. Show a => String -> M a -> M a
    checking String
    "for 'nm'" (M Nm -> M Nm) -> M Nm -> M Nm
    forall a b. (a -> b) -> a -> b
    $ do
        nmProgram <- String -> ProgOpt -> [String] -> M Program
    findProgram String
    "nm utility" ProgOpt
    progOpt [String
    "nm", String
    "llvm-nm"]
        return Nm {..}