    -- |
    -- Module      :  Cryptol.Utils.Ident
    -- Copyright   :  (c) 2015-2016 Galois, Inc.
    -- License     :  BSD3
    -- Maintainer  :  cryptol@galois.com
    -- Stability   :  provisional
    -- Portability :  portable

    {-# LANGUAGE DeriveGeneric #-}
    {-# LANGUAGE DeriveAnyClass #-}
    {-# LANGUAGE OverloadedStrings #-}

    module Cryptol.Utils.Ident
      ( -- * Module names
        ModPath(..)
      , apPathRoot
      , modPathCommon
      , modPathIsOrContains
      , topModuleFor
      , modPathSplit
      , modPathIsNormal

      , ModName
      , modNameToText
      , textToModName
      , modNameChunks
      , modNameChunksText
      , packModName
      , preludeName
      , preludeReferenceName
      , undefinedModName
      , floatName
      , suiteBName
      , arrayName
      , primeECName
      , interactiveName
      , noModuleName
      , exprModName
      , modNameArg
      , modNameIfaceMod
      , modNameToNormalModName
      , modNameIsNormal

        -- * Identifiers
      , Ident
      , packIdent
      , packInfix
      , unpackIdent
      , mkIdent
      , mkInfix
      , isInfixIdent
      , nullIdent
      , identText
      , modParamIdent
      , identAnonArg
      , identAnonIfaceMod
      , identIsNormal

        -- * Namespaces
      , Namespace(..)
      , allNamespaces

        -- * Original names
      , OrigName(..)
      , OrigSource(..)
      , ogFromModParam

        -- * Identifiers for primitives
      , PrimIdent(..)
      , prelPrim
      , floatPrim
      , arrayPrim
      , suiteBPrim
      , primeECPrim
      ) where

    import           Control.DeepSeq (NFData)
    import           Data.Char (isSpace)
    import           Data.List (unfoldr)
    import           Data.Text (Text)
    import qualified Data.Text as T
    import           Data.String (IsString(..))
    import           GHC.Generics (Generic)

    import Cryptol.Utils.Panic(panic)

    --------------------------------------------------------------------------------

    -- | Namespaces for names
    data Namespace = NSValue | NSType | NSModule
      deriving ((forall x. Namespace -> Rep Namespace x)
    -> (forall x. Rep Namespace x -> Namespace) -> Generic Namespace
    forall x. Rep Namespace x -> Namespace
    forall x. Namespace -> Rep Namespace x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Namespace -> Rep Namespace x
    from :: forall x. Namespace -> Rep Namespace x
    $cto :: forall x. Rep Namespace x -> Namespace
    to :: forall x. Rep Namespace x -> Namespace
    Generic,Int -> Namespace -> ShowS
    [Namespace] -> ShowS
    Namespace -> String
    (Int -> Namespace -> ShowS)
    -> (Namespace -> String)
    -> ([Namespace] -> ShowS)
    -> Show Namespace
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Namespace -> ShowS
    showsPrec :: Int -> Namespace -> ShowS
    $cshow :: Namespace -> String
    show :: Namespace -> String
    $cshowList :: [Namespace] -> ShowS
    showList :: [Namespace] -> ShowS
    Show,Namespace -> ()
    (Namespace -> ()) -> NFData Namespace
    forall a. (a -> ()) -> NFData a
    $crnf :: Namespace -> ()
    rnf :: Namespace -> ()
    NFData,Namespace -> Namespace -> Bool
    (Namespace -> Namespace -> Bool)
    -> (Namespace -> Namespace -> Bool) -> Eq Namespace
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Namespace -> Namespace -> Bool
    == :: Namespace -> Namespace -> Bool
    $c/= :: Namespace -> Namespace -> Bool
    /= :: Namespace -> Namespace -> Bool
    Eq,Eq Namespace
    Eq Namespace
    -> (Namespace -> Namespace -> Ordering)
    -> (Namespace -> Namespace -> Bool)
    -> (Namespace -> Namespace -> Bool)
    -> (Namespace -> Namespace -> Bool)
    -> (Namespace -> Namespace -> Bool)
    -> (Namespace -> Namespace -> Namespace)
    -> (Namespace -> Namespace -> Namespace)
    -> Ord Namespace
    Namespace -> Namespace -> Bool
    Namespace -> Namespace -> Ordering
    Namespace -> Namespace -> Namespace
    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 :: Namespace -> Namespace -> Ordering
    compare :: Namespace -> Namespace -> Ordering
    $c< :: Namespace -> Namespace -> Bool
    < :: Namespace -> Namespace -> Bool
    $c<= :: Namespace -> Namespace -> Bool
    <= :: Namespace -> Namespace -> Bool
    $c> :: Namespace -> Namespace -> Bool
    > :: Namespace -> Namespace -> Bool
    $c>= :: Namespace -> Namespace -> Bool
    >= :: Namespace -> Namespace -> Bool
    $cmax :: Namespace -> Namespace -> Namespace
    max :: Namespace -> Namespace -> Namespace
    $cmin :: Namespace -> Namespace -> Namespace
    min :: Namespace -> Namespace -> Namespace
    Ord,Int -> Namespace
    Namespace -> Int
    Namespace -> [Namespace]
    Namespace -> Namespace
    Namespace -> Namespace -> [Namespace]
    Namespace -> Namespace -> Namespace -> [Namespace]
    (Namespace -> Namespace)
    -> (Namespace -> Namespace)
    -> (Int -> Namespace)
    -> (Namespace -> Int)
    -> (Namespace -> [Namespace])
    -> (Namespace -> Namespace -> [Namespace])
    -> (Namespace -> Namespace -> [Namespace])
    -> (Namespace -> Namespace -> Namespace -> [Namespace])
    -> Enum Namespace
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: Namespace -> Namespace
    succ :: Namespace -> Namespace
    $cpred :: Namespace -> Namespace
    pred :: Namespace -> Namespace
    $ctoEnum :: Int -> Namespace
    toEnum :: Int -> Namespace
    $cfromEnum :: Namespace -> Int
    fromEnum :: Namespace -> Int
    $cenumFrom :: Namespace -> [Namespace]
    enumFrom :: Namespace -> [Namespace]
    $cenumFromThen :: Namespace -> Namespace -> [Namespace]
    enumFromThen :: Namespace -> Namespace -> [Namespace]
    $cenumFromTo :: Namespace -> Namespace -> [Namespace]
    enumFromTo :: Namespace -> Namespace -> [Namespace]
    $cenumFromThenTo :: Namespace -> Namespace -> Namespace -> [Namespace]
    enumFromThenTo :: Namespace -> Namespace -> Namespace -> [Namespace]
    Enum,Namespace
    Namespace -> Namespace -> Bounded Namespace
    forall a. a -> a -> Bounded a
    $cminBound :: Namespace
    minBound :: Namespace
    $cmaxBound :: Namespace
    maxBound :: Namespace
    Bounded)

    allNamespaces :: [Namespace]
    allNamespaces :: [Namespace]
    allNamespaces = [ Namespace
    forall a. Bounded a => a
    minBound .. Namespace
    forall a. Bounded a => a
    maxBound ]

    -- | Idnetifies a possibly nested module
    data ModPath  = TopModule ModName
                  | Nested ModPath Ident
                    deriving (ModPath -> ModPath -> Bool
    (ModPath -> ModPath -> Bool)
    -> (ModPath -> ModPath -> Bool) -> Eq ModPath
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ModPath -> ModPath -> Bool
    == :: ModPath -> ModPath -> Bool
    $c/= :: ModPath -> ModPath -> Bool
    /= :: ModPath -> ModPath -> Bool
    Eq,Eq ModPath
    Eq ModPath
    -> (ModPath -> ModPath -> Ordering)
    -> (ModPath -> ModPath -> Bool)
    -> (ModPath -> ModPath -> Bool)
    -> (ModPath -> ModPath -> Bool)
    -> (ModPath -> ModPath -> Bool)
    -> (ModPath -> ModPath -> ModPath)
    -> (ModPath -> ModPath -> ModPath)
    -> Ord ModPath
    ModPath -> ModPath -> Bool
    ModPath -> ModPath -> Ordering
    ModPath -> ModPath -> ModPath
    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 :: ModPath -> ModPath -> Ordering
    compare :: ModPath -> ModPath -> Ordering
    $c< :: ModPath -> ModPath -> Bool
    < :: ModPath -> ModPath -> Bool
    $c<= :: ModPath -> ModPath -> Bool
    <= :: ModPath -> ModPath -> Bool
    $c> :: ModPath -> ModPath -> Bool
    > :: ModPath -> ModPath -> Bool
    $c>= :: ModPath -> ModPath -> Bool
    >= :: ModPath -> ModPath -> Bool
    $cmax :: ModPath -> ModPath -> ModPath
    max :: ModPath -> ModPath -> ModPath
    $cmin :: ModPath -> ModPath -> ModPath
    min :: ModPath -> ModPath -> ModPath
    Ord,Int -> ModPath -> ShowS
    [ModPath] -> ShowS
    ModPath -> String
    (Int -> ModPath -> ShowS)
    -> (ModPath -> String) -> ([ModPath] -> ShowS) -> Show ModPath
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ModPath -> ShowS
    showsPrec :: Int -> ModPath -> ShowS
    $cshow :: ModPath -> String
    show :: ModPath -> String
    $cshowList :: [ModPath] -> ShowS
    showList :: [ModPath] -> ShowS
    Show,(forall x. ModPath -> Rep ModPath x)
    -> (forall x. Rep ModPath x -> ModPath) -> Generic ModPath
    forall x. Rep ModPath x -> ModPath
    forall x. ModPath -> Rep ModPath x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. ModPath -> Rep ModPath x
    from :: forall x. ModPath -> Rep ModPath x
    $cto :: forall x. Rep ModPath x -> ModPath
    to :: forall x. Rep ModPath x -> ModPath
    Generic,ModPath -> ()
    (ModPath -> ()) -> NFData ModPath
    forall a. (a -> ()) -> NFData a
    $crnf :: ModPath -> ()
    rnf :: ModPath -> ()
    NFData)

    apPathRoot :: (ModName -> ModName) -> ModPath -> ModPath
    apPathRoot :: (ModName -> ModName) -> ModPath -> ModPath
    apPathRoot ModName -> ModName
    f ModPath
    path =
      case ModPath
    path of
        TopModule ModName
    m -> ModName -> ModPath
    TopModule (ModName -> ModName
    f ModName
    m)
        Nested ModPath
    p Ident
    q  -> ModPath -> Ident -> ModPath
    Nested ((ModName -> ModName) -> ModPath -> ModPath
    apPathRoot ModName -> ModName
    f ModPath
    p) Ident
    q

    topModuleFor :: ModPath -> ModName
    topModuleFor :: ModPath -> ModName
    topModuleFor ModPath
    m =
      case ModPath
    m of
        TopModule ModName
    x -> ModName
    x
        Nested ModPath
    p Ident
    _ -> ModPath -> ModName
    topModuleFor ModPath
    p

    -- | Compute a common prefix between two module paths, if any.
    -- This is basically "anti-unification" of the two paths, where we
    -- compute the longest common prefix, and the remaining differences for
    -- each module.
    modPathCommon :: ModPath -> ModPath -> Maybe (ModPath, [Ident], [Ident])
    modPathCommon :: ModPath -> ModPath -> Maybe (ModPath, [Ident], [Ident])
    modPathCommon ModPath
    p1 ModPath
    p2
      | ModName
    top1 ModName -> ModName -> Bool
    forall a. Eq a => a -> a -> Bool
    == ModName
    top2 = (ModPath, [Ident], [Ident]) -> Maybe (ModPath, [Ident], [Ident])
    forall a. a -> Maybe a
    Just (ModPath -> [Ident] -> [Ident] -> (ModPath, [Ident], [Ident])
    findCommon (ModName -> ModPath
    TopModule ModName
    top1) [Ident]
    as [Ident]
    bs)
      | Bool
    otherwise    = Maybe (ModPath, [Ident], [Ident])
    forall a. Maybe a
    Nothing
      where
      (ModName
    top1,[Ident]
    as) = ModPath -> (ModName, [Ident])
    modPathSplit ModPath
    p1
      (ModName
    top2,[Ident]
    bs) = ModPath -> (ModName, [Ident])
    modPathSplit ModPath
    p2

      findCommon :: ModPath -> [Ident] -> [Ident] -> (ModPath, [Ident], [Ident])
    findCommon ModPath
    com [Ident]
    xs [Ident]
    ys =
        case ([Ident]
    xs,[Ident]
    ys) of
          (Ident
    x:[Ident]
    xs',Ident
    y:[Ident]
    ys') | Ident
    x Ident -> Ident -> Bool
    forall a. Eq a => a -> a -> Bool
    == Ident
    y -> ModPath -> [Ident] -> [Ident] -> (ModPath, [Ident], [Ident])
    findCommon (ModPath -> Ident -> ModPath
    Nested ModPath
    com Ident
    x) [Ident]
    xs' [Ident]
    ys'
          ([Ident], [Ident])
    _                      -> (ModPath
    com, [Ident]
    xs, [Ident]
    ys)

    -- | Does the first module path contain the second?
    -- This returns true if the paths are the same.
    modPathIsOrContains :: ModPath -> ModPath -> Bool
    modPathIsOrContains :: ModPath -> ModPath -> Bool
    modPathIsOrContains ModPath
    p1 ModPath
    p2 =
      case ModPath -> ModPath -> Maybe (ModPath, [Ident], [Ident])
    modPathCommon ModPath
    p1 ModPath
    p2 of
        Just (ModPath
    _,[],[Ident]
    _) -> Bool
    True
        Maybe (ModPath, [Ident], [Ident])
    _ -> Bool
    False

    modPathSplit :: ModPath -> (ModName, [Ident])
    modPathSplit :: ModPath -> (ModName, [Ident])
    modPathSplit ModPath
    p0 = (ModName
    top,[Ident] -> [Ident]
    forall a. [a] -> [a]
    reverse [Ident]
    xs)
      where
      (ModName
    top,[Ident]
    xs) = ModPath -> (ModName, [Ident])
    go ModPath
    p0
      go :: ModPath -> (ModName, [Ident])
    go ModPath
    p =
        case ModPath
    p of
          TopModule ModName
    a -> (ModName
    a, [])
          Nested ModPath
    b Ident
    i  -> (ModName
    a, Ident
    iIdent -> [Ident] -> [Ident]
    forall a. a -> [a] -> [a]
    :[Ident]
    bs)
            where (ModName
    a,[Ident]
    bs) = ModPath -> (ModName, [Ident])
    go ModPath
    b

    modPathIsNormal :: ModPath -> Bool
    modPathIsNormal :: ModPath -> Bool
    modPathIsNormal ModPath
    p = ModName -> Bool
    modNameIsNormal ModName
    m Bool -> Bool -> Bool
    && (Ident -> Bool) -> [Ident] -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    all Ident -> Bool
    identIsNormal [Ident]
    is
      where (ModName
    m,[Ident]
    is) = ModPath -> (ModName, [Ident])
    modPathSplit ModPath
    p

    --------------------------------------------------------------------------------
    -- | Top-level Module names are just text.
    data ModName = ModName Text MaybeAnon
      deriving (ModName -> ModName -> Bool
    (ModName -> ModName -> Bool)
    -> (ModName -> ModName -> Bool) -> Eq ModName
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ModName -> ModName -> Bool
    == :: ModName -> ModName -> Bool
    $c/= :: ModName -> ModName -> Bool
    /= :: ModName -> ModName -> Bool
    Eq,Eq ModName
    Eq ModName
    -> (ModName -> ModName -> Ordering)
    -> (ModName -> ModName -> Bool)
    -> (ModName -> ModName -> Bool)
    -> (ModName -> ModName -> Bool)
    -> (ModName -> ModName -> Bool)
    -> (ModName -> ModName -> ModName)
    -> (ModName -> ModName -> ModName)
    -> Ord ModName
    ModName -> ModName -> Bool
    ModName -> ModName -> Ordering
    ModName -> ModName -> ModName
    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 :: ModName -> ModName -> Ordering
    compare :: ModName -> ModName -> Ordering
    $c< :: ModName -> ModName -> Bool
    < :: ModName -> ModName -> Bool
    $c<= :: ModName -> ModName -> Bool
    <= :: ModName -> ModName -> Bool
    $c> :: ModName -> ModName -> Bool
    > :: ModName -> ModName -> Bool
    $c>= :: ModName -> ModName -> Bool
    >= :: ModName -> ModName -> Bool
    $cmax :: ModName -> ModName -> ModName
    max :: ModName -> ModName -> ModName
    $cmin :: ModName -> ModName -> ModName
    min :: ModName -> ModName -> ModName
    Ord,Int -> ModName -> ShowS
    [ModName] -> ShowS
    ModName -> String
    (Int -> ModName -> ShowS)
    -> (ModName -> String) -> ([ModName] -> ShowS) -> Show ModName
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ModName -> ShowS
    showsPrec :: Int -> ModName -> ShowS
    $cshow :: ModName -> String
    show :: ModName -> String
    $cshowList :: [ModName] -> ShowS
    showList :: [ModName] -> ShowS
    Show,(forall x. ModName -> Rep ModName x)
    -> (forall x. Rep ModName x -> ModName) -> Generic ModName
    forall x. Rep ModName x -> ModName
    forall x. ModName -> Rep ModName x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. ModName -> Rep ModName x
    from :: forall x. ModName -> Rep ModName x
    $cto :: forall x. Rep ModName x -> ModName
    to :: forall x. Rep ModName x -> ModName
    Generic)

    instance NFData ModName

    -- | Change a normal module name to a module name to be used for an
    -- anonnymous argument.
    modNameArg :: ModName -> ModName
    modNameArg :: ModName -> ModName
    modNameArg (ModName Text
    m MaybeAnon
    fl) =
      case MaybeAnon
    fl of
        MaybeAnon
    NormalName        -> Text -> MaybeAnon -> ModName
    ModName Text
    m MaybeAnon
    AnonModArgName
        MaybeAnon
    AnonModArgName    -> String -> [String] -> ModName
    forall a. HasCallStack => String -> [String] -> a
    panic String
    "modNameArg" [String
    "Name is not normal"]
        MaybeAnon
    AnonIfaceModName  -> String -> [String] -> ModName
    forall a. HasCallStack => String -> [String] -> a
    panic String
    "modNameArg" [String
    "Name is not normal"]

    -- | Change a normal module name to a module name to be used for an
    -- anonnymous interface.
    modNameIfaceMod :: ModName -> ModName
    modNameIfaceMod :: ModName -> ModName
    modNameIfaceMod (ModName Text
    m MaybeAnon
    fl) =
      case MaybeAnon
    fl of
        MaybeAnon
    NormalName        -> Text -> MaybeAnon -> ModName
    ModName Text
    m MaybeAnon
    AnonIfaceModName
        MaybeAnon
    AnonModArgName    -> String -> [String] -> ModName
    forall a. HasCallStack => String -> [String] -> a
    panic String
    "modNameIfaceMod" [String
    "Name is not normal"]
        MaybeAnon
    AnonIfaceModName  -> String -> [String] -> ModName
    forall a. HasCallStack => String -> [String] -> a
    panic String
    "modNameIfaceMod" [String
    "Name is not normal"]

    -- | This is used when we check that the name of a module matches the
    -- file where it is defined.
    modNameToNormalModName :: ModName -> ModName
    modNameToNormalModName :: ModName -> ModName
    modNameToNormalModName (ModName Text
    t MaybeAnon
    _) = Text -> MaybeAnon -> ModName
    ModName Text
    t MaybeAnon
    NormalName

    modNameToText :: ModName -> Text
    modNameToText :: ModName -> Text
    modNameToText (ModName Text
    x MaybeAnon
    fl) = MaybeAnon -> Text -> Text
    maybeAnonText MaybeAnon
    fl Text
    x

    -- | This is useful when we want to hide anonymous modules.
    modNameIsNormal :: ModName -> Bool
    modNameIsNormal :: ModName -> Bool
    modNameIsNormal (ModName Text
    _ MaybeAnon
    fl) = MaybeAnon -> Bool
    isNormal MaybeAnon
    fl

    -- | Make a normal module name out of text.
    textToModName :: T.Text -> ModName
    textToModName :: Text -> ModName
    textToModName Text
    txt = Text -> MaybeAnon -> ModName
    ModName Text
    txt MaybeAnon
    NormalName

    -- | Break up a module name on the separators, `Text` version.
    modNameChunksText :: ModName -> [T.Text]
    modNameChunksText :: ModName -> [Text]
    modNameChunksText (ModName Text
    x MaybeAnon
    fl) = (Text -> Maybe (Text, Text)) -> Text -> [Text]
    forall b a. (b -> Maybe (a, b)) -> b -> [a]
    unfoldr Text -> Maybe (Text, Text)
    step Text
    x
      where
      step :: Text -> Maybe (Text, Text)
    step Text
    str
        | Text -> Bool
    T.null Text
    str = Maybe (Text, Text)
    forall a. Maybe a
    Nothing
        | Bool
    otherwise  =
          case HasCallStack => Text -> Text -> (Text, Text)
    Text -> Text -> (Text, Text)
    T.breakOn Text
    modSep Text
    str of
            (Text
    a,Text
    b)
              | Text -> Bool
    T.null Text
    b  -> (Text, Text) -> Maybe (Text, Text)
    forall a. a -> Maybe a
    Just (MaybeAnon -> Text -> Text
    maybeAnonText MaybeAnon
    fl Text
    str, Text
    b)
              | Bool
    otherwise -> (Text, Text) -> Maybe (Text, Text)
    forall a. a -> Maybe a
    Just (Text
    a,Int -> Text -> Text
    T.drop (Text -> Int
    T.length Text
    modSep) Text
    b)

    -- | Break up a module name on the separators, `String` version
    modNameChunks :: ModName -> [String]
    modNameChunks :: ModName -> [String]
    modNameChunks = (Text -> String) -> [Text] -> [String]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> String
    T.unpack ([Text] -> [String]) -> (ModName -> [Text]) -> ModName -> [String]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ModName -> [Text]
    modNameChunksText

    packModName :: [T.Text] -> ModName
    packModName :: [Text] -> ModName
    packModName [Text]
    strs = Text -> ModName
    textToModName (Text -> [Text] -> Text
    T.intercalate Text
    modSep ((Text -> Text) -> [Text] -> [Text]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> Text
    trim [Text]
    strs))
      where
      -- trim space off of the start and end of the string
      trim :: Text -> Text
    trim Text
    str = (Char -> Bool) -> Text -> Text
    T.dropWhile Char -> Bool
    isSpace ((Char -> Bool) -> Text -> Text
    T.dropWhileEnd Char -> Bool
    isSpace Text
    str)

    modSep :: T.Text
    modSep :: Text
    modSep  = Text
    "::"

    preludeName :: ModName
    preludeName :: ModName
    preludeName  = [Text] -> ModName
    packModName [Text
    "Cryptol"]

    undefinedModName :: ModName
    undefinedModName :: ModName
    undefinedModName = [Text] -> ModName
    packModName [Text
    "Undefined module"]

    preludeReferenceName :: ModName
    preludeReferenceName :: ModName
    preludeReferenceName = [Text] -> ModName
    packModName [Text
    "Cryptol",Text
    "Reference"]

    floatName :: ModName
    floatName :: ModName
    floatName = [Text] -> ModName
    packModName [Text
    "Float"]

    arrayName :: ModName
    arrayName :: ModName
    arrayName  = [Text] -> ModName
    packModName [Text
    "Array"]

    suiteBName :: ModName
    suiteBName :: ModName
    suiteBName = [Text] -> ModName
    packModName [Text
    "SuiteB"]

    primeECName :: ModName
    primeECName :: ModName
    primeECName = [Text] -> ModName
    packModName [Text
    "PrimeEC"]

    interactiveName :: ModName
    interactiveName :: ModName
    interactiveName  = [Text] -> ModName
    packModName [Text
    "<interactive>"]

    noModuleName :: ModName
    noModuleName :: ModName
    noModuleName = [Text] -> ModName
    packModName [Text
    "<none>"]

    exprModName :: ModName
    exprModName :: ModName
    exprModName = [Text] -> ModName
    packModName [Text
    "<expr>"]

    --------------------------------------------------------------------------------
    -- | Identifies an entitiy
    data OrigName = OrigName
      { OrigName -> Namespace
    ogNamespace :: Namespace
      , OrigName -> ModPath
    ogModule    :: ModPath
      , OrigName -> OrigSource
    ogSource    :: OrigSource
      , OrigName -> Ident
    ogName      :: Ident
      } deriving (OrigName -> OrigName -> Bool
    (OrigName -> OrigName -> Bool)
    -> (OrigName -> OrigName -> Bool) -> Eq OrigName
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: OrigName -> OrigName -> Bool
    == :: OrigName -> OrigName -> Bool
    $c/= :: OrigName -> OrigName -> Bool
    /= :: OrigName -> OrigName -> Bool
    Eq,Eq OrigName
    Eq OrigName
    -> (OrigName -> OrigName -> Ordering)
    -> (OrigName -> OrigName -> Bool)
    -> (OrigName -> OrigName -> Bool)
    -> (OrigName -> OrigName -> Bool)
    -> (OrigName -> OrigName -> Bool)
    -> (OrigName -> OrigName -> OrigName)
    -> (OrigName -> OrigName -> OrigName)
    -> Ord OrigName
    OrigName -> OrigName -> Bool
    OrigName -> OrigName -> Ordering
    OrigName -> OrigName -> OrigName
    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 :: OrigName -> OrigName -> Ordering
    compare :: OrigName -> OrigName -> Ordering
    $c< :: OrigName -> OrigName -> Bool
    < :: OrigName -> OrigName -> Bool
    $c<= :: OrigName -> OrigName -> Bool
    <= :: OrigName -> OrigName -> Bool
    $c> :: OrigName -> OrigName -> Bool
    > :: OrigName -> OrigName -> Bool
    $c>= :: OrigName -> OrigName -> Bool
    >= :: OrigName -> OrigName -> Bool
    $cmax :: OrigName -> OrigName -> OrigName
    max :: OrigName -> OrigName -> OrigName
    $cmin :: OrigName -> OrigName -> OrigName
    min :: OrigName -> OrigName -> OrigName
    Ord,Int -> OrigName -> ShowS
    [OrigName] -> ShowS
    OrigName -> String
    (Int -> OrigName -> ShowS)
    -> (OrigName -> String) -> ([OrigName] -> ShowS) -> Show OrigName
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> OrigName -> ShowS
    showsPrec :: Int -> OrigName -> ShowS
    $cshow :: OrigName -> String
    show :: OrigName -> String
    $cshowList :: [OrigName] -> ShowS
    showList :: [OrigName] -> ShowS
    Show,(forall x. OrigName -> Rep OrigName x)
    -> (forall x. Rep OrigName x -> OrigName) -> Generic OrigName
    forall x. Rep OrigName x -> OrigName
    forall x. OrigName -> Rep OrigName x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. OrigName -> Rep OrigName x
    from :: forall x. OrigName -> Rep OrigName x
    $cto :: forall x. Rep OrigName x -> OrigName
    to :: forall x. Rep OrigName x -> OrigName
    Generic,OrigName -> ()
    (OrigName -> ()) -> NFData OrigName
    forall a. (a -> ()) -> NFData a
    $crnf :: OrigName -> ()
    rnf :: OrigName -> ()
    NFData)

    -- | Describes where a top-level name came from
    data OrigSource =
        FromDefinition
      | FromFunctorInst
      | FromModParam Ident
        deriving (OrigSource -> OrigSource -> Bool
    (OrigSource -> OrigSource -> Bool)
    -> (OrigSource -> OrigSource -> Bool) -> Eq OrigSource
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: OrigSource -> OrigSource -> Bool
    == :: OrigSource -> OrigSource -> Bool
    $c/= :: OrigSource -> OrigSource -> Bool
    /= :: OrigSource -> OrigSource -> Bool
    Eq,Eq OrigSource
    Eq OrigSource
    -> (OrigSource -> OrigSource -> Ordering)
    -> (OrigSource -> OrigSource -> Bool)
    -> (OrigSource -> OrigSource -> Bool)
    -> (OrigSource -> OrigSource -> Bool)
    -> (OrigSource -> OrigSource -> Bool)
    -> (OrigSource -> OrigSource -> OrigSource)
    -> (OrigSource -> OrigSource -> OrigSource)
    -> Ord OrigSource
    OrigSource -> OrigSource -> Bool
    OrigSource -> OrigSource -> Ordering
    OrigSource -> OrigSource -> OrigSource
    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 :: OrigSource -> OrigSource -> Ordering
    compare :: OrigSource -> OrigSource -> Ordering
    $c< :: OrigSource -> OrigSource -> Bool
    < :: OrigSource -> OrigSource -> Bool
    $c<= :: OrigSource -> OrigSource -> Bool
    <= :: OrigSource -> OrigSource -> Bool
    $c> :: OrigSource -> OrigSource -> Bool
    > :: OrigSource -> OrigSource -> Bool
    $c>= :: OrigSource -> OrigSource -> Bool
    >= :: OrigSource -> OrigSource -> Bool
    $cmax :: OrigSource -> OrigSource -> OrigSource
    max :: OrigSource -> OrigSource -> OrigSource
    $cmin :: OrigSource -> OrigSource -> OrigSource
    min :: OrigSource -> OrigSource -> OrigSource
    Ord,Int -> OrigSource -> ShowS
    [OrigSource] -> ShowS
    OrigSource -> String
    (Int -> OrigSource -> ShowS)
    -> (OrigSource -> String)
    -> ([OrigSource] -> ShowS)
    -> Show OrigSource
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> OrigSource -> ShowS
    showsPrec :: Int -> OrigSource -> ShowS
    $cshow :: OrigSource -> String
    show :: OrigSource -> String
    $cshowList :: [OrigSource] -> ShowS
    showList :: [OrigSource] -> ShowS
    Show,(forall x. OrigSource -> Rep OrigSource x)
    -> (forall x. Rep OrigSource x -> OrigSource) -> Generic OrigSource
    forall x. Rep OrigSource x -> OrigSource
    forall x. OrigSource -> Rep OrigSource x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. OrigSource -> Rep OrigSource x
    from :: forall x. OrigSource -> Rep OrigSource x
    $cto :: forall x. Rep OrigSource x -> OrigSource
    to :: forall x. Rep OrigSource x -> OrigSource
    Generic,OrigSource -> ()
    (OrigSource -> ()) -> NFData OrigSource
    forall a. (a -> ()) -> NFData a
    $crnf :: OrigSource -> ()
    rnf :: OrigSource -> ()
    NFData)

    -- | Returns true iff the 'ogSource' of the given 'OrigName' is 'FromModParam'
    ogFromModParam :: OrigName -> Bool
    ogFromModParam :: OrigName -> Bool
    ogFromModParam OrigName
    og = case OrigName -> OrigSource
    ogSource OrigName
    og of
                          FromModParam Ident
    _ -> Bool
    True
                          OrigSource
    _ -> Bool
    False

    --------------------------------------------------------------------------------

    {- | The type of identifiers.
      * The boolean flag indicates whether or not they're infix operators.
        The boolean is present just as cached information from the lexer,
        and never used during comparisons.
      * The MaybeAnon indicates if this is an anonymous name  -}
    data Ident = Ident Bool MaybeAnon T.Text
                 deriving (Int -> Ident -> ShowS
    [Ident] -> ShowS
    Ident -> String
    (Int -> Ident -> ShowS)
    -> (Ident -> String) -> ([Ident] -> ShowS) -> Show Ident
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Ident -> ShowS
    showsPrec :: Int -> Ident -> ShowS
    $cshow :: Ident -> String
    show :: Ident -> String
    $cshowList :: [Ident] -> ShowS
    showList :: [Ident] -> ShowS
    Show,(forall x. Ident -> Rep Ident x)
    -> (forall x. Rep Ident x -> Ident) -> Generic Ident
    forall x. Rep Ident x -> Ident
    forall x. Ident -> Rep Ident x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Ident -> Rep Ident x
    from :: forall x. Ident -> Rep Ident x
    $cto :: forall x. Rep Ident x -> Ident
    to :: forall x. Rep Ident x -> Ident
    Generic)

    instance Eq Ident where
      Ident
    a == :: Ident -> Ident -> Bool
    == Ident
    b = Ident -> Ident -> Ordering
    forall a. Ord a => a -> a -> Ordering
    compare Ident
    a Ident
    b Ordering -> Ordering -> Bool
    forall a. Eq a => a -> a -> Bool
    == Ordering
    EQ
      Ident
    a /= :: Ident -> Ident -> Bool
    /= Ident
    b = Ident -> Ident -> Ordering
    forall a. Ord a => a -> a -> Ordering
    compare Ident
    a Ident
    b Ordering -> Ordering -> Bool
    forall a. Eq a => a -> a -> Bool
    /= Ordering
    EQ

    instance Ord Ident where
      compare :: Ident -> Ident -> Ordering
    compare (Ident Bool
    _ MaybeAnon
    mb1 Text
    i1) (Ident Bool
    _ MaybeAnon
    mb2 Text
    i2) = (MaybeAnon, Text) -> (MaybeAnon, Text) -> Ordering
    forall a. Ord a => a -> a -> Ordering
    compare (MaybeAnon
    mb1,Text
    i1) (MaybeAnon
    mb2,Text
    i2)

    instance IsString Ident where
      fromString :: String -> Ident
    fromString String
    str = Text -> Ident
    mkIdent (String -> Text
    T.pack String
    str)

    instance NFData Ident

    -- | Make a normal (i.e., not anonymous) identifier
    packIdent :: String -> Ident
    packIdent :: String -> Ident
    packIdent  = Text -> Ident
    mkIdent (Text -> Ident) -> (String -> Text) -> String -> Ident
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Text
    T.pack

    -- | Make a normal (i.e., not anonymous) identifier
    packInfix :: String -> Ident
    packInfix :: String -> Ident
    packInfix  = Text -> Ident
    mkInfix (Text -> Ident) -> (String -> Text) -> String -> Ident
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Text
    T.pack

    unpackIdent :: Ident -> String
    unpackIdent :: Ident -> String
    unpackIdent  = Text -> String
    T.unpack (Text -> String) -> (Ident -> Text) -> Ident -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Ident -> Text
    identText

    -- | Make a normal (i.e., not anonymous) identifier
    mkIdent :: T.Text -> Ident
    mkIdent :: Text -> Ident
    mkIdent  = Bool -> MaybeAnon -> Text -> Ident
    Ident Bool
    False MaybeAnon
    NormalName

    mkInfix :: T.Text -> Ident
    mkInfix :: Text -> Ident
    mkInfix  = Bool -> MaybeAnon -> Text -> Ident
    Ident Bool
    True MaybeAnon
    NormalName

    isInfixIdent :: Ident -> Bool
    isInfixIdent :: Ident -> Bool
    isInfixIdent (Ident Bool
    b MaybeAnon
    _ Text
    _) = Bool
    b

    nullIdent :: Ident -> Bool
    nullIdent :: Ident -> Bool
    nullIdent = Text -> Bool
    T.null (Text -> Bool) -> (Ident -> Text) -> Ident -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Ident -> Text
    identText

    identText :: Ident -> T.Text
    identText :: Ident -> Text
    identText (Ident Bool
    _ MaybeAnon
    mb Text
    t) = MaybeAnon -> Text -> Text
    maybeAnonText MaybeAnon
    mb Text
    t

    modParamIdent :: Ident -> Ident
    modParamIdent :: Ident -> Ident
    modParamIdent (Ident Bool
    x MaybeAnon
    a Text
    t) =
      Bool -> MaybeAnon -> Text -> Ident
    Ident Bool
    x MaybeAnon
    a (Text -> Text -> Text
    T.append (String -> Text
    T.pack String
    "module parameter ") Text
    t)

    -- | Make an anonymous identifier for the module corresponding to
    -- a `where` block in a functor instantiation.
    identAnonArg :: Ident -> Ident
    identAnonArg :: Ident -> Ident
    identAnonArg (Ident Bool
    b MaybeAnon
    _ Text
    txt) = Bool -> MaybeAnon -> Text -> Ident
    Ident Bool
    b MaybeAnon
    AnonModArgName Text
    txt

    -- | Make an anonymous identifier for the interface corresponding to
    -- a `parameter` declaration.
    identAnonIfaceMod :: Ident -> Ident
    identAnonIfaceMod :: Ident -> Ident
    identAnonIfaceMod (Ident Bool
    b MaybeAnon
    _ Text
    txt) = Bool -> MaybeAnon -> Text -> Ident
    Ident Bool
    b MaybeAnon
    AnonIfaceModName Text
    txt

    identIsNormal :: Ident -> Bool
    identIsNormal :: Ident -> Bool
    identIsNormal (Ident Bool
    _ MaybeAnon
    mb Text
    _) = MaybeAnon -> Bool
    isNormal MaybeAnon
    mb

    --------------------------------------------------------------------------------

    -- | Information about anonymous names.
    data MaybeAnon = NormalName       -- ^ Not an anonymous name.
                   | AnonModArgName   -- ^ Anonymous module (from `where`)
                   | AnonIfaceModName -- ^ Anonymous interface (from `parameter`)
      deriving (MaybeAnon -> MaybeAnon -> Bool
    (MaybeAnon -> MaybeAnon -> Bool)
    -> (MaybeAnon -> MaybeAnon -> Bool) -> Eq MaybeAnon
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: MaybeAnon -> MaybeAnon -> Bool
    == :: MaybeAnon -> MaybeAnon -> Bool
    $c/= :: MaybeAnon -> MaybeAnon -> Bool
    /= :: MaybeAnon -> MaybeAnon -> Bool
    Eq,Eq MaybeAnon
    Eq MaybeAnon
    -> (MaybeAnon -> MaybeAnon -> Ordering)
    -> (MaybeAnon -> MaybeAnon -> Bool)
    -> (MaybeAnon -> MaybeAnon -> Bool)
    -> (MaybeAnon -> MaybeAnon -> Bool)
    -> (MaybeAnon -> MaybeAnon -> Bool)
    -> (MaybeAnon -> MaybeAnon -> MaybeAnon)
    -> (MaybeAnon -> MaybeAnon -> MaybeAnon)
    -> Ord MaybeAnon
    MaybeAnon -> MaybeAnon -> Bool
    MaybeAnon -> MaybeAnon -> Ordering
    MaybeAnon -> MaybeAnon -> MaybeAnon
    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 :: MaybeAnon -> MaybeAnon -> Ordering
    compare :: MaybeAnon -> MaybeAnon -> Ordering
    $c< :: MaybeAnon -> MaybeAnon -> Bool
    < :: MaybeAnon -> MaybeAnon -> Bool
    $c<= :: MaybeAnon -> MaybeAnon -> Bool
    <= :: MaybeAnon -> MaybeAnon -> Bool
    $c> :: MaybeAnon -> MaybeAnon -> Bool
    > :: MaybeAnon -> MaybeAnon -> Bool
    $c>= :: MaybeAnon -> MaybeAnon -> Bool
    >= :: MaybeAnon -> MaybeAnon -> Bool
    $cmax :: MaybeAnon -> MaybeAnon -> MaybeAnon
    max :: MaybeAnon -> MaybeAnon -> MaybeAnon
    $cmin :: MaybeAnon -> MaybeAnon -> MaybeAnon
    min :: MaybeAnon -> MaybeAnon -> MaybeAnon
    Ord,Int -> MaybeAnon -> ShowS
    [MaybeAnon] -> ShowS
    MaybeAnon -> String
    (Int -> MaybeAnon -> ShowS)
    -> (MaybeAnon -> String)
    -> ([MaybeAnon] -> ShowS)
    -> Show MaybeAnon
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> MaybeAnon -> ShowS
    showsPrec :: Int -> MaybeAnon -> ShowS
    $cshow :: MaybeAnon -> String
    show :: MaybeAnon -> String
    $cshowList :: [MaybeAnon] -> ShowS
    showList :: [MaybeAnon] -> ShowS
    Show,(forall x. MaybeAnon -> Rep MaybeAnon x)
    -> (forall x. Rep MaybeAnon x -> MaybeAnon) -> Generic MaybeAnon
    forall x. Rep MaybeAnon x -> MaybeAnon
    forall x. MaybeAnon -> Rep MaybeAnon x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. MaybeAnon -> Rep MaybeAnon x
    from :: forall x. MaybeAnon -> Rep MaybeAnon x
    $cto :: forall x. Rep MaybeAnon x -> MaybeAnon
    to :: forall x. Rep MaybeAnon x -> MaybeAnon
    Generic)

    instance NFData MaybeAnon

    -- | Modify a name, if it is a nonymous
    maybeAnonText :: MaybeAnon -> Text -> Text
    maybeAnonText :: MaybeAnon -> Text -> Text
    maybeAnonText MaybeAnon
    mb Text
    txt =
      case MaybeAnon
    mb of
        MaybeAnon
    NormalName       -> Text
    txt
        MaybeAnon
    AnonModArgName   -> Text
    "`where` argument of " Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    txt
        MaybeAnon
    AnonIfaceModName -> Text
    "`parameter` interface of " Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    txt

    isNormal :: MaybeAnon -> Bool
    isNormal :: MaybeAnon -> Bool
    isNormal MaybeAnon
    mb =
      case MaybeAnon
    mb of
        MaybeAnon
    NormalName -> Bool
    True
        MaybeAnon
    _          -> Bool
    False

    --------------------------------------------------------------------------------

    {- | A way to identify primitives: we used to use just 'Ident', but this
    isn't good anymore as now we have primitives in multiple modules.
    This is used as a key when we need to lookup details about a specific
    primitive.  Also, this is intended to mostly be used internally, so
    we don't store the fixity flag of the `Ident` -}
    data PrimIdent = PrimIdent ModName T.Text
      deriving (PrimIdent -> PrimIdent -> Bool
    (PrimIdent -> PrimIdent -> Bool)
    -> (PrimIdent -> PrimIdent -> Bool) -> Eq PrimIdent
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: PrimIdent -> PrimIdent -> Bool
    == :: PrimIdent -> PrimIdent -> Bool
    $c/= :: PrimIdent -> PrimIdent -> Bool
    /= :: PrimIdent -> PrimIdent -> Bool
    Eq,Eq PrimIdent
    Eq PrimIdent
    -> (PrimIdent -> PrimIdent -> Ordering)
    -> (PrimIdent -> PrimIdent -> Bool)
    -> (PrimIdent -> PrimIdent -> Bool)
    -> (PrimIdent -> PrimIdent -> Bool)
    -> (PrimIdent -> PrimIdent -> Bool)
    -> (PrimIdent -> PrimIdent -> PrimIdent)
    -> (PrimIdent -> PrimIdent -> PrimIdent)
    -> Ord PrimIdent
    PrimIdent -> PrimIdent -> Bool
    PrimIdent -> PrimIdent -> Ordering
    PrimIdent -> PrimIdent -> PrimIdent
    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 :: PrimIdent -> PrimIdent -> Ordering
    compare :: PrimIdent -> PrimIdent -> Ordering
    $c< :: PrimIdent -> PrimIdent -> Bool
    < :: PrimIdent -> PrimIdent -> Bool
    $c<= :: PrimIdent -> PrimIdent -> Bool
    <= :: PrimIdent -> PrimIdent -> Bool
    $c> :: PrimIdent -> PrimIdent -> Bool
    > :: PrimIdent -> PrimIdent -> Bool
    $c>= :: PrimIdent -> PrimIdent -> Bool
    >= :: PrimIdent -> PrimIdent -> Bool
    $cmax :: PrimIdent -> PrimIdent -> PrimIdent
    max :: PrimIdent -> PrimIdent -> PrimIdent
    $cmin :: PrimIdent -> PrimIdent -> PrimIdent
    min :: PrimIdent -> PrimIdent -> PrimIdent
    Ord,Int -> PrimIdent -> ShowS
    [PrimIdent] -> ShowS
    PrimIdent -> String
    (Int -> PrimIdent -> ShowS)
    -> (PrimIdent -> String)
    -> ([PrimIdent] -> ShowS)
    -> Show PrimIdent
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> PrimIdent -> ShowS
    showsPrec :: Int -> PrimIdent -> ShowS
    $cshow :: PrimIdent -> String
    show :: PrimIdent -> String
    $cshowList :: [PrimIdent] -> ShowS
    showList :: [PrimIdent] -> ShowS
    Show,(forall x. PrimIdent -> Rep PrimIdent x)
    -> (forall x. Rep PrimIdent x -> PrimIdent) -> Generic PrimIdent
    forall x. Rep PrimIdent x -> PrimIdent
    forall x. PrimIdent -> Rep PrimIdent x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. PrimIdent -> Rep PrimIdent x
    from :: forall x. PrimIdent -> Rep PrimIdent x
    $cto :: forall x. Rep PrimIdent x -> PrimIdent
    to :: forall x. Rep PrimIdent x -> PrimIdent
    Generic)

    -- | A shortcut to make (non-infix) primitives in the prelude.
    prelPrim :: T.Text -> PrimIdent
    prelPrim :: Text -> PrimIdent
    prelPrim = ModName -> Text -> PrimIdent
    PrimIdent ModName
    preludeName

    floatPrim :: T.Text -> PrimIdent
    floatPrim :: Text -> PrimIdent
    floatPrim = ModName -> Text -> PrimIdent
    PrimIdent ModName
    floatName

    suiteBPrim :: T.Text -> PrimIdent
    suiteBPrim :: Text -> PrimIdent
    suiteBPrim = ModName -> Text -> PrimIdent
    PrimIdent ModName
    suiteBName

    primeECPrim :: T.Text -> PrimIdent
    primeECPrim :: Text -> PrimIdent
    primeECPrim = ModName -> Text -> PrimIdent
    PrimIdent ModName
    primeECName

    arrayPrim :: T.Text -> PrimIdent
    arrayPrim :: Text -> PrimIdent
    arrayPrim = ModName -> Text -> PrimIdent
    PrimIdent ModName
    arrayName

    instance NFData PrimIdent