    {-|
      Copyright   :  (C) 2013-2016, University of Twente,
                         2016-2017, Myrtle Software Ltd,
                         2017-2022, Google Inc.,
                         2017-2023, QBayLogic B.V.
      License     :  BSD2 (see the file LICENSE)
      Maintainer  :  QBayLogic B.V. <devops@qbaylogic.com>
    -}

    {-# LANGUAGE CPP #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}
    {-# LANGUAGE MagicHash #-}
    {-# LANGUAGE NamedFieldPuns #-}
    {-# LANGUAGE OverloadedStrings #-}
    {-# LANGUAGE RankNTypes #-}
    {-# LANGUAGE TemplateHaskell #-}
    {-# LANGUAGE UnboxedTuples #-}

    {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}

    module Clash.GHC.Evaluator.Primitive
      ( ghcPrimStep
      , ghcPrimUnwind
      , isUndefinedPrimVal
      , isUndefinedXPrimVal
      ) where

    import           Control.Concurrent.Supply  (Supply,freshId)
    import           Control.DeepSeq            (force)
    import           Control.Exception          (ArithException(..), Exception, tryJust, evaluate)
    import           Control.Monad.State.Strict (State, MonadState)
    import qualified Control.Monad.State.Strict as State
    import           Control.Monad.Trans.Except (runExcept)
    import           Data.Binary.IEEE754        (doubleToWord, floatToWord, wordToDouble, wordToFloat)
    import           Data.Bits
    import qualified Data.ByteString.Internal as BS
    import           Data.Char           (chr,ord)
    import qualified Data.Either         as Either
    import           Data.Maybe (fromMaybe, mapMaybe)
    import qualified Data.List           as List
    import qualified Data.Primitive.ByteArray as BA
    import           Data.Proxy          (Proxy)
    import           Data.Reflection     (reifyNat)
    import           Data.Text           (Text)
    import qualified Data.Text           as Text
    import           GHC.Exts (IsList(..))
    import           GHC.Float
    import           GHC.Int
    import           GHC.Integer
      (decodeDoubleInteger,encodeDoubleInteger,compareInteger,orInteger,andInteger,
       xorInteger,complementInteger,absInteger,signumInteger)
    #if MIN_VERSION_base(4,16,0)
    import           GHC.Num.Integer (Integer (..), integerEncodeFloat#)
    #elif MIN_VERSION_base(4,15,0)
    import           GHC.Num.Integer
      (Integer (..), integerEncodeFloat#, integerToFloat#, integerToDouble#)
    #else
    import           GHC.Integer.GMP.Internals
      (Integer (..), BigNat (..))
    #endif
    #if MIN_VERSION_base(4,15,0)
    import           GHC.Num.Natural     (naturalSubUnsafe)
    #endif
    import           GHC.Natural
    import           GHC.ForeignPtr
    import           GHC.Prim
    import           GHC.Real            (Ratio (..))
    import           GHC.TypeLits        (KnownNat)
    import           GHC.Types           (IO (..))
    import           GHC.Word
    import           System.IO.Unsafe    (unsafeDupablePerformIO)
    #if MIN_VERSION_ghc(9,4,0)
    import           Data.Bifunctor      (first)
    import qualified Data.Text.Array     as Text
    import qualified Data.Text.Internal  as Text
    #endif

    #if MIN_VERSION_ghc(9,0,0)
    import           GHC.Types.Basic     (Boxity (..))
    import           GHC.Types.Name      (getSrcSpan, nameOccName, occNameString)
    import           GHC.Builtin.Names   (trueDataConKey, falseDataConKey)
    import qualified GHC.Core.TyCon      as TyCon
    import           GHC.Builtin.Types   (tupleTyCon)
    import           GHC.Types.Unique    (getKey)
    #else
    import           BasicTypes          (Boxity (..))
    import           Name                (getSrcSpan, nameOccName, occNameString)
    import           PrelNames           (trueDataConKey, falseDataConKey)
    import qualified TyCon
    import           TysWiredIn          (tupleTyCon)
    import           Unique              (getKey)
    #endif

    import           Clash.Class.BitPack (pack,unpack)
    import           Clash.Core.DataCon  (DataCon (..))
    import           Clash.Core.Evaluator.Types
    import           Clash.Core.HasType  (piResultTys, applyTypeToArgs)
    import           Clash.Core.Literal  (Literal (..))
    import           Clash.Core.Name
      (Name (..), NameSort (..), mkUnsafeSystemName)
    import           Clash.Core.Pretty   (showPpr)
    import           Clash.Core.Term
      (IsMultiPrim (..), Pat (..), PrimInfo (..), Term (..), WorkInfo (..), mkApps,
       PrimUnfolding(..), collectArgs)
    import           Clash.Core.Type
      (Type (..), ConstTy (..), LitTy (..), TypeView (..), mkFunTy, mkTyConApp,
       splitFunForallTy, tyView)
    import           Clash.Core.TyCon
      (TyConMap, TyConName, tyConDataCons)
    import           Clash.Core.TysPrim
    import           Clash.Core.Util
      (mkRTree,mkVec,tyNatSize,dataConInstArgTys,primCo, mkSelectorCase,undefinedPrims,
       undefinedXPrims)
    import           Clash.Core.Var      (mkLocalId, mkTyVar)
    import qualified Clash.Data.UniqMap as UniqMap
    import           Clash.Debug
    import           Clash.GHC.GHC2Core  (modNameM)
    import           Clash.Util
      (MonadUnique (..), clogBase, flogBase, curLoc)
    import           Clash.Normalize.PrimitiveReductions
      (typeNatMul, typeNatSub, typeNatAdd, vecLastPrim, vecInitPrim, vecHeadPrim,
       vecTailPrim, mkVecCons, mkVecNil)

    import qualified Clash.Normalize.Primitives as NP
    import Clash.Promoted.Nat.Unsafe (unsafeSNat)
    import qualified Clash.Sized.Internal.BitVector as BitVector
    import qualified Clash.Sized.Internal.Signed    as Signed
    import qualified Clash.Sized.Internal.Unsigned  as Unsigned
    import Clash.Sized.Internal.BitVector(BitVector(..), Bit(..))
    import Clash.Sized.Internal.Signed   (Signed   (..))
    import Clash.Sized.Internal.Unsigned (Unsigned (..))
    import Clash.XException (isX)

    import {-# SOURCE #-} Clash.GHC.Evaluator

    isUndefinedPrimVal :: Value -> Bool
    isUndefinedPrimVal :: Value -> Bool
    isUndefinedPrimVal (PrimVal (PrimInfo{Text
    primName :: Text
    primName :: PrimInfo -> Text
    primName}) [Type]
    _ [Value]
    _) =
      Text
    primName Text -> [Text] -> Bool
    forall a. Eq a => a -> [a] -> Bool
    forall (t :: Type -> Type) a.
    (Foldable t, Eq a) =>
    a -> t a -> Bool
    `elem` [Text]
    undefinedPrims
    isUndefinedPrimVal Value
    _ = Bool
    False

    isUndefinedXPrimVal :: Value -> Bool
    isUndefinedXPrimVal :: Value -> Bool
    isUndefinedXPrimVal (PrimVal (PrimInfo{Text
    primName :: PrimInfo -> Text
    primName :: Text
    primName}) [Type]
    _ [Value]
    _) =
      Text
    primName Text -> [Text] -> Bool
    forall a. Eq a => a -> [a] -> Bool
    forall (t :: Type -> Type) a.
    (Foldable t, Eq a) =>
    a -> t a -> Bool
    `elem` [Text]
    undefinedXPrims
    isUndefinedXPrimVal Value
    _ = Bool
    False

    -- | Evaluation of primitive operations.
    ghcPrimUnwind :: PrimUnwind
    ghcPrimUnwind :: PrimUnwind
    ghcPrimUnwind TyConMap
    tcm PrimInfo
    p [Type]
    tys [Value]
    vs Value
    v [] Machine
    m
      | PrimInfo -> Text
    primName PrimInfo
    p Text -> [Text] -> Bool
    forall a. Eq a => a -> [a] -> Bool
    forall (t :: Type -> Type) a.
    (Foldable t, Eq a) =>
    a -> t a -> Bool
    `elem` [ Text
    "Clash.Sized.Internal.Index.fromInteger#"
                           , Text
    "GHC.CString.unpackCString#"
                           , [Char] -> Text
    Text.pack (Name -> [Char]
    forall a. Show a => a -> [Char]
    show 'NP.removedArg)
                           , Text
    "GHC.Prim.MutableByteArray#"
                           , [Char] -> Text
    Text.pack (Name -> [Char]
    forall a. Show a => a -> [Char]
    show 'NP.undefined)
                           , [Char] -> Text
    Text.pack (Name -> [Char]
    forall a. Show a => a -> [Char]
    show 'NP.undefinedX)
                           ]
                  -- The above primitives are actually values, and not operations.
      = Unwind
    ghcUnwind (PrimInfo -> [Type] -> [Value] -> Value
    PrimVal PrimInfo
    p [Type]
    tys ([Value]
    vs [Value] -> [Value] -> [Value]
    forall a. [a] -> [a] -> [a]
    ++ [Value
    v])) Machine
    m TyConMap
    tcm
      | PrimInfo -> Text
    primName PrimInfo
    p Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    "Clash.Sized.Internal.BitVector.fromInteger#"
      = case ([Value]
    vs,Value
    v) of
        ([Value -> Maybe Integer
    naturalLiteral -> Just Integer
    n,Value
    mask], Value -> Maybe Integer
    integerLiteral -> Just Integer
    i) ->
          Unwind
    ghcUnwind (PrimInfo -> [Type] -> [Value] -> Value
    PrimVal PrimInfo
    p [Type]
    tys [Literal -> Value
    Lit (Integer -> Literal
    NaturalLiteral Integer
    n), Value
    mask, Literal -> Value
    Lit (Integer -> Literal
    IntegerLiteral (Integer -> Integer -> Integer
    wrapUnsigned Integer
    n Integer
    i))]) Machine
    m TyConMap
    tcm
        ([Value], Value)
    _ -> [Char] -> Maybe Machine
    forall a. HasCallStack => [Char] -> a
    error ($(curLoc) [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "Internal error"  [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ ([Value], Value) -> [Char]
    forall a. Show a => a -> [Char]
    show ([Value]
    vs,Value
    v))
      | PrimInfo -> Text
    primName PrimInfo
    p Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    "Clash.Sized.Internal.BitVector.fromInteger##"
      = case ([Value]
    vs,Value
    v) of
        ([Value
    mask], Value -> Maybe Integer
    integerLiteral -> Just Integer
    i) ->
          Unwind
    ghcUnwind (PrimInfo -> [Type] -> [Value] -> Value
    PrimVal PrimInfo
    p [Type]
    tys [Value
    mask, Literal -> Value
    Lit (Integer -> Literal
    IntegerLiteral (Integer -> Integer -> Integer
    wrapUnsigned Integer
    1 Integer
    i))]) Machine
    m TyConMap
    tcm
        ([Value], Value)
    _ -> [Char] -> Maybe Machine
    forall a. HasCallStack => [Char] -> a
    error ($(curLoc) [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "Internal error"  [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ ([Value], Value) -> [Char]
    forall a. Show a => a -> [Char]
    show ([Value]
    vs,Value
    v))
      | PrimInfo -> Text
    primName PrimInfo
    p Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    "Clash.Sized.Internal.Signed.fromInteger#"
      = case ([Value]
    vs,Value
    v) of
        ([Value -> Maybe Integer
    naturalLiteral -> Just Integer
    n],Value -> Maybe Integer
    integerLiteral -> Just Integer
    i) ->
          Unwind
    ghcUnwind (PrimInfo -> [Type] -> [Value] -> Value
    PrimVal PrimInfo
    p [Type]
    tys [Literal -> Value
    Lit (Integer -> Literal
    NaturalLiteral Integer
    n), Literal -> Value
    Lit (Integer -> Literal
    IntegerLiteral (Integer -> Integer -> Integer
    wrapSigned Integer
    n Integer
    i))]) Machine
    m TyConMap
    tcm
        ([Value], Value)
    _ -> [Char] -> Maybe Machine
    forall a. HasCallStack => [Char] -> a
    error ($(curLoc) [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "Internal error"  [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ ([Value], Value) -> [Char]
    forall a. Show a => a -> [Char]
    show ([Value]
    vs,Value
    v))
      | PrimInfo -> Text
    primName PrimInfo
    p Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    "Clash.Sized.Internal.Unsigned.fromInteger#"
      = case ([Value]
    vs,Value
    v) of
        ([Value -> Maybe Integer
    naturalLiteral -> Just Integer
    n],Value -> Maybe Integer
    integerLiteral -> Just Integer
    i) ->
          Unwind
    ghcUnwind (PrimInfo -> [Type] -> [Value] -> Value
    PrimVal PrimInfo
    p [Type]
    tys [Literal -> Value
    Lit (Integer -> Literal
    NaturalLiteral Integer
    n), Literal -> Value
    Lit (Integer -> Literal
    IntegerLiteral (Integer -> Integer -> Integer
    wrapUnsigned Integer
    n Integer
    i))]) Machine
    m TyConMap
    tcm
        ([Value], Value)
    _ -> [Char] -> Maybe Machine
    forall a. HasCallStack => [Char] -> a
    error ($(curLoc) [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "Internal error"  [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ ([Value], Value) -> [Char]
    forall a. Show a => a -> [Char]
    show ([Value]
    vs,Value
    v))
      | Value -> Bool
    isUndefinedPrimVal Value
    v
      = let tyArgs :: [Either a Type]
    tyArgs = (Type -> Either a Type) -> [Type] -> [Either a Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either a Type
    forall a b. b -> Either a b
    Right [Type]
    tys
            tmArgs :: [Either Term b]
    tmArgs = (Value -> Either Term b) -> [Value] -> [Either Term b]
    forall a b. (a -> b) -> [a] -> [b]
    map (Term -> Either Term b
    forall a b. a -> Either a b
    Left (Term -> Either Term b)
    -> (Value -> Term) -> Value -> Either Term b
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Value -> Term
    valToTerm) ([Value]
    vs [Value] -> [Value] -> [Value]
    forall a. [a] -> [a] -> [a]
    ++ [Value
    v])
        in  Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ (Term -> Machine -> Machine) -> Machine -> Term -> Machine
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Term -> Machine -> Machine
    setTerm Machine
    m (Term -> Machine) -> Term -> Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Type -> Term
    TyApp (PrimInfo -> Term
    Prim PrimInfo
    NP.undefined) (Type -> Term) -> Type -> Term
    forall a b. (a -> b) -> a -> b
    $
              Term -> TyConMap -> Type -> [Either Term Type] -> Type
    applyTypeToArgs (PrimInfo -> Term
    Prim PrimInfo
    p) TyConMap
    tcm (PrimInfo -> Type
    primType PrimInfo
    p) ([Either Term Type]
    forall {a}. [Either a Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++ [Either Term Type]
    forall {b}. [Either Term b]
    tmArgs)
      | Value -> Bool
    isUndefinedXPrimVal Value
    v
      = let tyArgs :: [Either a Type]
    tyArgs = (Type -> Either a Type) -> [Type] -> [Either a Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either a Type
    forall a b. b -> Either a b
    Right [Type]
    tys
            tmArgs :: [Either Term b]
    tmArgs = (Value -> Either Term b) -> [Value] -> [Either Term b]
    forall a b. (a -> b) -> [a] -> [b]
    map (Term -> Either Term b
    forall a b. a -> Either a b
    Left (Term -> Either Term b)
    -> (Value -> Term) -> Value -> Either Term b
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Value -> Term
    valToTerm) ([Value]
    vs [Value] -> [Value] -> [Value]
    forall a. [a] -> [a] -> [a]
    ++ [Value
    v])
        in  Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ (Term -> Machine -> Machine) -> Machine -> Term -> Machine
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Term -> Machine -> Machine
    setTerm Machine
    m (Term -> Machine) -> Term -> Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Type -> Term
    TyApp (PrimInfo -> Term
    Prim PrimInfo
    NP.undefinedX) (Type -> Term) -> Type -> Term
    forall a b. (a -> b) -> a -> b
    $
              Term -> TyConMap -> Type -> [Either Term Type] -> Type
    applyTypeToArgs (PrimInfo -> Term
    Prim PrimInfo
    p) TyConMap
    tcm (PrimInfo -> Type
    primType PrimInfo
    p) ([Either Term Type]
    forall {a}. [Either a Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++ [Either Term Type]
    forall {b}. [Either Term b]
    tmArgs)
      | Bool
    otherwise
      = PrimStep
    ghcPrimStep TyConMap
    tcm (Machine -> Bool
    forcePrims Machine
    m) PrimInfo
    p [Type]
    tys ([Value]
    vs [Value] -> [Value] -> [Value]
    forall a. [a] -> [a] -> [a]
    ++ [Value
    v]) Machine
    m

    ghcPrimUnwind TyConMap
    tcm PrimInfo
    p [Type]
    tys [Value]
    vs Value
    v [Term
    e] Machine
    m0
      -- Note [Lazy primitives]
      -- ~~~~~~~~~~~~~~~~~~~~~~
      --
      -- Primitives are usually considered undefined when one of their arguments is
      -- (unless they're unused). _Some_ primitives can still yield a result even
      -- though one of their arguments is undefined. It turns out that all primitives
      -- exhibiting this property happen to be "lazy" in their last argument. Thus,
      -- all the cases can be covered by a match on [e] and their names:
      | PrimInfo -> Text
    primName PrimInfo
    p Text -> [Text] -> Bool
    forall a. Eq a => a -> [a] -> Bool
    forall (t :: Type -> Type) a.
    (Foldable t, Eq a) =>
    a -> t a -> Bool
    `elem` [ Text
    "Clash.Sized.Vector.lazyV"
                           , Text
    "Clash.Sized.Vector.replicate"
                           , Text
    "Clash.Sized.Vector.replace_int"
                           , Text
    "GHC.Classes.&&"
                           , Text
    "GHC.Classes.||"
                           , Text
    "Clash.Class.BitPack.Internal.xToBV"
                           , Text
    "Clash.Sized.Vector.imap_go"
                           ]
      = if Value -> Bool
    isUndefinedPrimVal Value
    v then
          let tyArgs :: [Either a Type]
    tyArgs = (Type -> Either a Type) -> [Type] -> [Either a Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either a Type
    forall a b. b -> Either a b
    Right [Type]
    tys
              tmArgs :: [Either Term b]
    tmArgs = (Value -> Either Term b) -> [Value] -> [Either Term b]
    forall a b. (a -> b) -> [a] -> [b]
    map (Term -> Either Term b
    forall a b. a -> Either a b
    Left (Term -> Either Term b)
    -> (Value -> Term) -> Value -> Either Term b
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Value -> Term
    valToTerm) ([Value]
    vs [Value] -> [Value] -> [Value]
    forall a. [a] -> [a] -> [a]
    ++ [Value
    v]) [Either Term b] -> [Either Term b] -> [Either Term b]
    forall a. [a] -> [a] -> [a]
    ++ [Term -> Either Term b
    forall a b. a -> Either a b
    Left Term
    e]
          in  Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ (Term -> Machine -> Machine) -> Machine -> Term -> Machine
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Term -> Machine -> Machine
    setTerm Machine
    m0 (Term -> Machine) -> Term -> Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Type -> Term
    TyApp (PrimInfo -> Term
    Prim PrimInfo
    NP.undefined) (Type -> Term) -> Type -> Term
    forall a b. (a -> b) -> a -> b
    $
                Term -> TyConMap -> Type -> [Either Term Type] -> Type
    applyTypeToArgs (PrimInfo -> Term
    Prim PrimInfo
    p) TyConMap
    tcm (PrimInfo -> Type
    primType PrimInfo
    p) ([Either Term Type]
    forall {a}. [Either a Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++ [Either Term Type]
    forall {b}. [Either Term b]
    tmArgs)
        else
          let (Machine
    m1,Id
    i) = TyConMap -> Machine -> Term -> (Machine, Id)
    newLetBinding TyConMap
    tcm Machine
    m0 Term
    e
          in  PrimStep
    ghcPrimStep TyConMap
    tcm (Machine -> Bool
    forcePrims Machine
    m0) PrimInfo
    p [Type]
    tys ([Value]
    vs [Value] -> [Value] -> [Value]
    forall a. [a] -> [a] -> [a]
    ++ [Value
    v,Term -> Value
    Suspend (Id -> Term
    Var Id
    i)]) Machine
    m1

    ghcPrimUnwind TyConMap
    tcm PrimInfo
    p [Type]
    tys [Value]
    vs (Value -> (Value, [TickInfo])
    collectValueTicks -> (Value
    v, [TickInfo]
    ts)) (Term
    e:[Term]
    es) Machine
    m
      | Value -> Bool
    isUndefinedPrimVal Value
    v
      = let tyArgs :: [Either a Type]
    tyArgs = (Type -> Either a Type) -> [Type] -> [Either a Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either a Type
    forall a b. b -> Either a b
    Right [Type]
    tys
            tmArgs :: [Either Term b]
    tmArgs = (Value -> Either Term b) -> [Value] -> [Either Term b]
    forall a b. (a -> b) -> [a] -> [b]
    map (Term -> Either Term b
    forall a b. a -> Either a b
    Left (Term -> Either Term b)
    -> (Value -> Term) -> Value -> Either Term b
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Value -> Term
    valToTerm) ([Value]
    vs [Value] -> [Value] -> [Value]
    forall a. [a] -> [a] -> [a]
    ++ [Value
    v]) [Either Term b] -> [Either Term b] -> [Either Term b]
    forall a. [a] -> [a] -> [a]
    ++ (Term -> Either Term b) -> [Term] -> [Either Term b]
    forall a b. (a -> b) -> [a] -> [b]
    map Term -> Either Term b
    forall a b. a -> Either a b
    Left (Term
    eTerm -> [Term] -> [Term]
    forall a. a -> [a] -> [a]
    :[Term]
    es)
        in  Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ (Term -> Machine -> Machine) -> Machine -> Term -> Machine
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Term -> Machine -> Machine
    setTerm Machine
    m (Term -> Machine) -> Term -> Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Type -> Term
    TyApp (PrimInfo -> Term
    Prim PrimInfo
    NP.undefined) (Type -> Term) -> Type -> Term
    forall a b. (a -> b) -> a -> b
    $
              Term -> TyConMap -> Type -> [Either Term Type] -> Type
    applyTypeToArgs (PrimInfo -> Term
    Prim PrimInfo
    p) TyConMap
    tcm (PrimInfo -> Type
    primType PrimInfo
    p) ([Either Term Type]
    forall {a}. [Either a Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++ [Either Term Type]
    forall {b}. [Either Term b]
    tmArgs)
      | Bool
    otherwise
      = Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine)
    -> (Machine -> Machine) -> Machine -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Term -> Machine -> Machine
    setTerm Term
    e (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ StackFrame -> Machine -> Machine
    stackPush (PrimInfo -> [Type] -> [Value] -> [Term] -> StackFrame
    PrimApply PrimInfo
    p [Type]
    tys ([Value]
    vs [Value] -> [Value] -> [Value]
    forall a. [a] -> [a] -> [a]
    ++ [(TickInfo -> Value -> Value) -> Value -> [TickInfo] -> Value
    forall a b. (a -> b -> b) -> b -> [a] -> b
    forall (t :: Type -> Type) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr TickInfo -> Value -> Value
    TickValue Value
    v [TickInfo]
    ts]) [Term]
    es) Machine
    m

    newtype PrimEvalMonad a = PEM (State Supply a)
      deriving ((forall a b. (a -> b) -> PrimEvalMonad a -> PrimEvalMonad b)
    -> (forall a b. a -> PrimEvalMonad b -> PrimEvalMonad a)
    -> Functor PrimEvalMonad
    forall a b. a -> PrimEvalMonad b -> PrimEvalMonad a
    forall a b. (a -> b) -> PrimEvalMonad a -> PrimEvalMonad b
    forall (f :: Type -> Type).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    $cfmap :: forall a b. (a -> b) -> PrimEvalMonad a -> PrimEvalMonad b
    fmap :: forall a b. (a -> b) -> PrimEvalMonad a -> PrimEvalMonad b
    $c<$ :: forall a b. a -> PrimEvalMonad b -> PrimEvalMonad a
    <$ :: forall a b. a -> PrimEvalMonad b -> PrimEvalMonad a
    Functor, Functor PrimEvalMonad
    Functor PrimEvalMonad
    -> (forall a. a -> PrimEvalMonad a)
    -> (forall a b.
        PrimEvalMonad (a -> b) -> PrimEvalMonad a -> PrimEvalMonad b)
    -> (forall a b c.
        (a -> b -> c)
        -> PrimEvalMonad a -> PrimEvalMonad b -> PrimEvalMonad c)
    -> (forall a b.
        PrimEvalMonad a -> PrimEvalMonad b -> PrimEvalMonad b)
    -> (forall a b.
        PrimEvalMonad a -> PrimEvalMonad b -> PrimEvalMonad a)
    -> Applicative PrimEvalMonad
    forall a. a -> PrimEvalMonad a
    forall a b. PrimEvalMonad a -> PrimEvalMonad b -> PrimEvalMonad a
    forall a b. PrimEvalMonad a -> PrimEvalMonad b -> PrimEvalMonad b
    forall a b.
    PrimEvalMonad (a -> b) -> PrimEvalMonad a -> PrimEvalMonad b
    forall a b c.
    (a -> b -> c)
    -> PrimEvalMonad a -> PrimEvalMonad b -> PrimEvalMonad c
    forall (f :: Type -> Type).
    Functor f
    -> (forall a. a -> f a)
    -> (forall a b. f (a -> b) -> f a -> f b)
    -> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
    -> (forall a b. f a -> f b -> f b)
    -> (forall a b. f a -> f b -> f a)
    -> Applicative f
    $cpure :: forall a. a -> PrimEvalMonad a
    pure :: forall a. a -> PrimEvalMonad a
    $c<*> :: forall a b.
    PrimEvalMonad (a -> b) -> PrimEvalMonad a -> PrimEvalMonad b
    <*> :: forall a b.
    PrimEvalMonad (a -> b) -> PrimEvalMonad a -> PrimEvalMonad b
    $cliftA2 :: forall a b c.
    (a -> b -> c)
    -> PrimEvalMonad a -> PrimEvalMonad b -> PrimEvalMonad c
    liftA2 :: forall a b c.
    (a -> b -> c)
    -> PrimEvalMonad a -> PrimEvalMonad b -> PrimEvalMonad c
    $c*> :: forall a b. PrimEvalMonad a -> PrimEvalMonad b -> PrimEvalMonad b
    *> :: forall a b. PrimEvalMonad a -> PrimEvalMonad b -> PrimEvalMonad b
    $c<* :: forall a b. PrimEvalMonad a -> PrimEvalMonad b -> PrimEvalMonad a
    <* :: forall a b. PrimEvalMonad a -> PrimEvalMonad b -> PrimEvalMonad a
    Applicative, Applicative PrimEvalMonad
    Applicative PrimEvalMonad
    -> (forall a b.
        PrimEvalMonad a -> (a -> PrimEvalMonad b) -> PrimEvalMonad b)
    -> (forall a b.
        PrimEvalMonad a -> PrimEvalMonad b -> PrimEvalMonad b)
    -> (forall a. a -> PrimEvalMonad a)
    -> Monad PrimEvalMonad
    forall a. a -> PrimEvalMonad a
    forall a b. PrimEvalMonad a -> PrimEvalMonad b -> PrimEvalMonad b
    forall a b.
    PrimEvalMonad a -> (a -> PrimEvalMonad b) -> PrimEvalMonad b
    forall (m :: Type -> Type).
    Applicative m
    -> (forall a b. m a -> (a -> m b) -> m b)
    -> (forall a b. m a -> m b -> m b)
    -> (forall a. a -> m a)
    -> Monad m
    $c>>= :: forall a b.
    PrimEvalMonad a -> (a -> PrimEvalMonad b) -> PrimEvalMonad b
    >>= :: forall a b.
    PrimEvalMonad a -> (a -> PrimEvalMonad b) -> PrimEvalMonad b
    $c>> :: forall a b. PrimEvalMonad a -> PrimEvalMonad b -> PrimEvalMonad b
    >> :: forall a b. PrimEvalMonad a -> PrimEvalMonad b -> PrimEvalMonad b
    $creturn :: forall a. a -> PrimEvalMonad a
    return :: forall a. a -> PrimEvalMonad a
    Monad, MonadState Supply)

    instance MonadUnique PrimEvalMonad where
      getUniqueM :: PrimEvalMonad Unique
    getUniqueM = State Supply Unique -> PrimEvalMonad Unique
    forall a. State Supply a -> PrimEvalMonad a
    PEM (State Supply Unique -> PrimEvalMonad Unique)
    -> State Supply Unique -> PrimEvalMonad Unique
    forall a b. (a -> b) -> a -> b
    $ (Supply -> (Unique, Supply)) -> State Supply Unique
    forall a. (Supply -> (a, Supply)) -> StateT Supply Identity a
    forall s (m :: Type -> Type) a.
    MonadState s m =>
    (s -> (a, s)) -> m a
    State.state (\Supply
    s -> case Supply -> (Unique, Supply)
    freshId Supply
    s of (!Unique
    i,!Supply
    s') -> (Unique
    i,Supply
    s'))

    runPEM :: PrimEvalMonad a -> Supply -> (a, Supply)
    runPEM :: forall a. PrimEvalMonad a -> Supply -> (a, Supply)
    runPEM (PEM State Supply a
    m) = State Supply a -> Supply -> (a, Supply)
    forall s a. State s a -> s -> (a, s)
    State.runState State Supply a
    m

    ghcPrimStep :: PrimStep
    ghcPrimStep :: PrimStep
    ghcPrimStep TyConMap
    tcm Bool
    isSubj PrimInfo
    pInfo [Type]
    tys [Value]
    args Machine
    mach = case PrimInfo -> Text
    primName PrimInfo
    pInfo of
    -----------------
    -- GHC.Prim.Char#
    -----------------
      Text
    "GHC.Prim.gtChar#" | Just (Char
    i,Char
    j) <- [Value] -> Maybe (Char, Char)
    charLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Char
    i Char -> Char -> Bool
    forall a. Ord a => a -> a -> Bool
    > Char
    j))
      Text
    "GHC.Prim.geChar#" | Just (Char
    i,Char
    j) <- [Value] -> Maybe (Char, Char)
    charLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Char
    i Char -> Char -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Char
    j))
      Text
    "GHC.Prim.eqChar#" | Just (Char
    i,Char
    j) <- [Value] -> Maybe (Char, Char)
    charLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Char
    i Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == Char
    j))
      Text
    "GHC.Prim.neChar#" | Just (Char
    i,Char
    j) <- [Value] -> Maybe (Char, Char)
    charLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Char
    i Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    /= Char
    j))
      Text
    "GHC.Prim.ltChar#" | Just (Char
    i,Char
    j) <- [Value] -> Maybe (Char, Char)
    charLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Char
    i Char -> Char -> Bool
    forall a. Ord a => a -> a -> Bool
    < Char
    j))
      Text
    "GHC.Prim.leChar#" | Just (Char
    i,Char
    j) <- [Value] -> Maybe (Char, Char)
    charLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Char
    i Char -> Char -> Bool
    forall a. Ord a => a -> a -> Bool
    <= Char
    j))
      Text
    "GHC.Prim.ord#" | [Char
    i] <- [Value] -> [Char]
    charLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntLiteral (Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> Unique -> Integer
    forall a b. (a -> b) -> a -> b
    $ Char -> Unique
    ord Char
    i))

    ----------------
    -- GHC.Prim.Int#
    ----------------
      Text
    "GHC.Prim.+#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntLiteral (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    +Integer
    j))
      Text
    "GHC.Prim.-#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntLiteral (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    j))
      Text
    "GHC.Prim.*#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntLiteral (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    *Integer
    j))

      Text
    "GHC.Prim.mulIntMayOflo#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals  [Value]
    args
        -> let !(I# Int#
    a)  = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               !(I# Int#
    b)  = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
               c :: Int#
               c :: Int#
    c = Int# -> Int# -> Int#
    mulIntMayOflo# Int#
    a Int#
    b
           in  Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntLiteral (Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> Unique -> Integer
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    c))

      Text
    "GHC.Prim.quotInt#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Integer -> Term
    integerToIntLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `quot` Integer
    j))
      Text
    "GHC.Prim.remInt#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Integer -> Term
    integerToIntLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `rem` Integer
    j))
      Text
    "GHC.Prim.quotRemInt#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               (Integer
    q,Integer
    r)   = Integer -> Integer -> (Integer, Integer)
    forall a. Integral a => a -> a -> (a, a)
    quotRem Integer
    i Integer
    j
               ret :: Term
    ret     = Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                        [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Either Term Type) -> Term -> Either Term Type
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Integer -> Term
    integerToIntLiteral Integer
    q)
                        ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Either Term Type) -> Term -> Either Term Type
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Integer -> Term
    integerToIntLiteral Integer
    r)])
           in  Term -> Maybe Machine
    reduce Term
    ret

      Text
    "GHC.Prim.andI#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .&. Integer
    j))
      Text
    "GHC.Prim.orI#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .|. Integer
    j))
      Text
    "GHC.Prim.xorI#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    `xor` Integer
    j))
      Text
    "GHC.Prim.notI#" | [Integer
    i] <- [Value] -> [Integer]
    intLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntLiteral (Integer -> Integer
    forall a. Bits a => a -> a
    complement Integer
    i))

      Text
    "GHC.Prim.negateInt#"
        | [Lit (IntLiteral Integer
    i)] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntLiteral (Integer -> Integer
    forall a. Num a => a -> a
    negate Integer
    i))

      Text
    "GHC.Prim.addIntC#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               !(I# Int#
    a)  = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               !(I# Int#
    b)  = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
               !(# Int#
    d, Int#
    c #) = Int# -> Int# -> (# Int#, Int# #)
    addIntC# Int#
    a Int#
    b
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                       [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Term) -> Unique -> Term
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    d)
                       , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Term) -> Unique -> Term
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    c)])
      Text
    "GHC.Prim.subIntC#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               !(I# Int#
    a)  = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               !(I# Int#
    b)  = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
               !(# Int#
    d, Int#
    c #) = Int# -> Int# -> (# Int#, Int# #)
    subIntC# Int#
    a Int#
    b
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                       [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Term) -> Unique -> Term
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    d)
                       , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Term) -> Unique -> Term
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    c)])

      Text
    "GHC.Prim.>#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    > Integer
    j))
      Text
    "GHC.Prim.>=#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Integer
    j))
      Text
    "GHC.Prim.==#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    j))
      Text
    "GHC.Prim./=#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    /= Integer
    j))
      Text
    "GHC.Prim.<#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    < Integer
    j))
      Text
    "GHC.Prim.<=#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <= Integer
    j))

      Text
    "GHC.Prim.chr#" | [Integer
    i] <- [Value] -> [Integer]
    intLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Char -> Term
    charToCharLiteral (Unique -> Char
    chr (Unique -> Char) -> Unique -> Char
    forall a b. (a -> b) -> a -> b
    $ Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i))

      Text
    "GHC.Prim.int2Word#"
        | [Lit (IntLiteral Integer
    i)] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> (Word -> Term) -> Word -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Word -> Literal) -> Word -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    WordLiteral (Integer -> Literal) -> (Word -> Integer) -> Word -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Maybe Machine) -> Word -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ (Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word) Integer
    i -- for overflow behavior

      Text
    "GHC.Prim.int2Float#"
        | [Lit (IntLiteral Integer
    i)] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Float -> Term) -> Float -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Float -> Literal) -> Float -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word32 -> Literal
    FloatLiteral  (Word32 -> Literal) -> (Float -> Word32) -> Float -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Float -> Word32
    floatToWord (Float -> Maybe Machine) -> Float -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer -> Float
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
      Text
    "GHC.Prim.int2Double#"
        | [Lit (IntLiteral Integer
    i)] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Double -> Term) -> Double -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Double -> Literal) -> Double -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Literal
    DoubleLiteral (Word64 -> Literal) -> (Double -> Word64) -> Double -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Double -> Word64
    doubleToWord (Double -> Maybe Machine) -> Double -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer -> Double
    forall a. Num a => Integer -> a
    fromInteger Integer
    i

      Text
    "GHC.Prim.word2Float#"
        | [Lit (WordLiteral Integer
    i)] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Float -> Term) -> Float -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Float -> Literal) -> Float -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word32 -> Literal
    FloatLiteral  (Word32 -> Literal) -> (Float -> Word32) -> Float -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Float -> Word32
    floatToWord (Float -> Maybe Machine) -> Float -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer -> Float
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
      Text
    "GHC.Prim.word2Double#"
        | [Lit (WordLiteral Integer
    i)] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Double -> Term) -> Double -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Double -> Literal) -> Double -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Literal
    DoubleLiteral (Word64 -> Literal) -> (Double -> Word64) -> Double -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Double -> Word64
    doubleToWord (Double -> Maybe Machine) -> Double -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer -> Double
    forall a. Num a => Integer -> a
    fromInteger Integer
    i

      Text
    "GHC.Prim.uncheckedIShiftL#"
        | [ Lit (IntLiteral Integer
    i)
          , Lit (IntLiteral Integer
    s)
          ] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntLiteral (Integer
    i Integer -> Unique -> Integer
    forall a. Bits a => a -> Unique -> a
    `shiftL` Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    s))
      Text
    "GHC.Prim.uncheckedIShiftRA#"
        | [ Lit (IntLiteral Integer
    i)
          , Lit (IntLiteral Integer
    s)
          ] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntLiteral (Integer
    i Integer -> Unique -> Integer
    forall a. Bits a => a -> Unique -> a
    `shiftR` Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    s))
      Text
    "GHC.Prim.uncheckedIShiftRL#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> let !(I# Int#
    a)  = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               !(I# Int#
    b)  = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
               c :: Int#
               c :: Int#
    c = Int# -> Int# -> Int#
    uncheckedIShiftRL# Int#
    a Int#
    b
           in  Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntLiteral (Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> Unique -> Integer
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    c))

    -----------------
    -- GHC.Prim.Word#
    -----------------
      Text
    "GHC.Prim.plusWord#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToWordLiteral (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    +Integer
    j))

      Text
    "GHC.Prim.subWordC#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               !(W# Word#
    a)  = Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               !(W# Word#
    b)  = Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
               !(# Word#
    d, Int#
    c #) = Word# -> Word# -> (# Word#, Int# #)
    subWordC# Word#
    a Word#
    b
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                       [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Word -> Literal) -> Word -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    WordLiteral (Integer -> Literal) -> (Word -> Integer) -> Word -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Term) -> Word -> Term
    forall a b. (a -> b) -> a -> b
    $ Word# -> Word
    W# Word#
    d)
                       , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Term) -> Unique -> Term
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    c)])

      Text
    "GHC.Prim.plusWord2#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               !(W# Word#
    a)  = Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               !(W# Word#
    b)  = Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
               !(# Word#
    h', Word#
    l #) = Word# -> Word# -> (# Word#, Word# #)
    plusWord2# Word#
    a Word#
    b
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                       [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Word -> Literal) -> Word -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    WordLiteral (Integer -> Literal) -> (Word -> Integer) -> Word -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Term) -> Word -> Term
    forall a b. (a -> b) -> a -> b
    $ Word# -> Word
    W# Word#
    h')
                       , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Word -> Literal) -> Word -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    WordLiteral (Integer -> Literal) -> (Word -> Integer) -> Word -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Term) -> Word -> Term
    forall a b. (a -> b) -> a -> b
    $ Word# -> Word
    W# Word#
    l)])

      Text
    "GHC.Prim.minusWord#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToWordLiteral (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    j))
      Text
    "GHC.Prim.timesWord#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToWordLiteral (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    *Integer
    j))

      Text
    "GHC.Prim.timesWord2#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               !(W# Word#
    a)  = Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               !(W# Word#
    b)  = Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
               !(# Word#
    h', Word#
    l #) = Word# -> Word# -> (# Word#, Word# #)
    timesWord2# Word#
    a Word#
    b
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                       [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Word -> Literal) -> Word -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    WordLiteral (Integer -> Literal) -> (Word -> Integer) -> Word -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Term) -> Word -> Term
    forall a b. (a -> b) -> a -> b
    $ Word# -> Word
    W# Word#
    h')
                       , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Word -> Literal) -> Word -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    WordLiteral (Integer -> Literal) -> (Word -> Integer) -> Word -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Term) -> Word -> Term
    forall a b. (a -> b) -> a -> b
    $ Word# -> Word
    W# Word#
    l)])

      Text
    "GHC.Prim.quotWord#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Integer -> Term
    integerToWordLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `quot` Integer
    j))
      Text
    "GHC.Prim.remWord#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Integer -> Term
    integerToWordLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `rem` Integer
    j))
      Text
    "GHC.Prim.quotRemWord#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               (Integer
    q,Integer
    r)   = Integer -> Integer -> (Integer, Integer)
    forall a. Integral a => a -> a -> (a, a)
    quotRem Integer
    i Integer
    j
               ret :: Term
    ret     = Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                        [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Either Term Type) -> Term -> Either Term Type
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Integer -> Term
    integerToWordLiteral Integer
    q)
                        ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Either Term Type) -> Term -> Either Term Type
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Integer -> Term
    integerToWordLiteral Integer
    r)])
           in  Term -> Maybe Machine
    reduce Term
    ret
      Text
    "GHC.Prim.quotRemWord2#" | [Integer
    i,Integer
    j,Integer
    k'] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               !(W# Word#
    a)  = Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               !(W# Word#
    b)  = Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
               !(W# Word#
    c)  = Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    k'
               !(# Word#
    x, Word#
    y #) = Word# -> Word# -> Word# -> (# Word#, Word# #)
    quotRemWord2# Word#
    a Word#
    b Word#
    c
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                       [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Either Term Type) -> Term -> Either Term Type
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Literal -> Term
    Literal (Literal -> Term) -> (Word -> Literal) -> Word -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    WordLiteral (Integer -> Literal) -> (Word -> Integer) -> Word -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Term) -> Word -> Term
    forall a b. (a -> b) -> a -> b
    $ Word# -> Word
    W# Word#
    x)
                       , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Either Term Type) -> Term -> Either Term Type
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Literal -> Term
    Literal (Literal -> Term) -> (Word -> Literal) -> Word -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    WordLiteral (Integer -> Literal) -> (Word -> Integer) -> Word -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Term) -> Word -> Term
    forall a b. (a -> b) -> a -> b
    $ Word# -> Word
    W# Word#
    y)])

      Text
    "GHC.Prim.and#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToWordLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .&. Integer
    j))
      Text
    "GHC.Prim.or#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToWordLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .|. Integer
    j))
      Text
    "GHC.Prim.xor#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToWordLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    `xor` Integer
    j))
      Text
    "GHC.Prim.not#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToWordLiteral (Integer -> Integer
    forall a. Bits a => a -> a
    complement Integer
    i))

      Text
    "GHC.Prim.uncheckedShiftL#"
        | [ Lit (WordLiteral Integer
    w)
          , Lit (IntLiteral  Integer
    i)
          ] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    WordLiteral (Integer
    w Integer -> Unique -> Integer
    forall a. Bits a => a -> Unique -> a
    `shiftL` Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i)))
      Text
    "GHC.Prim.uncheckedShiftRL#"
        | [ Lit (WordLiteral Integer
    w)
          , Lit (IntLiteral  Integer
    i)
          ] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    WordLiteral (Integer
    w Integer -> Unique -> Integer
    forall a. Bits a => a -> Unique -> a
    `shiftR` Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i)))

      Text
    "GHC.Prim.word2Int#"
        | [Lit (WordLiteral Integer
    i)] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Unique -> Term) -> Unique -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Maybe Machine) -> Unique -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Int) Integer
    i -- for overflow behavior

      Text
    "GHC.Prim.gtWord#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    > Integer
    j))
      Text
    "GHC.Prim.geWord#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Integer
    j))
      Text
    "GHC.Prim.eqWord#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    j))
      Text
    "GHC.Prim.neWord#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    /= Integer
    j))
      Text
    "GHC.Prim.ltWord#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    < Integer
    j))
      Text
    "GHC.Prim.leWord#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    wordLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <= Integer
    j))

      Text
    "GHC.Prim.popCnt8#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (Integer -> Unique) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word8 -> Unique
    forall a. Bits a => a -> Unique
    popCount (Word8 -> Unique) -> (Integer -> Word8) -> Integer -> Unique
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word8
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word8) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i
      Text
    "GHC.Prim.popCnt16#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (Integer -> Unique) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word16 -> Unique
    forall a. Bits a => a -> Unique
    popCount (Word16 -> Unique) -> (Integer -> Word16) -> Integer -> Unique
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word16
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word16) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i
      Text
    "GHC.Prim.popCnt32#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (Integer -> Unique) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word32 -> Unique
    forall a. Bits a => a -> Unique
    popCount (Word32 -> Unique) -> (Integer -> Word32) -> Integer -> Unique
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word32
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word32) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i
      Text
    "GHC.Prim.popCnt64#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (Integer -> Unique) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Unique
    forall a. Bits a => a -> Unique
    popCount (Word64 -> Unique) -> (Integer -> Word64) -> Integer -> Unique
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word64) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i
      Text
    "GHC.Prim.popCnt#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (Integer -> Unique) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Unique
    forall a. Bits a => a -> Unique
    popCount (Word -> Unique) -> (Integer -> Word) -> Integer -> Unique
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i

      Text
    "GHC.Prim.clz8#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (Integer -> Unique) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word8 -> Unique
    forall b. FiniteBits b => b -> Unique
    countLeadingZeros (Word8 -> Unique) -> (Integer -> Word8) -> Integer -> Unique
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word8
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word8) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i
      Text
    "GHC.Prim.clz16#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (Integer -> Unique) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word16 -> Unique
    forall b. FiniteBits b => b -> Unique
    countLeadingZeros (Word16 -> Unique) -> (Integer -> Word16) -> Integer -> Unique
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word16
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word16) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i
      Text
    "GHC.Prim.clz32#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (Integer -> Unique) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word32 -> Unique
    forall b. FiniteBits b => b -> Unique
    countLeadingZeros (Word32 -> Unique) -> (Integer -> Word32) -> Integer -> Unique
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word32
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word32) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i
      Text
    "GHC.Prim.clz64#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (Integer -> Unique) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Unique
    forall b. FiniteBits b => b -> Unique
    countLeadingZeros (Word64 -> Unique) -> (Integer -> Word64) -> Integer -> Unique
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word64) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i
      Text
    "GHC.Prim.clz#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (Integer -> Unique) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Unique
    forall b. FiniteBits b => b -> Unique
    countLeadingZeros (Word -> Unique) -> (Integer -> Word) -> Integer -> Unique
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i

      Text
    "GHC.Prim.ctz8#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (Integer -> Unique) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Unique
    forall b. FiniteBits b => b -> Unique
    countTrailingZeros (Word -> Unique) -> (Integer -> Word) -> Integer -> Unique
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .&. (Unique -> Integer
    forall a. Bits a => Unique -> a
    bit Unique
    8 Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1)
      Text
    "GHC.Prim.ctz16#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (Integer -> Unique) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Unique
    forall b. FiniteBits b => b -> Unique
    countTrailingZeros (Word -> Unique) -> (Integer -> Word) -> Integer -> Unique
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .&. (Unique -> Integer
    forall a. Bits a => Unique -> a
    bit Unique
    16 Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1)
      Text
    "GHC.Prim.ctz32#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (Integer -> Unique) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Unique
    forall b. FiniteBits b => b -> Unique
    countTrailingZeros (Word -> Unique) -> (Integer -> Word) -> Integer -> Unique
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .&. (Unique -> Integer
    forall a. Bits a => Unique -> a
    bit Unique
    32 Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1)
      Text
    "GHC.Prim.ctz64#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (Integer -> Unique) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Unique
    forall b. FiniteBits b => b -> Unique
    countTrailingZeros (Word64 -> Unique) -> (Integer -> Word64) -> Integer -> Unique
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word64) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .&. (Unique -> Integer
    forall a. Bits a => Unique -> a
    bit Unique
    64 Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1)
      Text
    "GHC.Prim.ctz#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (Integer -> Unique) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Unique
    forall b. FiniteBits b => b -> Unique
    countTrailingZeros (Word -> Unique) -> (Integer -> Word) -> Integer -> Unique
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i

      Text
    "GHC.Prim.byteSwap16#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word16 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word16 -> Integer) -> (Integer -> Word16) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word16 -> Word16
    byteSwap16 (Word16 -> Word16) -> (Integer -> Word16) -> Integer -> Word16
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word16
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word16) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i
      Text
    "GHC.Prim.byteSwap32#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word32 -> Integer) -> (Integer -> Word32) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word32 -> Word32
    byteSwap32 (Word32 -> Word32) -> (Integer -> Word32) -> Integer -> Word32
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word32
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word32) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i
      Text
    "GHC.Prim.byteSwap64#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word64 -> Integer) -> (Integer -> Word64) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Word64
    byteSwap64 (Word64 -> Word64) -> (Integer -> Word64) -> Integer -> Word64
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word64) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i
      Text
    "GHC.Prim.byteSwap#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args -- assume 64bits
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word64 -> Integer) -> (Integer -> Word64) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Word64
    byteSwap64 (Word64 -> Word64) -> (Integer -> Word64) -> Integer -> Word64
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word64) (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i

    #if MIN_VERSION_base(4,14,0)
      Text
    "GHC.Prim.bitReverse#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word64 -> Integer) -> (Integer -> Word64) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Word64
    bitReverse64 (Word64 -> Word64) -> (Integer -> Word64) -> Integer -> Word64
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i -- assume 64bits
      Text
    "GHC.Prim.bitReverse8#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word8 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word8 -> Integer) -> (Integer -> Word8) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word8 -> Word8
    bitReverse8 (Word8 -> Word8) -> (Integer -> Word8) -> Integer -> Word8
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Word8
    forall a. Num a => Integer -> a
    fromInteger (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i
      Text
    "GHC.Prim.bitReverse16#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word16 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word16 -> Integer) -> (Integer -> Word16) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word16 -> Word16
    bitReverse16 (Word16 -> Word16) -> (Integer -> Word16) -> Integer -> Word16
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Word16
    forall a. Num a => Integer -> a
    fromInteger (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i
      Text
    "GHC.Prim.bitReverse32#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word32 -> Integer) -> (Integer -> Word32) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word32 -> Word32
    bitReverse32 (Word32 -> Word32) -> (Integer -> Word32) -> Integer -> Word32
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Word32
    forall a. Num a => Integer -> a
    fromInteger (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i
      Text
    "GHC.Prim.bitReverse64#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Integer -> Term) -> Integer -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Term
    integerToWordLiteral (Integer -> Term) -> (Integer -> Integer) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word64 -> Integer) -> (Integer -> Word64) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Word64
    bitReverse64 (Word64 -> Word64) -> (Integer -> Word64) -> Integer -> Word64
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger (Integer -> Maybe Machine) -> Integer -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer
    i
    #endif
    ------------
    -- Narrowing
    ------------
      Text
    "GHC.Prim.narrow8Int#" | [Integer
    i] <- [Value] -> [Integer]
    intLiterals' [Value]
    args
        -> let !(I# Int#
    a)  = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               b :: Int#
    b = Int# -> Int#
    narrow8Int# Int#
    a
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Unique -> Term) -> Unique -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Maybe Machine) -> Unique -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    b
      Text
    "GHC.Prim.narrow16Int#" | [Integer
    i] <- [Value] -> [Integer]
    intLiterals' [Value]
    args
        -> let !(I# Int#
    a)  = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               b :: Int#
    b = Int# -> Int#
    narrow16Int# Int#
    a
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Unique -> Term) -> Unique -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Maybe Machine) -> Unique -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    b
      Text
    "GHC.Prim.narrow32Int#" | [Integer
    i] <- [Value] -> [Integer]
    intLiterals' [Value]
    args
        -> let !(I# Int#
    a)  = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               b :: Int#
    b = Int# -> Int#
    narrow32Int# Int#
    a
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Unique -> Term) -> Unique -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Maybe Machine) -> Unique -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    b
      Text
    "GHC.Prim.narrow8Word#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> let !(W# Word#
    a)  = Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               b :: Word#
    b = Word# -> Word#
    narrow8Word# Word#
    a
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> (Word -> Term) -> Word -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Word -> Literal) -> Word -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    WordLiteral (Integer -> Literal) -> (Word -> Integer) -> Word -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Maybe Machine) -> Word -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Word# -> Word
    W# Word#
    b
      Text
    "GHC.Prim.narrow16Word#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> let !(W# Word#
    a)  = Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               b :: Word#
    b = Word# -> Word#
    narrow16Word# Word#
    a
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> (Word -> Term) -> Word -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Word -> Literal) -> Word -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    WordLiteral (Integer -> Literal) -> (Word -> Integer) -> Word -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Maybe Machine) -> Word -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Word# -> Word
    W# Word#
    b
      Text
    "GHC.Prim.narrow32Word#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> let !(W# Word#
    a)  = Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               b :: Word#
    b = Word# -> Word#
    narrow32Word# Word#
    a
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> (Word -> Term) -> Word -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Word -> Literal) -> Word -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    WordLiteral (Integer -> Literal) -> (Word -> Integer) -> Word -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Maybe Machine) -> Word -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Word# -> Word
    W# Word#
    b

    #if MIN_VERSION_base(4,16,0)
    --------
    -- Int8#
    --------
      Text
    "GHC.Prim.intToInt8#" | [Integer
    i] <- [Value] -> [Integer]
    intLiterals' [Value]
    args
        -> let !(I# Int#
    a)  = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               b :: Int#
    b = Int# -> Int#
    narrow8Int# Int#
    a
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Unique -> Term) -> Unique -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    Int8Literal (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Maybe Machine) -> Unique -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    b
      Text
    "GHC.Prim.int8ToInt#" | [Integer
    i] <- [Value] -> [Integer]
    int8Literals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Literal -> Term) -> Literal -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Maybe Machine) -> Literal -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer -> Literal
    IntLiteral Integer
    i
      Text
    "GHC.Prim.negateInt8" | [Integer
    i] <- [Value] -> [Integer]
    int8Literals' [Value]
    args
        -> let !(I8# Int8#
    a) = Integer -> Int8
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            in Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Int8Literal (Int8 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int8# -> Int8
    I8# (Int8# -> Int8#
    negateInt8# Int8#
    a)))))
      Text
    "GHC.Prim.plusInt8#" | Just Term
    r <- (Int8# -> Int8# -> Int8#) -> [Value] -> Maybe Term
    liftI8 Int8# -> Int8# -> Int8#
    plusInt8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.subInt8#" | Just Term
    r <- (Int8# -> Int8# -> Int8#) -> [Value] -> Maybe Term
    liftI8 Int8# -> Int8# -> Int8#
    subInt8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.timesInt8#" | Just Term
    r <- (Int8# -> Int8# -> Int8#) -> [Value] -> Maybe Term
    liftI8 Int8# -> Int8# -> Int8#
    timesInt8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.quotInt8#" | Just Term
    r <- (Int8# -> Int8# -> Int8#) -> [Value] -> Maybe Term
    liftI8 Int8# -> Int8# -> Int8#
    quotInt8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.remInt8#" | Just Term
    r <- (Int8# -> Int8# -> Int8#) -> [Value] -> Maybe Term
    liftI8 Int8# -> Int8# -> Int8#
    remInt8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.quotRemInt8#"
        | [Integer
    i, Integer
    j] <- [Value] -> [Integer]
    int8Literals' [Value]
    args
        , ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
        , (Just TyCon
    tupTc) <- TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
        , [DataCon
    tupDc] <- TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
        -> let !(I8# Int8#
    a)    = Integer -> Int8
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               !(I8# Int8#
    b)    = Integer -> Int8
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
               !(# Int8#
    q, Int8#
    r #) = Int8# -> Int8# -> (# Int8#, Int8# #)
    quotRemInt8# Int8#
    a Int8#
    b
            in Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                      [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Int8Literal (Int8 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int8# -> Int8
    I8# Int8#
    q))))
                      , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Int8Literal (Int8 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int8# -> Int8
    I8# Int8#
    r))))])
      Text
    "GHC.Prim.uncheckedShiftLInt8#" | Just Term
    r <- (Int8# -> Int# -> Int8#) -> [Value] -> Maybe Term
    liftI8I Int8# -> Int# -> Int8#
    uncheckedShiftLInt8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.uncheckedShiftRAInt8#" | Just Term
    r <- (Int8# -> Int# -> Int8#) -> [Value] -> Maybe Term
    liftI8I Int8# -> Int# -> Int8#
    uncheckedShiftRAInt8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.uncheckedShiftRLInt8#" | Just Term
    r <- (Int8# -> Int# -> Int8#) -> [Value] -> Maybe Term
    liftI8I Int8# -> Int# -> Int8#
    uncheckedShiftRLInt8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.int8ToWord8#" | [Integer
    i] <- [Value] -> [Integer]
    int8Literals' [Value]
    args
        -> let !(I8# Int8#
    a) = Integer -> Int8
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            in Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Word8Literal (Word8 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word8# -> Word8
    W8# (Int8# -> Word8#
    int8ToWord8# Int8#
    a)))))
      Text
    "GHC.Prim.eqInt8#" | Just Term
    r <- (Int8# -> Int8# -> Int#) -> [Value] -> Maybe Term
    liftI8RI Int8# -> Int8# -> Int#
    eqInt8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.geInt8#" | Just Term
    r <- (Int8# -> Int8# -> Int#) -> [Value] -> Maybe Term
    liftI8RI Int8# -> Int8# -> Int#
    geInt8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.gtInt8#" | Just Term
    r <- (Int8# -> Int8# -> Int#) -> [Value] -> Maybe Term
    liftI8RI Int8# -> Int8# -> Int#
    gtInt8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.leInt8#" | Just Term
    r <- (Int8# -> Int8# -> Int#) -> [Value] -> Maybe Term
    liftI8RI Int8# -> Int8# -> Int#
    leInt8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.ltInt8#" | Just Term
    r <- (Int8# -> Int8# -> Int#) -> [Value] -> Maybe Term
    liftI8RI Int8# -> Int8# -> Int#
    ltInt8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.neInt8#" | Just Term
    r <- (Int8# -> Int8# -> Int#) -> [Value] -> Maybe Term
    liftI8RI Int8# -> Int8# -> Int#
    neInt8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r

    ---------
    -- Int16#
    ---------
      Text
    "GHC.Prim.intToInt16#" | [Integer
    i] <- [Value] -> [Integer]
    intLiterals' [Value]
    args
        -> let !(I# Int#
    a)  = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               b :: Int#
    b = Int# -> Int#
    narrow16Int# Int#
    a
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Unique -> Term) -> Unique -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    Int16Literal (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Maybe Machine) -> Unique -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    b
      Text
    "GHC.Prim.int16ToInt#" | [Integer
    i] <- [Value] -> [Integer]
    int16Literals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Literal -> Term) -> Literal -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Maybe Machine) -> Literal -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer -> Literal
    IntLiteral Integer
    i
      Text
    "GHC.Prim.negateInt16" | [Integer
    i] <- [Value] -> [Integer]
    int16Literals' [Value]
    args
        -> let !(I16# Int16#
    a) = Integer -> Int16
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            in Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Int16Literal (Int16 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int16# -> Int16
    I16# (Int16# -> Int16#
    negateInt16# Int16#
    a)))))
      Text
    "GHC.Prim.plusInt16#" | Just Term
    r <- (Int16# -> Int16# -> Int16#) -> [Value] -> Maybe Term
    liftI16 Int16# -> Int16# -> Int16#
    plusInt16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.subInt16#" | Just Term
    r <- (Int16# -> Int16# -> Int16#) -> [Value] -> Maybe Term
    liftI16 Int16# -> Int16# -> Int16#
    subInt16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.timesInt16#" | Just Term
    r <- (Int16# -> Int16# -> Int16#) -> [Value] -> Maybe Term
    liftI16 Int16# -> Int16# -> Int16#
    timesInt16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.quotInt16#" | Just Term
    r <- (Int16# -> Int16# -> Int16#) -> [Value] -> Maybe Term
    liftI16 Int16# -> Int16# -> Int16#
    quotInt16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.remInt16#" | Just Term
    r <- (Int16# -> Int16# -> Int16#) -> [Value] -> Maybe Term
    liftI16 Int16# -> Int16# -> Int16#
    remInt16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.quotRemInt16#"
        | [Integer
    i, Integer
    j] <- [Value] -> [Integer]
    int16Literals' [Value]
    args
        , ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
        , (Just TyCon
    tupTc) <- TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
        , [DataCon
    tupDc] <- TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
        -> let !(I16# Int16#
    a)   = Integer -> Int16
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               !(I16# Int16#
    b)   = Integer -> Int16
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
               !(# Int16#
    q, Int16#
    r #) = Int16# -> Int16# -> (# Int16#, Int16# #)
    quotRemInt16# Int16#
    a Int16#
    b
            in Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                      [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Int16Literal (Int16 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int16# -> Int16
    I16# Int16#
    q))))
                      , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Int16Literal (Int16 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int16# -> Int16
    I16# Int16#
    r))))])
      Text
    "GHC.Prim.uncheckedShiftLInt16#" | Just Term
    r <- (Int16# -> Int# -> Int16#) -> [Value] -> Maybe Term
    liftI16I Int16# -> Int# -> Int16#
    uncheckedShiftLInt16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.uncheckedShiftRAInt16#" | Just Term
    r <- (Int16# -> Int# -> Int16#) -> [Value] -> Maybe Term
    liftI16I Int16# -> Int# -> Int16#
    uncheckedShiftRAInt16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.uncheckedShiftRLInt16#" | Just Term
    r <- (Int16# -> Int# -> Int16#) -> [Value] -> Maybe Term
    liftI16I Int16# -> Int# -> Int16#
    uncheckedShiftRLInt16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.int16ToWord16#" | [Integer
    i] <- [Value] -> [Integer]
    int16Literals' [Value]
    args
        -> let !(I16# Int16#
    a) = Integer -> Int16
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            in Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Word16Literal (Word16 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word16# -> Word16
    W16# (Int16# -> Word16#
    int16ToWord16# Int16#
    a)))))
      Text
    "GHC.Prim.eqInt16#" | Just Term
    r <- (Int16# -> Int16# -> Int#) -> [Value] -> Maybe Term
    liftI16RI Int16# -> Int16# -> Int#
    eqInt16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.geInt16#" | Just Term
    r <- (Int16# -> Int16# -> Int#) -> [Value] -> Maybe Term
    liftI16RI Int16# -> Int16# -> Int#
    geInt16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.gtInt16#" | Just Term
    r <- (Int16# -> Int16# -> Int#) -> [Value] -> Maybe Term
    liftI16RI Int16# -> Int16# -> Int#
    gtInt16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.leInt16#" | Just Term
    r <- (Int16# -> Int16# -> Int#) -> [Value] -> Maybe Term
    liftI16RI Int16# -> Int16# -> Int#
    leInt16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.ltInt16#" | Just Term
    r <- (Int16# -> Int16# -> Int#) -> [Value] -> Maybe Term
    liftI16RI Int16# -> Int16# -> Int#
    ltInt16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.neInt16#" | Just Term
    r <- (Int16# -> Int16# -> Int#) -> [Value] -> Maybe Term
    liftI16RI Int16# -> Int16# -> Int#
    neInt16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r

    ---------
    -- Int32#
    ---------
      Text
    "GHC.Prim.intToInt32#" | [Integer
    i] <- [Value] -> [Integer]
    intLiterals' [Value]
    args
        -> let !(I# Int#
    a)  = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               b :: Int#
    b = Int# -> Int#
    narrow32Int# Int#
    a
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Unique -> Term) -> Unique -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    Int32Literal (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Maybe Machine) -> Unique -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    b
      Text
    "GHC.Prim.int32ToInt#" | [Integer
    i] <- [Value] -> [Integer]
    int32Literals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Literal -> Term) -> Literal -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Maybe Machine) -> Literal -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer -> Literal
    IntLiteral Integer
    i
      Text
    "GHC.Prim.negateInt32" | [Integer
    i] <- [Value] -> [Integer]
    int32Literals' [Value]
    args
        -> let !(I32# Int32#
    a) = Integer -> Int32
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            in Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Int32Literal (Int32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int32# -> Int32
    I32# (Int32# -> Int32#
    negateInt32# Int32#
    a)))))
      Text
    "GHC.Prim.plusInt32#" | Just Term
    r <- (Int32# -> Int32# -> Int32#) -> [Value] -> Maybe Term
    liftI32 Int32# -> Int32# -> Int32#
    plusInt32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.subInt32#" | Just Term
    r <- (Int32# -> Int32# -> Int32#) -> [Value] -> Maybe Term
    liftI32 Int32# -> Int32# -> Int32#
    subInt32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.timesInt32#" | Just Term
    r <- (Int32# -> Int32# -> Int32#) -> [Value] -> Maybe Term
    liftI32 Int32# -> Int32# -> Int32#
    timesInt32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.quotInt32#" | Just Term
    r <- (Int32# -> Int32# -> Int32#) -> [Value] -> Maybe Term
    liftI32 Int32# -> Int32# -> Int32#
    quotInt32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.remInt32#" | Just Term
    r <- (Int32# -> Int32# -> Int32#) -> [Value] -> Maybe Term
    liftI32 Int32# -> Int32# -> Int32#
    remInt32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.quotRemInt32#"
        | [Integer
    i, Integer
    j] <- [Value] -> [Integer]
    int32Literals' [Value]
    args
        , ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
        , (Just TyCon
    tupTc) <- TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
        , [DataCon
    tupDc] <- TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
        -> let !(I32# Int32#
    a)   = Integer -> Int32
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               !(I32# Int32#
    b)   = Integer -> Int32
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
               !(# Int32#
    q, Int32#
    r #) = Int32# -> Int32# -> (# Int32#, Int32# #)
    quotRemInt32# Int32#
    a Int32#
    b
            in Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                      [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Int32Literal (Int32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int32# -> Int32
    I32# Int32#
    q))))
                      , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Int32Literal (Int32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int32# -> Int32
    I32# Int32#
    r))))])
      Text
    "GHC.Prim.uncheckedShiftLInt32#" | Just Term
    r <- (Int32# -> Int# -> Int32#) -> [Value] -> Maybe Term
    liftI32I Int32# -> Int# -> Int32#
    uncheckedShiftLInt32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.uncheckedShiftRAInt32#" | Just Term
    r <- (Int32# -> Int# -> Int32#) -> [Value] -> Maybe Term
    liftI32I Int32# -> Int# -> Int32#
    uncheckedShiftRAInt32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.uncheckedShiftRLInt32#" | Just Term
    r <- (Int32# -> Int# -> Int32#) -> [Value] -> Maybe Term
    liftI32I Int32# -> Int# -> Int32#
    uncheckedShiftRLInt32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.int32ToWord32#" | [Integer
    i] <- [Value] -> [Integer]
    int32Literals' [Value]
    args
        -> let !(I32# Int32#
    a) = Integer -> Int32
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            in Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Word32Literal (Word32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word32# -> Word32
    W32# (Int32# -> Word32#
    int32ToWord32# Int32#
    a)))))
      Text
    "GHC.Prim.eqInt32#" | Just Term
    r <- (Int32# -> Int32# -> Int#) -> [Value] -> Maybe Term
    liftI32RI Int32# -> Int32# -> Int#
    eqInt32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.geInt32#" | Just Term
    r <- (Int32# -> Int32# -> Int#) -> [Value] -> Maybe Term
    liftI32RI Int32# -> Int32# -> Int#
    geInt32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.gtInt32#" | Just Term
    r <- (Int32# -> Int32# -> Int#) -> [Value] -> Maybe Term
    liftI32RI Int32# -> Int32# -> Int#
    gtInt32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.leInt32#" | Just Term
    r <- (Int32# -> Int32# -> Int#) -> [Value] -> Maybe Term
    liftI32RI Int32# -> Int32# -> Int#
    leInt32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.ltInt32#" | Just Term
    r <- (Int32# -> Int32# -> Int#) -> [Value] -> Maybe Term
    liftI32RI Int32# -> Int32# -> Int#
    ltInt32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.neInt32#" | Just Term
    r <- (Int32# -> Int32# -> Int#) -> [Value] -> Maybe Term
    liftI32RI Int32# -> Int32# -> Int#
    neInt32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r

    ---------
    -- Int64#
    ---------
    #if MIN_VERSION_base(4,17,0)
      Text
    "GHC.Prim.intToInt64#" | [Integer
    i] <- [Value] -> [Integer]
    intLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Int64Literal Integer
    i))
      Text
    "GHC.Prim.int64ToInt#" | [Integer
    i] <- [Value] -> [Integer]
    int64Literals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Literal -> Term) -> Literal -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Maybe Machine) -> Literal -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer -> Literal
    IntLiteral Integer
    i
      Text
    "GHC.Prim.negateInt64" | [Integer
    i] <- [Value] -> [Integer]
    int64Literals' [Value]
    args
        -> let !(I64# Int64#
    a) = Integer -> Int64
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            in Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Int64Literal (Int64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int64# -> Int64
    I64# (Int64# -> Int64#
    negateInt64# Int64#
    a)))))
      Text
    "GHC.Prim.plusInt64#" | Just Term
    r <- (Int64# -> Int64# -> Int64#) -> [Value] -> Maybe Term
    liftI64 Int64# -> Int64# -> Int64#
    plusInt64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.subInt64#" | Just Term
    r <- (Int64# -> Int64# -> Int64#) -> [Value] -> Maybe Term
    liftI64 Int64# -> Int64# -> Int64#
    subInt64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.timesInt64#" | Just Term
    r <- (Int64# -> Int64# -> Int64#) -> [Value] -> Maybe Term
    liftI64 Int64# -> Int64# -> Int64#
    timesInt64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.quotInt64#" | Just Term
    r <- (Int64# -> Int64# -> Int64#) -> [Value] -> Maybe Term
    liftI64 Int64# -> Int64# -> Int64#
    quotInt64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.remInt64#" | Just Term
    r <- (Int64# -> Int64# -> Int64#) -> [Value] -> Maybe Term
    liftI64 Int64# -> Int64# -> Int64#
    remInt64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.uncheckedIShiftL64#" | Just Term
    r <- (Int64# -> Int# -> Int64#) -> [Value] -> Maybe Term
    liftI64I Int64# -> Int# -> Int64#
    uncheckedIShiftL64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.uncheckedIShiftRA64#" | Just Term
    r <- (Int64# -> Int# -> Int64#) -> [Value] -> Maybe Term
    liftI64I Int64# -> Int# -> Int64#
    uncheckedIShiftRA64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.uncheckedIShiftRL64#" | Just Term
    r <- (Int64# -> Int# -> Int64#) -> [Value] -> Maybe Term
    liftI64I Int64# -> Int# -> Int64#
    uncheckedIShiftRL64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.int64ToWord64#" | [Integer
    i] <- [Value] -> [Integer]
    int64Literals' [Value]
    args
        -> let !(I64# Int64#
    a) = Integer -> Int64
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            in Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Word64Literal (Word64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word64# -> Word64
    W64# (Int64# -> Word64#
    int64ToWord64# Int64#
    a)))))
      Text
    "GHC.Prim.eqInt64#" | Just Term
    r <- (Int64# -> Int64# -> Int#) -> [Value] -> Maybe Term
    liftI64RI Int64# -> Int64# -> Int#
    eqInt64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.geInt64#" | Just Term
    r <- (Int64# -> Int64# -> Int#) -> [Value] -> Maybe Term
    liftI64RI Int64# -> Int64# -> Int#
    geInt64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.gtInt64#" | Just Term
    r <- (Int64# -> Int64# -> Int#) -> [Value] -> Maybe Term
    liftI64RI Int64# -> Int64# -> Int#
    gtInt64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.leInt64#" | Just Term
    r <- (Int64# -> Int64# -> Int#) -> [Value] -> Maybe Term
    liftI64RI Int64# -> Int64# -> Int#
    leInt64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.ltInt64#" | Just Term
    r <- (Int64# -> Int64# -> Int#) -> [Value] -> Maybe Term
    liftI64RI Int64# -> Int64# -> Int#
    ltInt64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.neInt64#" | Just Term
    r <- (Int64# -> Int64# -> Int#) -> [Value] -> Maybe Term
    liftI64RI Int64# -> Int64# -> Int#
    neInt64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
    #endif

    ---------
    -- Word8#
    ---------
      Text
    "GHC.Prim.wordToWord8#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> let !(W# Word#
    a)  = Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               b :: Word#
    b = Word# -> Word#
    narrow8Word# Word#
    a
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> (Word -> Term) -> Word -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Word -> Literal) -> Word -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    Word8Literal (Integer -> Literal) -> (Word -> Integer) -> Word -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Maybe Machine) -> Word -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Word# -> Word
    W# Word#
    b
      Text
    "GHC.Prim.word8ToWord#" | [Integer
    i] <- [Value] -> [Integer]
    word8Literals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Literal -> Term) -> Literal -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Maybe Machine) -> Literal -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer -> Literal
    WordLiteral Integer
    i
      Text
    "GHC.Prim.plusWord8#" | Just Term
    r <- (Word8# -> Word8# -> Word8#) -> [Value] -> Maybe Term
    liftW8 Word8# -> Word8# -> Word8#
    plusWord8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.subWord8#" | Just Term
    r <- (Word8# -> Word8# -> Word8#) -> [Value] -> Maybe Term
    liftW8 Word8# -> Word8# -> Word8#
    subWord8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.timesWord8#" | Just Term
    r <- (Word8# -> Word8# -> Word8#) -> [Value] -> Maybe Term
    liftW8 Word8# -> Word8# -> Word8#
    timesWord8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.quotWord8#" | Just Term
    r <- (Word8# -> Word8# -> Word8#) -> [Value] -> Maybe Term
    liftW8 Word8# -> Word8# -> Word8#
    quotWord8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.remWord8#" | Just Term
    r <- (Word8# -> Word8# -> Word8#) -> [Value] -> Maybe Term
    liftW8 Word8# -> Word8# -> Word8#
    remWord8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.quotRemWord8#"
        | [Integer
    i, Integer
    j] <- [Value] -> [Integer]
    word8Literals' [Value]
    args
        , ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
        , (Just TyCon
    tupTc) <- TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
        , [DataCon
    tupDc] <- TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
        -> let !(W8# Word8#
    a)    = Integer -> Word8
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               !(W8# Word8#
    b)    = Integer -> Word8
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
               !(# Word8#
    q, Word8#
    r #) = Word8# -> Word8# -> (# Word8#, Word8# #)
    quotRemWord8# Word8#
    a Word8#
    b
            in Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                      [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Word8Literal (Word8 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word8# -> Word8
    W8# Word8#
    q))))
                      , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Word8Literal (Word8 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word8# -> Word8
    W8# Word8#
    r))))])
      Text
    "GHC.Prim.andWord8#" | Just Term
    r <- (Word8# -> Word8# -> Word8#) -> [Value] -> Maybe Term
    liftW8 Word8# -> Word8# -> Word8#
    andWord8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.orWord8#" | Just Term
    r <- (Word8# -> Word8# -> Word8#) -> [Value] -> Maybe Term
    liftW8 Word8# -> Word8# -> Word8#
    orWord8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.xorWord8#" | Just Term
    r <- (Word8# -> Word8# -> Word8#) -> [Value] -> Maybe Term
    liftW8 Word8# -> Word8# -> Word8#
    xorWord8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.notWord8#" | [Integer
    i] <- [Value] -> [Integer]
    word8Literals' [Value]
    args
        -> let !(W8# Word8#
    a) = Integer -> Word8
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            in Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Word8Literal (Word8 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word8# -> Word8
    W8# (Word8# -> Word8#
    notWord8# Word8#
    a)))))
      Text
    "GHC.Prim.uncheckedShiftLWord8#" | Just Term
    r <- (Word8# -> Int# -> Word8#) -> [Value] -> Maybe Term
    liftW8I Word8# -> Int# -> Word8#
    uncheckedShiftLWord8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.uncheckedShiftRLWord8#" | Just Term
    r <- (Word8# -> Int# -> Word8#) -> [Value] -> Maybe Term
    liftW8I Word8# -> Int# -> Word8#
    uncheckedShiftRLWord8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.word8ToInt8#" | [Integer
    i] <- [Value] -> [Integer]
    word8Literals' [Value]
    args
        -> let !(W8# Word8#
    a) = Integer -> Word8
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            in Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Int8Literal (Int8 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int8# -> Int8
    I8# (Word8# -> Int8#
    word8ToInt8# Word8#
    a)))))
      Text
    "GHC.Prim.eqWord8#" | Just Term
    r <- (Word8# -> Word8# -> Int#) -> [Value] -> Maybe Term
    liftW8RI Word8# -> Word8# -> Int#
    eqWord8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.geWord8#" | Just Term
    r <- (Word8# -> Word8# -> Int#) -> [Value] -> Maybe Term
    liftW8RI Word8# -> Word8# -> Int#
    geWord8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.gtWord8#" | Just Term
    r <- (Word8# -> Word8# -> Int#) -> [Value] -> Maybe Term
    liftW8RI Word8# -> Word8# -> Int#
    gtWord8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.leWord8#" | Just Term
    r <- (Word8# -> Word8# -> Int#) -> [Value] -> Maybe Term
    liftW8RI Word8# -> Word8# -> Int#
    leWord8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.ltWord8#" | Just Term
    r <- (Word8# -> Word8# -> Int#) -> [Value] -> Maybe Term
    liftW8RI Word8# -> Word8# -> Int#
    ltWord8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.neWord8#" | Just Term
    r <- (Word8# -> Word8# -> Int#) -> [Value] -> Maybe Term
    liftW8RI Word8# -> Word8# -> Int#
    neWord8# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r

    ----------
    -- Word16#
    ----------
      Text
    "GHC.Prim.wordToWord16#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> let !(W# Word#
    a)  = Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               b :: Word#
    b = Word# -> Word#
    narrow16Word# Word#
    a
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> (Word -> Term) -> Word -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Word -> Literal) -> Word -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    Word16Literal (Integer -> Literal) -> (Word -> Integer) -> Word -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Maybe Machine) -> Word -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Word# -> Word
    W# Word#
    b
      Text
    "GHC.Prim.word16ToWord#" | [Integer
    i] <- [Value] -> [Integer]
    word16Literals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Literal -> Term) -> Literal -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Maybe Machine) -> Literal -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer -> Literal
    WordLiteral Integer
    i
      Text
    "GHC.Prim.plusWord16#" | Just Term
    r <- (Word16# -> Word16# -> Word16#) -> [Value] -> Maybe Term
    liftW16 Word16# -> Word16# -> Word16#
    plusWord16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.subWord16#" | Just Term
    r <- (Word16# -> Word16# -> Word16#) -> [Value] -> Maybe Term
    liftW16 Word16# -> Word16# -> Word16#
    subWord16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.timesWord16#" | Just Term
    r <- (Word16# -> Word16# -> Word16#) -> [Value] -> Maybe Term
    liftW16 Word16# -> Word16# -> Word16#
    timesWord16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.quotWord16#" | Just Term
    r <- (Word16# -> Word16# -> Word16#) -> [Value] -> Maybe Term
    liftW16 Word16# -> Word16# -> Word16#
    quotWord16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.remWord16#" | Just Term
    r <- (Word16# -> Word16# -> Word16#) -> [Value] -> Maybe Term
    liftW16 Word16# -> Word16# -> Word16#
    remWord16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.quotRemWord16#"
        | [Integer
    i, Integer
    j] <- [Value] -> [Integer]
    word16Literals' [Value]
    args
        , ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
        , (Just TyCon
    tupTc) <- TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
        , [DataCon
    tupDc] <- TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
        -> let !(W16# Word16#
    a)    = Integer -> Word16
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               !(W16# Word16#
    b)    = Integer -> Word16
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
               !(# Word16#
    q, Word16#
    r #) = Word16# -> Word16# -> (# Word16#, Word16# #)
    quotRemWord16# Word16#
    a Word16#
    b
            in Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                      [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Word16Literal (Word16 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word16# -> Word16
    W16# Word16#
    q))))
                      , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Word16Literal (Word16 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word16# -> Word16
    W16# Word16#
    r))))])
      Text
    "GHC.Prim.andWord16#" | Just Term
    r <- (Word16# -> Word16# -> Word16#) -> [Value] -> Maybe Term
    liftW16 Word16# -> Word16# -> Word16#
    andWord16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.orWord16#" | Just Term
    r <- (Word16# -> Word16# -> Word16#) -> [Value] -> Maybe Term
    liftW16 Word16# -> Word16# -> Word16#
    orWord16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.xorWord16#" | Just Term
    r <- (Word16# -> Word16# -> Word16#) -> [Value] -> Maybe Term
    liftW16 Word16# -> Word16# -> Word16#
    xorWord16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.notWord16#" | [Integer
    i] <- [Value] -> [Integer]
    word16Literals' [Value]
    args
        -> let !(W16# Word16#
    a) = Integer -> Word16
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            in Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Word16Literal (Word16 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word16# -> Word16
    W16# (Word16# -> Word16#
    notWord16# Word16#
    a)))))
      Text
    "GHC.Prim.uncheckedShiftLWord16#" | Just Term
    r <- (Word16# -> Int# -> Word16#) -> [Value] -> Maybe Term
    liftW16I Word16# -> Int# -> Word16#
    uncheckedShiftLWord16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.uncheckedShiftRLWord16#" | Just Term
    r <- (Word16# -> Int# -> Word16#) -> [Value] -> Maybe Term
    liftW16I Word16# -> Int# -> Word16#
    uncheckedShiftRLWord16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.word16ToInt16#" | [Integer
    i] <- [Value] -> [Integer]
    word16Literals' [Value]
    args
        -> let !(W16# Word16#
    a) = Integer -> Word16
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            in Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Int16Literal (Int16 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int16# -> Int16
    I16# (Word16# -> Int16#
    word16ToInt16# Word16#
    a)))))
      Text
    "GHC.Prim.eqWord16#" | Just Term
    r <- (Word16# -> Word16# -> Int#) -> [Value] -> Maybe Term
    liftW16RI Word16# -> Word16# -> Int#
    eqWord16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.geWord16#" | Just Term
    r <- (Word16# -> Word16# -> Int#) -> [Value] -> Maybe Term
    liftW16RI Word16# -> Word16# -> Int#
    geWord16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.gtWord16#" | Just Term
    r <- (Word16# -> Word16# -> Int#) -> [Value] -> Maybe Term
    liftW16RI Word16# -> Word16# -> Int#
    gtWord16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.leWord16#" | Just Term
    r <- (Word16# -> Word16# -> Int#) -> [Value] -> Maybe Term
    liftW16RI Word16# -> Word16# -> Int#
    leWord16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.ltWord16#" | Just Term
    r <- (Word16# -> Word16# -> Int#) -> [Value] -> Maybe Term
    liftW16RI Word16# -> Word16# -> Int#
    ltWord16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.neWord16#" | Just Term
    r <- (Word16# -> Word16# -> Int#) -> [Value] -> Maybe Term
    liftW16RI Word16# -> Word16# -> Int#
    neWord16# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r

    ----------
    -- Word32#
    ----------
      Text
    "GHC.Prim.wordToWord32#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> let !(W# Word#
    a)  = Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               b :: Word#
    b = Word# -> Word#
    narrow32Word# Word#
    a
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> (Word -> Term) -> Word -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Word -> Literal) -> Word -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    Word32Literal (Integer -> Literal) -> (Word -> Integer) -> Word -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Maybe Machine) -> Word -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Word# -> Word
    W# Word#
    b
      Text
    "GHC.Prim.word32ToWord#" | [Integer
    i] <- [Value] -> [Integer]
    word32Literals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Literal -> Term) -> Literal -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Maybe Machine) -> Literal -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer -> Literal
    WordLiteral Integer
    i
      Text
    "GHC.Prim.plusWord32#" | Just Term
    r <- (Word32# -> Word32# -> Word32#) -> [Value] -> Maybe Term
    liftW32 Word32# -> Word32# -> Word32#
    plusWord32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.subWord32#" | Just Term
    r <- (Word32# -> Word32# -> Word32#) -> [Value] -> Maybe Term
    liftW32 Word32# -> Word32# -> Word32#
    subWord32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.timesWord32#" | Just Term
    r <- (Word32# -> Word32# -> Word32#) -> [Value] -> Maybe Term
    liftW32 Word32# -> Word32# -> Word32#
    timesWord32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.quotWord32#" | Just Term
    r <- (Word32# -> Word32# -> Word32#) -> [Value] -> Maybe Term
    liftW32 Word32# -> Word32# -> Word32#
    quotWord32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.remWord32#" | Just Term
    r <- (Word32# -> Word32# -> Word32#) -> [Value] -> Maybe Term
    liftW32 Word32# -> Word32# -> Word32#
    remWord32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.quotRemWord32#"
        | [Integer
    i, Integer
    j] <- [Value] -> [Integer]
    word32Literals' [Value]
    args
        , ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
        , (Just TyCon
    tupTc) <- TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
        , [DataCon
    tupDc] <- TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
        -> let !(W32# Word32#
    a)    = Integer -> Word32
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               !(W32# Word32#
    b)    = Integer -> Word32
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
               !(# Word32#
    q, Word32#
    r #) = Word32# -> Word32# -> (# Word32#, Word32# #)
    quotRemWord32# Word32#
    a Word32#
    b
            in Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                      [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Word32Literal (Word32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word32# -> Word32
    W32# Word32#
    q))))
                      , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Word32Literal (Word32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word32# -> Word32
    W32# Word32#
    r))))])
      Text
    "GHC.Prim.andWord32#" | Just Term
    r <- (Word32# -> Word32# -> Word32#) -> [Value] -> Maybe Term
    liftW32 Word32# -> Word32# -> Word32#
    andWord32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.orWord32#" | Just Term
    r <- (Word32# -> Word32# -> Word32#) -> [Value] -> Maybe Term
    liftW32 Word32# -> Word32# -> Word32#
    orWord32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.xorWord32#" | Just Term
    r <- (Word32# -> Word32# -> Word32#) -> [Value] -> Maybe Term
    liftW32 Word32# -> Word32# -> Word32#
    xorWord32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.notWord32#" | [Integer
    i] <- [Value] -> [Integer]
    word32Literals' [Value]
    args
        -> let !(W32# Word32#
    a) = Integer -> Word32
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            in Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Word32Literal (Word32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word32# -> Word32
    W32# (Word32# -> Word32#
    notWord32# Word32#
    a)))))
      Text
    "GHC.Prim.uncheckedShiftLWord32#" | Just Term
    r <- (Word32# -> Int# -> Word32#) -> [Value] -> Maybe Term
    liftW32I Word32# -> Int# -> Word32#
    uncheckedShiftLWord32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.uncheckedShiftRLWord32#" | Just Term
    r <- (Word32# -> Int# -> Word32#) -> [Value] -> Maybe Term
    liftW32I Word32# -> Int# -> Word32#
    uncheckedShiftRLWord32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.word32ToInt32#" | [Integer
    i] <- [Value] -> [Integer]
    word32Literals' [Value]
    args
        -> let !(W32# Word32#
    a) = Integer -> Word32
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            in Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Int32Literal (Int32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int32# -> Int32
    I32# (Word32# -> Int32#
    word32ToInt32# Word32#
    a)))))
      Text
    "GHC.Prim.eqWord32#" | Just Term
    r <- (Word32# -> Word32# -> Int#) -> [Value] -> Maybe Term
    liftW32RI Word32# -> Word32# -> Int#
    eqWord32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.geWord32#" | Just Term
    r <- (Word32# -> Word32# -> Int#) -> [Value] -> Maybe Term
    liftW32RI Word32# -> Word32# -> Int#
    geWord32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.gtWord32#" | Just Term
    r <- (Word32# -> Word32# -> Int#) -> [Value] -> Maybe Term
    liftW32RI Word32# -> Word32# -> Int#
    gtWord32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.leWord32#" | Just Term
    r <- (Word32# -> Word32# -> Int#) -> [Value] -> Maybe Term
    liftW32RI Word32# -> Word32# -> Int#
    leWord32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.ltWord32#" | Just Term
    r <- (Word32# -> Word32# -> Int#) -> [Value] -> Maybe Term
    liftW32RI Word32# -> Word32# -> Int#
    ltWord32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.neWord32#" | Just Term
    r <- (Word32# -> Word32# -> Int#) -> [Value] -> Maybe Term
    liftW32RI Word32# -> Word32# -> Int#
    neWord32# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r

    #if MIN_VERSION_base(4,17,0)
    ----------
    -- Word64#
    ----------
      Text
    "GHC.Prim.wordToWord64#" | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Word64Literal Integer
    i))
      Text
    "GHC.Prim.word64ToWord#" | [Integer
    i] <- [Value] -> [Integer]
    word64Literals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Literal -> Term) -> Literal -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Maybe Machine) -> Literal -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer -> Literal
    WordLiteral Integer
    i
      Text
    "GHC.Prim.plusWord64#" | Just Term
    r <- (Word64# -> Word64# -> Word64#) -> [Value] -> Maybe Term
    liftW64 Word64# -> Word64# -> Word64#
    plusWord64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.subWord64#" | Just Term
    r <- (Word64# -> Word64# -> Word64#) -> [Value] -> Maybe Term
    liftW64 Word64# -> Word64# -> Word64#
    subWord64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.timesWord64#" | Just Term
    r <- (Word64# -> Word64# -> Word64#) -> [Value] -> Maybe Term
    liftW64 Word64# -> Word64# -> Word64#
    timesWord64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.quotWord64#" | Just Term
    r <- (Word64# -> Word64# -> Word64#) -> [Value] -> Maybe Term
    liftW64 Word64# -> Word64# -> Word64#
    quotWord64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.remWord64#" | Just Term
    r <- (Word64# -> Word64# -> Word64#) -> [Value] -> Maybe Term
    liftW64 Word64# -> Word64# -> Word64#
    remWord64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.and64#" | Just Term
    r <- (Word64# -> Word64# -> Word64#) -> [Value] -> Maybe Term
    liftW64 Word64# -> Word64# -> Word64#
    and64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.or64#" | Just Term
    r <- (Word64# -> Word64# -> Word64#) -> [Value] -> Maybe Term
    liftW64 Word64# -> Word64# -> Word64#
    or64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.xor64#" | Just Term
    r <- (Word64# -> Word64# -> Word64#) -> [Value] -> Maybe Term
    liftW64 Word64# -> Word64# -> Word64#
    xor64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.not64#" | [Integer
    i] <- [Value] -> [Integer]
    word64Literals' [Value]
    args
        -> let !(W64# Word64#
    a) = Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            in Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Word64Literal (Word64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word64# -> Word64
    W64# (Word64# -> Word64#
    not64# Word64#
    a)))))
      Text
    "GHC.Prim.uncheckedShiftL64#" | Just Term
    r <- (Word64# -> Int# -> Word64#) -> [Value] -> Maybe Term
    liftW64I Word64# -> Int# -> Word64#
    uncheckedShiftL64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.uncheckedShiftRL64#" | Just Term
    r <- (Word64# -> Int# -> Word64#) -> [Value] -> Maybe Term
    liftW64I Word64# -> Int# -> Word64#
    uncheckedShiftRL64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.word64ToInt64#" | [Integer
    i] <- [Value] -> [Integer]
    word64Literals' [Value]
    args
        -> let !(W64# Word64#
    a) = Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            in Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    Int64Literal (Int64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int64# -> Int64
    I64# (Word64# -> Int64#
    word64ToInt64# Word64#
    a)))))
      Text
    "GHC.Prim.eqWord64#" | Just Term
    r <- (Word64# -> Word64# -> Int#) -> [Value] -> Maybe Term
    liftW64RI Word64# -> Word64# -> Int#
    eqWord64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.geWord64#" | Just Term
    r <- (Word64# -> Word64# -> Int#) -> [Value] -> Maybe Term
    liftW64RI Word64# -> Word64# -> Int#
    geWord64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.gtWord64#" | Just Term
    r <- (Word64# -> Word64# -> Int#) -> [Value] -> Maybe Term
    liftW64RI Word64# -> Word64# -> Int#
    gtWord64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.leWord64#" | Just Term
    r <- (Word64# -> Word64# -> Int#) -> [Value] -> Maybe Term
    liftW64RI Word64# -> Word64# -> Int#
    leWord64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.ltWord64#" | Just Term
    r <- (Word64# -> Word64# -> Int#) -> [Value] -> Maybe Term
    liftW64RI Word64# -> Word64# -> Int#
    ltWord64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.neWord64#" | Just Term
    r <- (Word64# -> Word64# -> Int#) -> [Value] -> Maybe Term
    liftW64RI Word64# -> Word64# -> Int#
    neWord64# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
    #endif
    #endif

    ----------
    -- Double#
    ----------
      Text
    "GHC.Prim.>##"  | Just Term
    r <- (Double# -> Double# -> Int#) -> [Value] -> Maybe Term
    liftDDI Double# -> Double# -> Int#
    (>##)  [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.>=##" | Just Term
    r <- (Double# -> Double# -> Int#) -> [Value] -> Maybe Term
    liftDDI Double# -> Double# -> Int#
    (>=##) [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.==##" | Just Term
    r <- (Double# -> Double# -> Int#) -> [Value] -> Maybe Term
    liftDDI Double# -> Double# -> Int#
    (==##) [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim./=##" | Just Term
    r <- (Double# -> Double# -> Int#) -> [Value] -> Maybe Term
    liftDDI Double# -> Double# -> Int#
    (/=##) [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.<##"  | Just Term
    r <- (Double# -> Double# -> Int#) -> [Value] -> Maybe Term
    liftDDI Double# -> Double# -> Int#
    (<##)  [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.<=##" | Just Term
    r <- (Double# -> Double# -> Int#) -> [Value] -> Maybe Term
    liftDDI Double# -> Double# -> Int#
    (<=##) [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.+##"  | Just Term
    r <- (Double# -> Double# -> Double#) -> [Value] -> Maybe Term
    liftDDD Double# -> Double# -> Double#
    (+##)  [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.-##"  | Just Term
    r <- (Double# -> Double# -> Double#) -> [Value] -> Maybe Term
    liftDDD Double# -> Double# -> Double#
    (-##)  [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.*##"  | Just Term
    r <- (Double# -> Double# -> Double#) -> [Value] -> Maybe Term
    liftDDD Double# -> Double# -> Double#
    (*##)  [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim./##"  | Just Term
    r <- (Double# -> Double# -> Double#) -> [Value] -> Maybe Term
    liftDDD Double# -> Double# -> Double#
    (/##)  [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r

      Text
    "GHC.Prim.negateDouble#" | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    negateDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.fabsDouble#" | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    fabsDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r

      Text
    "GHC.Prim.double2Int#" | [Word64
    i] <- [Value] -> [Word64]
    doubleLiterals' [Value]
    args
        -> let !(D# Double#
    a) = Word64 -> Double
    wordToDouble Word64
    i
               r :: Int#
    r = Double# -> Int#
    double2Int# Double#
    a
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Unique -> Term) -> Unique -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Maybe Machine) -> Unique -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    r
      Text
    "GHC.Prim.double2Float#"
        | [Lit (DoubleLiteral Word64
    d)] <- [Value]
    args
        -> let !(D# Double#
    a) = Word64 -> Double
    wordToDouble Word64
    d
               r :: Float#
    r = Double# -> Float#
    double2Float# Double#
    a
           in Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Float -> Term) -> Float -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Float -> Literal) -> Float -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word32 -> Literal
    FloatLiteral (Word32 -> Literal) -> (Float -> Word32) -> Float -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Float -> Word32
    floatToWord (Float -> Maybe Machine) -> Float -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Float# -> Float
    F# Float#
    r

      Text
    "GHC.Prim.expDouble#" | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    expDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.logDouble#" | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    logDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.sqrtDouble#" | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    sqrtDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.sinDouble#" | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    sinDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.cosDouble#" | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    cosDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.tanDouble#" | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    tanDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.asinDouble#" | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    asinDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.acosDouble#" | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    acosDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.atanDouble#" | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    atanDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.sinhDouble#" | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    sinhDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.coshDouble#" | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    coshDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.tanhDouble#" | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    tanhDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r

    #if MIN_VERSION_ghc(8,7,0)
      Text
    "GHC.Prim.asinhDouble#"  | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    asinhDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.acoshDouble#"  | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    acoshDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.atanhDouble#"  | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    atanhDouble# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
    #endif

      Text
    "GHC.Prim.**##" | Just Term
    r <- (Double# -> Double# -> Double#) -> [Value] -> Maybe Term
    liftDDD Double# -> Double# -> Double#
    (**##) [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
    -- decodeDouble_2Int# :: Double# -> (#Int#, Word#, Word#, Int##)
      Text
    "GHC.Prim.decodeDouble_2Int#" | [Word64
    i] <- [Value] -> [Word64]
    doubleLiterals' [Value]
    args
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               !(D# Double#
    a) = Word64 -> Double
    wordToDouble Word64
    i
               !(# Int#
    p, Word#
    q, Word#
    r, Int#
    s #) = Double# -> (# Int#, Word#, Word#, Int# #)
    decodeDouble_2Int# Double#
    a
           in Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
              Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                       [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral  (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Term) -> Unique -> Term
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    p)
                       , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Word -> Literal) -> Word -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    WordLiteral (Integer -> Literal) -> (Word -> Integer) -> Word -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Term) -> Word -> Term
    forall a b. (a -> b) -> a -> b
    $ Word# -> Word
    W# Word#
    q)
                       , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Word -> Literal) -> Word -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    WordLiteral (Integer -> Literal) -> (Word -> Integer) -> Word -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Term) -> Word -> Term
    forall a b. (a -> b) -> a -> b
    $ Word# -> Word
    W# Word#
    r)
                       , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral  (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Term) -> Unique -> Term
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    s)])
    -- decodeDouble_Int64# :: Double# -> (# Int64#, Int# #)
      Text
    "GHC.Prim.decodeDouble_Int64#" | [Word64
    i] <- [Value] -> [Word64]
    doubleLiterals' [Value]
    args
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               !(D# Double#
    a) = Word64 -> Double
    wordToDouble Word64
    i
               !(# Int64#
    p, Int#
    q #) = Double# -> (# Int64#, Int# #)
    decodeDouble_Int64# Double#
    a
           in Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
              Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
    #if MIN_VERSION_ghc_prim(0,9,0)
                       [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Int64 -> Literal) -> Int64 -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    Int64Literal  (Integer -> Literal) -> (Int64 -> Integer) -> Int64 -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int64 -> Term) -> Int64 -> Term
    forall a b. (a -> b) -> a -> b
    $ Int64# -> Int64
    I64# Int64#
    p)
    #else
                       [ Left (Literal . IntLiteral  . toInteger $ I64# p)
    #endif
                       , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral  (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Term) -> Unique -> Term
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    q)])

    --------
    -- Float
    --------
      Text
    "GHC.Prim.gtFloat#"  | Just Term
    r <- (Float# -> Float# -> Int#) -> [Value] -> Maybe Term
    liftFFI Float# -> Float# -> Int#
    gtFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.geFloat#"  | Just Term
    r <- (Float# -> Float# -> Int#) -> [Value] -> Maybe Term
    liftFFI Float# -> Float# -> Int#
    geFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.eqFloat#"  | Just Term
    r <- (Float# -> Float# -> Int#) -> [Value] -> Maybe Term
    liftFFI Float# -> Float# -> Int#
    eqFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.neFloat#"  | Just Term
    r <- (Float# -> Float# -> Int#) -> [Value] -> Maybe Term
    liftFFI Float# -> Float# -> Int#
    neFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.ltFloat#"  | Just Term
    r <- (Float# -> Float# -> Int#) -> [Value] -> Maybe Term
    liftFFI Float# -> Float# -> Int#
    ltFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.leFloat#"  | Just Term
    r <- (Float# -> Float# -> Int#) -> [Value] -> Maybe Term
    liftFFI Float# -> Float# -> Int#
    leFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r

      Text
    "GHC.Prim.plusFloat#"  | Just Term
    r <- (Float# -> Float# -> Float#) -> [Value] -> Maybe Term
    liftFFF Float# -> Float# -> Float#
    plusFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.minusFloat#"  | Just Term
    r <- (Float# -> Float# -> Float#) -> [Value] -> Maybe Term
    liftFFF Float# -> Float# -> Float#
    minusFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.timesFloat#"  | Just Term
    r <- (Float# -> Float# -> Float#) -> [Value] -> Maybe Term
    liftFFF Float# -> Float# -> Float#
    timesFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.divideFloat#"  | Just Term
    r <- (Float# -> Float# -> Float#) -> [Value] -> Maybe Term
    liftFFF Float# -> Float# -> Float#
    divideFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r

      Text
    "GHC.Prim.negateFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    negateFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.fabsFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    fabsFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r

      Text
    "GHC.Prim.float2Int#" | [Word32
    i] <- [Value] -> [Word32]
    floatLiterals' [Value]
    args
        -> let !(F# Float#
    a) = Word32 -> Float
    wordToFloat Word32
    i
               r :: Int#
    r = Float# -> Int#
    float2Int# Float#
    a
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Unique -> Term) -> Unique -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Maybe Machine) -> Unique -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    r

      Text
    "GHC.Prim.expFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    expFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.logFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    logFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.sqrtFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    sqrtFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.sinFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    sinFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.cosFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    cosFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.tanFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    tanFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.asinFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    asinFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.acosFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    acosFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.atanFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    atanFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.sinhFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    sinhFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.coshFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    coshFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.tanhFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    tanhFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.powerFloat#"  | Just Term
    r <- (Float# -> Float# -> Float#) -> [Value] -> Maybe Term
    liftFFF Float# -> Float# -> Float#
    powerFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r

      -- GHC.Float.asinh  -- XXX: Very fragile
      --  $w$casinh is the Double specialisation of asinh
      --  $w$casinh1 is the Float specialisation of asinh
      Text
    "GHC.Float.$w$casinh" | Just Term
    r <- (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD Double# -> Double#
    go [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
        where go :: Double# -> Double#
    go Double#
    f = case Double -> Double
    forall a. Floating a => a -> a
    asinh (Double# -> Double
    D# Double#
    f) of
                       D# Double#
    f' -> Double#
    f'
      Text
    "GHC.Float.$w$casinh1" | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    go [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
        where go :: Float# -> Float#
    go Float#
    f = case Float -> Float
    forall a. Floating a => a -> a
    asinh (Float# -> Float
    F# Float#
    f) of
                       F# Float#
    f' -> Float#
    f'

    #if MIN_VERSION_ghc(8,7,0)
      Text
    "GHC.Prim.asinhFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    asinhFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.acoshFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    acoshFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
      Text
    "GHC.Prim.atanhFloat#"  | Just Term
    r <- (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF Float# -> Float#
    atanhFloat# [Value]
    args
        -> Term -> Maybe Machine
    reduce Term
    r
    #endif

      Text
    "GHC.Prim.float2Double#" | [Word32
    i] <- [Value] -> [Word32]
    floatLiterals' [Value]
    args
        -> let !(F# Float#
    a) = Word32 -> Float
    wordToFloat Word32
    i
               r :: Double#
    r = Float# -> Double#
    float2Double# Float#
    a
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Double -> Term) -> Double -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Double -> Literal) -> Double -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Literal
    DoubleLiteral (Word64 -> Literal) -> (Double -> Word64) -> Double -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Double -> Word64
    doubleToWord (Double -> Maybe Machine) -> Double -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Double# -> Double
    D# Double#
    r

      Text
    "GHC.Prim.newByteArray#"
        | [Value
    iV,PrimVal PrimInfo
    rwTy [Type]
    _ [Value]
    _] <- [Value]
    args
        , [Integer
    i] <- [Value] -> [Integer]
    intLiterals' [Value
    iV]
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               p :: Unique
    p = Machine -> Unique
    primCount Machine
    mach
               lit :: Term
    lit = Literal -> Term
    Literal (ByteArray -> Literal
    ByteArrayLiteral ([Item ByteArray] -> ByteArray
    forall l. IsList l => [Item l] -> l
    fromList (Integer -> Word8 -> [Word8]
    forall i a. Integral i => i -> a -> [a]
    List.genericReplicate Integer
    i Word8
    0)))
               mbaTy :: Type
    mbaTy = Type -> Type -> Type
    mkFunTy Type
    intPrimTy ([Type] -> Type
    forall a. HasCallStack => [a] -> a
    last [Type]
    tyArgs)
               newE :: Term
    newE = Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                        [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (PrimInfo -> Term
    Prim PrimInfo
    rwTy)
                        ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim (Text
    -> Type -> WorkInfo -> IsMultiPrim -> PrimUnfolding -> PrimInfo
    PrimInfo Text
    "GHC.Prim.MutableByteArray#" Type
    mbaTy WorkInfo
    WorkNever IsMultiPrim
    SingleResult PrimUnfolding
    NoUnfolding))
                                      [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Integer -> Literal) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral (Integer -> Term) -> Integer -> Term
    forall a b. (a -> b) -> a -> b
    $ Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger Unique
    p)])
                        ])
           in Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine)
    -> (Machine -> Machine) -> Machine -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Term -> Machine -> Machine
    setTerm Term
    newE (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Unique -> Term -> Machine -> Machine
    primInsert Unique
    p Term
    lit Machine
    mach

      Text
    "GHC.Prim.setByteArray#"
        | [PrimVal PrimInfo
    _mbaTy [Type]
    _ [Value
    baV]
          ,Value
    offV,Value
    lenV,Value
    cV
          ,PrimVal PrimInfo
    rwTy [Type]
    _ [Value]
    _
          ] <- [Value]
    args
        , [Integer
    ba,Integer
    off,Integer
    len,Integer
    c] <- [Value] -> [Integer]
    intLiterals' [Value
    baV,Value
    offV,Value
    lenV,Value
    cV]
        -> let Just (Literal (ByteArrayLiteral ByteArray
    ba1)) =
                  Unique -> Machine -> Maybe Term
    primLookup (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    ba) Machine
    mach
               !(I# Int#
    off') = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    off
               !(I# Int#
    len') = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    len
               !(I# Int#
    c')   = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    c
               ba2 :: ByteArray
    ba2 = IO ByteArray -> ByteArray
    forall a. IO a -> a
    unsafeDupablePerformIO (IO ByteArray -> ByteArray) -> IO ByteArray -> ByteArray
    forall a b. (a -> b) -> a -> b
    $ do
                      BA.MutableByteArray MutableByteArray# RealWorld
    mba <- ByteArray -> IO (MutableByteArray (PrimState IO))
    forall (m :: Type -> Type).
    PrimMonad m =>
    ByteArray -> m (MutableByteArray (PrimState m))
    BA.unsafeThawByteArray ByteArray
    ba1
                      (State# RealWorld -> State# RealWorld) -> IO ()
    svoid (MutableByteArray# RealWorld
    -> Int# -> Int# -> Int# -> State# RealWorld -> State# RealWorld
    forall d.
    MutableByteArray# d -> Int# -> Int# -> Int# -> State# d -> State# d
    setByteArray# MutableByteArray# RealWorld
    mba Int#
    off' Int#
    len' Int#
    c')
                      MutableByteArray (PrimState IO) -> IO ByteArray
    forall (m :: Type -> Type).
    PrimMonad m =>
    MutableByteArray (PrimState m) -> m ByteArray
    BA.unsafeFreezeByteArray (MutableByteArray# RealWorld -> MutableByteArray RealWorld
    forall s. MutableByteArray# s -> MutableByteArray s
    BA.MutableByteArray MutableByteArray# RealWorld
    mba)
               ba3 :: Term
    ba3 = Literal -> Term
    Literal (ByteArray -> Literal
    ByteArrayLiteral ByteArray
    ba2)
           in Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine)
    -> (Machine -> Machine) -> Machine -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Term -> Machine -> Machine
    setTerm (PrimInfo -> Term
    Prim PrimInfo
    rwTy) (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Unique -> Term -> Machine -> Machine
    primUpdate (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    ba) Term
    ba3 Machine
    mach

      Text
    "GHC.Prim.writeWordArray#"
        | [PrimVal PrimInfo
    _mbaTy [Type]
    _  [Value
    baV]
          ,Value
    iV,Value
    wV
          ,PrimVal PrimInfo
    rwTy [Type]
    _ [Value]
    _
          ] <- [Value]
    args
        , [Integer
    ba,Integer
    i] <- [Value] -> [Integer]
    intLiterals' [Value
    baV,Value
    iV]
        , [Integer
    w] <- [Value] -> [Integer]
    wordLiterals' [Value
    wV]
        -> let Just (Literal (ByteArrayLiteral ByteArray
    ba1)) =
                  Unique -> Machine -> Maybe Term
    primLookup (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    ba) Machine
    mach
               !(I# Int#
    i') = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               !(W# Word#
    w') = Integer -> Word
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral Integer
    w
               ba2 :: ByteArray
    ba2 = IO ByteArray -> ByteArray
    forall a. IO a -> a
    unsafeDupablePerformIO (IO ByteArray -> ByteArray) -> IO ByteArray -> ByteArray
    forall a b. (a -> b) -> a -> b
    $ do
                      BA.MutableByteArray MutableByteArray# RealWorld
    mba <- ByteArray -> IO (MutableByteArray (PrimState IO))
    forall (m :: Type -> Type).
    PrimMonad m =>
    ByteArray -> m (MutableByteArray (PrimState m))
    BA.unsafeThawByteArray ByteArray
    ba1
                      (State# RealWorld -> State# RealWorld) -> IO ()
    svoid (MutableByteArray# RealWorld
    -> Int# -> Word# -> State# RealWorld -> State# RealWorld
    forall d.
    MutableByteArray# d -> Int# -> Word# -> State# d -> State# d
    writeWordArray# MutableByteArray# RealWorld
    mba Int#
    i' Word#
    w')
                      MutableByteArray (PrimState IO) -> IO ByteArray
    forall (m :: Type -> Type).
    PrimMonad m =>
    MutableByteArray (PrimState m) -> m ByteArray
    BA.unsafeFreezeByteArray (MutableByteArray# RealWorld -> MutableByteArray RealWorld
    forall s. MutableByteArray# s -> MutableByteArray s
    BA.MutableByteArray MutableByteArray# RealWorld
    mba)
               ba3 :: Term
    ba3 = Literal -> Term
    Literal (ByteArray -> Literal
    ByteArrayLiteral ByteArray
    ba2)
           in Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine)
    -> (Machine -> Machine) -> Machine -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Term -> Machine -> Machine
    setTerm (PrimInfo -> Term
    Prim PrimInfo
    rwTy) (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Unique -> Term -> Machine -> Machine
    primUpdate (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    ba) Term
    ba3 Machine
    mach

      Text
    "GHC.Prim.unsafeFreezeByteArray#"
        | [PrimVal PrimInfo
    _mbaTy [Type]
    _ [Value
    baV]
          ,PrimVal PrimInfo
    rwTy [Type]
    _ [Value]
    _
          ] <- [Value]
    args
        , [Integer
    ba] <-  [Value] -> [Integer]
    intLiterals' [Value
    baV]
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               Just Term
    ba' = Unique -> Machine -> Maybe Term
    primLookup (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    ba) Machine
    mach
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                          [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (PrimInfo -> Term
    Prim PrimInfo
    rwTy)
                          ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left Term
    ba'])

      Text
    "GHC.Prim.sizeofByteArray#"
        | [Lit (ByteArrayLiteral ByteArray
    ba)] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (ByteArray -> Unique
    BA.sizeofByteArray ByteArray
    ba))))

      Text
    "GHC.Prim.indexWordArray#"
        | [Lit (ByteArrayLiteral (BA.ByteArray ByteArray#
    ba)),Value
    iV] <- [Value]
    args
        , [Integer
    i] <- [Value] -> [Integer]
    intLiterals' [Value
    iV]
        -> let !(I# Int#
    i') = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               !w :: Word#
    w       = ByteArray# -> Int# -> Word#
    indexWordArray# ByteArray#
    ba Int#
    i'
           in  Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    WordLiteral (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word# -> Word
    W# Word#
    w))))

      Text
    "GHC.Prim.getSizeofMutBigNat#"
        | [PrimVal PrimInfo
    _mbaTy [Type]
    _ [Value
    baV]
          ,PrimVal PrimInfo
    rwTy [Type]
    _ [Value]
    _
          ] <- [Value]
    args
        , [Integer
    ba] <- [Value] -> [Integer]
    intLiterals' [Value
    baV]
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               Just (Literal (ByteArrayLiteral ByteArray
    ba')) = Unique -> Machine -> Maybe Term
    primLookup (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    ba) Machine
    mach
               lit :: Term
    lit = Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (ByteArray -> Unique
    BA.sizeofByteArray ByteArray
    ba')))
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                          [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (PrimInfo -> Term
    Prim PrimInfo
    rwTy)
                          ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left Term
    lit])

      Text
    "GHC.Prim.resizeMutableByteArray#"
        | [PrimVal PrimInfo
    mbaTy [Type]
    _ [Value
    baV]
          ,Value
    iV
          ,PrimVal PrimInfo
    rwTy [Type]
    _ [Value]
    _
          ] <- [Value]
    args
        , [Integer
    ba,Integer
    i] <- [Value] -> [Integer]
    intLiterals' [Value
    baV,Value
    iV]
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               p :: Unique
    p = Machine -> Unique
    primCount Machine
    mach
               Just (Literal (ByteArrayLiteral ByteArray
    ba1))
                = Unique -> Machine -> Maybe Term
    primLookup (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    ba) Machine
    mach
               !(I# Int#
    i') = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
               ba2 :: ByteArray
    ba2 = IO ByteArray -> ByteArray
    forall a. IO a -> a
    unsafeDupablePerformIO (IO ByteArray -> ByteArray) -> IO ByteArray -> ByteArray
    forall a b. (a -> b) -> a -> b
    $ do
                       BA.MutableByteArray MutableByteArray# RealWorld
    mba <- ByteArray -> IO (MutableByteArray (PrimState IO))
    forall (m :: Type -> Type).
    PrimMonad m =>
    ByteArray -> m (MutableByteArray (PrimState m))
    BA.unsafeThawByteArray ByteArray
    ba1
                       MutableByteArray RealWorld
    mba' <- (State# RealWorld
     -> (# State# RealWorld, MutableByteArray RealWorld #))
    -> IO (MutableByteArray RealWorld)
    forall a. (State# RealWorld -> (# State# RealWorld, a #)) -> IO a
    IO (\State# RealWorld
    s -> case MutableByteArray# RealWorld
    -> Int#
    -> State# RealWorld
    -> (# State# RealWorld, MutableByteArray# RealWorld #)
    forall d.
    MutableByteArray# d
    -> Int# -> State# d -> (# State# d, MutableByteArray# d #)
    resizeMutableByteArray# MutableByteArray# RealWorld
    mba Int#
    i' State# RealWorld
    s of
                                     (# State# RealWorld
    s', MutableByteArray# RealWorld
    mba' #) -> (# State# RealWorld
    s', MutableByteArray# RealWorld -> MutableByteArray RealWorld
    forall s. MutableByteArray# s -> MutableByteArray s
    BA.MutableByteArray MutableByteArray# RealWorld
    mba' #))
                       MutableByteArray (PrimState IO) -> IO ByteArray
    forall (m :: Type -> Type).
    PrimMonad m =>
    MutableByteArray (PrimState m) -> m ByteArray
    BA.unsafeFreezeByteArray MutableByteArray RealWorld
    MutableByteArray (PrimState IO)
    mba'
               ba3 :: Term
    ba3 = Literal -> Term
    Literal (ByteArray -> Literal
    ByteArrayLiteral ByteArray
    ba2)
               newE :: Term
    newE = Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                        [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (PrimInfo -> Term
    Prim PrimInfo
    rwTy)
                        ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    mbaTy)
                                      [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Integer -> Literal) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral (Integer -> Term) -> Integer -> Term
    forall a b. (a -> b) -> a -> b
    $ Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger Unique
    p)])
                        ])
           in Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine)
    -> (Machine -> Machine) -> Machine -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Term -> Machine -> Machine
    setTerm Term
    newE (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Unique -> Term -> Machine -> Machine
    primInsert Unique
    p Term
    ba3 Machine
    mach

      Text
    "GHC.Prim.shrinkMutableByteArray#"
        | [PrimVal PrimInfo
    _mbaTy [Type]
    _ [Value
    baV]
          ,Value
    lenV
          ,PrimVal PrimInfo
    rwTy [Type]
    _ [Value]
    _
          ] <- [Value]
    args
        , [Integer
    ba,Integer
    len] <- [Value] -> [Integer]
    intLiterals' [Value
    baV,Value
    lenV]
        -> let Just (Literal (ByteArrayLiteral ByteArray
    ba1)) =
                  Unique -> Machine -> Maybe Term
    primLookup (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    ba) Machine
    mach
               !(I# Int#
    len') = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    len
               ba2 :: ByteArray
    ba2 = IO ByteArray -> ByteArray
    forall a. IO a -> a
    unsafeDupablePerformIO (IO ByteArray -> ByteArray) -> IO ByteArray -> ByteArray
    forall a b. (a -> b) -> a -> b
    $ do
                      BA.MutableByteArray MutableByteArray# RealWorld
    mba <- ByteArray -> IO (MutableByteArray (PrimState IO))
    forall (m :: Type -> Type).
    PrimMonad m =>
    ByteArray -> m (MutableByteArray (PrimState m))
    BA.unsafeThawByteArray ByteArray
    ba1
                      (State# RealWorld -> State# RealWorld) -> IO ()
    svoid (MutableByteArray# RealWorld
    -> Int# -> State# RealWorld -> State# RealWorld
    forall d. MutableByteArray# d -> Int# -> State# d -> State# d
    shrinkMutableByteArray# MutableByteArray# RealWorld
    mba Int#
    len')
                      MutableByteArray (PrimState IO) -> IO ByteArray
    forall (m :: Type -> Type).
    PrimMonad m =>
    MutableByteArray (PrimState m) -> m ByteArray
    BA.unsafeFreezeByteArray (MutableByteArray# RealWorld -> MutableByteArray RealWorld
    forall s. MutableByteArray# s -> MutableByteArray s
    BA.MutableByteArray MutableByteArray# RealWorld
    mba)
               ba3 :: Term
    ba3 = Literal -> Term
    Literal (ByteArray -> Literal
    ByteArrayLiteral ByteArray
    ba2)
           in Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine)
    -> (Machine -> Machine) -> Machine -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Term -> Machine -> Machine
    setTerm (PrimInfo -> Term
    Prim PrimInfo
    rwTy) (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Unique -> Term -> Machine -> Machine
    primUpdate (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    ba) Term
    ba3 Machine
    mach

      Text
    "GHC.Prim.copyByteArray#"
        | [Lit (ByteArrayLiteral (BA.ByteArray ByteArray#
    src_ba))
          ,Value
    src_offV
          ,PrimVal PrimInfo
    _mbaTy [Type]
    _ [Value
    dst_mbaV]
          ,Value
    dst_offV, Value
    nV
          ,PrimVal PrimInfo
    rwTy [Type]
    _ [Value]
    _
          ] <- [Value]
    args
        , [Integer
    src_off,Integer
    dst_mba,Integer
    dst_off,Integer
    n] <- [Value] -> [Integer]
    intLiterals' [Value
    src_offV,Value
    dst_mbaV,Value
    dst_offV,Value
    nV]
        -> let Just (Literal (ByteArrayLiteral ByteArray
    dst_ba)) =
                  Unique -> Machine -> Maybe Term
    primLookup (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    dst_mba) Machine
    mach
               !(I# Int#
    src_off') = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    src_off
               !(I# Int#
    dst_off') = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    dst_off
               !(I# Int#
    n')       = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    n
               ba2 :: ByteArray
    ba2 = IO ByteArray -> ByteArray
    forall a. IO a -> a
    unsafeDupablePerformIO (IO ByteArray -> ByteArray) -> IO ByteArray -> ByteArray
    forall a b. (a -> b) -> a -> b
    $ do
                      BA.MutableByteArray MutableByteArray# RealWorld
    dst_mba1 <- ByteArray -> IO (MutableByteArray (PrimState IO))
    forall (m :: Type -> Type).
    PrimMonad m =>
    ByteArray -> m (MutableByteArray (PrimState m))
    BA.unsafeThawByteArray ByteArray
    dst_ba
                      (State# RealWorld -> State# RealWorld) -> IO ()
    svoid (ByteArray#
    -> Int#
    -> MutableByteArray# RealWorld
    -> Int#
    -> Int#
    -> State# RealWorld
    -> State# RealWorld
    forall d.
    ByteArray#
    -> Int#
    -> MutableByteArray# d
    -> Int#
    -> Int#
    -> State# d
    -> State# d
    copyByteArray# ByteArray#
    src_ba Int#
    src_off' MutableByteArray# RealWorld
    dst_mba1 Int#
    dst_off' Int#
    n')
                      MutableByteArray (PrimState IO) -> IO ByteArray
    forall (m :: Type -> Type).
    PrimMonad m =>
    MutableByteArray (PrimState m) -> m ByteArray
    BA.unsafeFreezeByteArray (MutableByteArray# RealWorld -> MutableByteArray RealWorld
    forall s. MutableByteArray# s -> MutableByteArray s
    BA.MutableByteArray MutableByteArray# RealWorld
    dst_mba1)
               ba3 :: Term
    ba3 = Literal -> Term
    Literal (ByteArray -> Literal
    ByteArrayLiteral ByteArray
    ba2)
           in Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine)
    -> (Machine -> Machine) -> Machine -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Term -> Machine -> Machine
    setTerm (PrimInfo -> Term
    Prim PrimInfo
    rwTy) (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Unique -> Term -> Machine -> Machine
    primUpdate (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    dst_mba) Term
    ba3 Machine
    mach

      Text
    "GHC.Prim.readWordArray#"
        | [PrimVal PrimInfo
    _mbaTy [Type]
    _  [Value
    baV]
          ,Value
    offV
          ,PrimVal PrimInfo
    rwTy [Type]
    _ [Value]
    _
          ] <- [Value]
    args
        , [Integer
    ba,Integer
    off] <- [Value] -> [Integer]
    intLiterals' [Value
    baV,Value
    offV]
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               Just (Literal (ByteArrayLiteral ByteArray
    ba1)) =
                  Unique -> Machine -> Maybe Term
    primLookup (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    ba) Machine
    mach
               !(I# Int#
    off') = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    off
               w :: Word
    w = IO Word -> Word
    forall a. IO a -> a
    unsafeDupablePerformIO (IO Word -> Word) -> IO Word -> Word
    forall a b. (a -> b) -> a -> b
    $ do
                      BA.MutableByteArray MutableByteArray# RealWorld
    mba <- ByteArray -> IO (MutableByteArray (PrimState IO))
    forall (m :: Type -> Type).
    PrimMonad m =>
    ByteArray -> m (MutableByteArray (PrimState m))
    BA.unsafeThawByteArray ByteArray
    ba1
                      (State# RealWorld -> (# State# RealWorld, Word #)) -> IO Word
    forall a. (State# RealWorld -> (# State# RealWorld, a #)) -> IO a
    IO (\State# RealWorld
    s -> case MutableByteArray# RealWorld
    -> Int# -> State# RealWorld -> (# State# RealWorld, Word# #)
    forall d.
    MutableByteArray# d -> Int# -> State# d -> (# State# d, Word# #)
    readWordArray# MutableByteArray# RealWorld
    mba Int#
    off' State# RealWorld
    s of
                            (# State# RealWorld
    s', Word#
    w' #) -> (# State# RealWorld
    s',  Word# -> Word
    W# Word#
    w' #))
               newE :: Term
    newE = Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                        [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (PrimInfo -> Term
    Prim PrimInfo
    rwTy)
                        ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    WordLiteral (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    w)))
                        ])
           in Term -> Maybe Machine
    reduce Term
    newE

      Text
    "GHC.Prim.copyAddrToByteArray#"
        | [ Lit (StringLiteral [Char]
    addr)
          , PrimVal PrimInfo
    _mbaTy [Type]
    _ [Value
    dst_mbaV]
          , Value
    offV, Value
    lenV
          , PrimVal PrimInfo
    rwTy [Type]
    _ [Value]
    _
          ] <- [Value]
    args
        , [Integer
    off,Integer
    len,Integer
    dst_mba] <- [Value] -> [Integer]
    intLiterals' [Value
    offV, Value
    lenV, Value
    dst_mbaV]
        -> let Just (Literal (ByteArrayLiteral ByteArray
    dst_ba)) =
                  Unique -> Machine -> Maybe Term
    primLookup (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    dst_mba) Machine
    mach
               !(I# Int#
    off') = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    off
               !(I# Int#
    len') = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    len
               !(BS.PS (ForeignPtr Addr#
    addr' ForeignPtrContents
    _) Unique
    _ Unique
    _) = [Char] -> ByteString
    BS.packChars [Char]
    addr
               ba2 :: ByteArray
    ba2 = IO ByteArray -> ByteArray
    forall a. IO a -> a
    unsafeDupablePerformIO (IO ByteArray -> ByteArray) -> IO ByteArray -> ByteArray
    forall a b. (a -> b) -> a -> b
    $ do
                        BA.MutableByteArray MutableByteArray# RealWorld
    dst_mba1 <- ByteArray -> IO (MutableByteArray (PrimState IO))
    forall (m :: Type -> Type).
    PrimMonad m =>
    ByteArray -> m (MutableByteArray (PrimState m))
    BA.unsafeThawByteArray ByteArray
    dst_ba
                        (State# RealWorld -> State# RealWorld) -> IO ()
    svoid (Addr#
    -> MutableByteArray# RealWorld
    -> Int#
    -> Int#
    -> State# RealWorld
    -> State# RealWorld
    forall d.
    Addr#
    -> MutableByteArray# d -> Int# -> Int# -> State# d -> State# d
    copyAddrToByteArray# Addr#
    addr' MutableByteArray# RealWorld
    dst_mba1 Int#
    off' Int#
    len')
                        MutableByteArray (PrimState IO) -> IO ByteArray
    forall (m :: Type -> Type).
    PrimMonad m =>
    MutableByteArray (PrimState m) -> m ByteArray
    BA.unsafeFreezeByteArray (MutableByteArray# RealWorld -> MutableByteArray RealWorld
    forall s. MutableByteArray# s -> MutableByteArray s
    BA.MutableByteArray MutableByteArray# RealWorld
    dst_mba1)
               ba3 :: Term
    ba3 = Literal -> Term
    Literal (ByteArray -> Literal
    ByteArrayLiteral ByteArray
    ba2)
            in Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine)
    -> (Machine -> Machine) -> Machine -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Term -> Machine -> Machine
    setTerm (PrimInfo -> Term
    Prim PrimInfo
    rwTy) (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Unique -> Term -> Machine -> Machine
    primUpdate (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    dst_mba) Term
    ba3 Machine
    mach

    -- decodeFloat_Int# :: Float# -> (#Int#, Int##)
      Text
    "GHC.Prim.decodeFloat_Int#" | [Word32
    i] <- [Value] -> [Word32]
    floatLiterals' [Value]
    args
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               !(F# Float#
    a) = Word32 -> Float
    wordToFloat Word32
    i
               !(# Int#
    p, Int#
    q #) = Float# -> (# Int#, Int# #)
    decodeFloat_Int# Float#
    a
           in Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
              Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                       [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral  (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Term) -> Unique -> Term
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    p)
                       , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral  (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Term) -> Unique -> Term
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    q)])

      Text
    "GHC.Prim.tagToEnum#"
        | [ConstTy (TyCon TyConName
    tcN)] <- [Type]
    tys
        , [Lit (IntLiteral Integer
    i)]  <- [Value]
    args
        -> let dc :: Maybe DataCon
    dc = do { TyCon
    tc <- TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tcN TyConMap
    tcm
                       ; let dcs :: [DataCon]
    dcs = TyCon -> [DataCon]
    tyConDataCons TyCon
    tc
                       ; (DataCon -> Bool) -> [DataCon] -> Maybe DataCon
    forall (t :: Type -> Type) a.
    Foldable t =>
    (a -> Bool) -> t a -> Maybe a
    List.find ((Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    +Integer
    1)) (Integer -> Bool) -> (DataCon -> Integer) -> DataCon -> Bool
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (DataCon -> Unique) -> DataCon -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . DataCon -> Unique
    dcTag) [DataCon]
    dcs
                       }
           in (\DataCon
    e -> Term -> Machine -> Machine
    setTerm (DataCon -> Term
    Data DataCon
    e) Machine
    mach) (DataCon -> Machine) -> Maybe DataCon -> Maybe Machine
    forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe DataCon
    dc

      Text
    "GHC.Prim.dataToTag#"
        | [DC DataCon
    dc [Either Term Type]
    _] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (DataCon -> Unique
    dcTag DataCon
    dc Unique -> Unique -> Unique
    forall a. Num a => a -> a -> a
    - Unique
    1))))

      Text
    "GHC.Classes.eqInt" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intCLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    j))

      Text
    "GHC.Classes.neInt" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intCLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    /= Integer
    j))

      Text
    "GHC.Classes.leInt" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intCLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <= Integer
    j))

      Text
    "GHC.Classes.ltInt" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intCLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    < Integer
    j))

      Text
    "GHC.Classes.geInt" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intCLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Integer
    j))

      Text
    "GHC.Classes.gtInt" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intCLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    > Integer
    j))

      Text
    "GHC.Classes.&&"
        | [ Value
    lArg , Value
    rArg ] <- [Value]
    args
        , Evaluator
    eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
    Evaluator Step
    ghcStep Unwind
    ghcUnwind PrimStep
    ghcPrimStep PrimUnwind
    ghcPrimUnwind
        -- evaluation of the arguments is deferred until the evaluation of the ghcPrimUnwindWith
        -- to make `&&` lazy in both arguments
        , mach1 :: Machine
    mach1@Machine{mStack :: Machine -> Stack
    mStack=[],mTerm :: Machine -> Term
    mTerm=Term
    lArgWHNF} <- Evaluator -> TyConMap -> Bool -> Machine -> Machine
    whnf Evaluator
    eval TyConMap
    tcm Bool
    True (Term -> Machine -> Machine
    setTerm (Value -> Term
    valToTerm Value
    lArg) (Machine -> Machine) -> Machine -> Machine
    forall a b. (a -> b) -> a -> b
    $ Machine -> Machine
    stackClear Machine
    mach)
        , mach2 :: Machine
    mach2@Machine{mStack :: Machine -> Stack
    mStack=[],mTerm :: Machine -> Term
    mTerm=Term
    rArgWHNF} <- Evaluator -> TyConMap -> Bool -> Machine -> Machine
    whnf Evaluator
    eval TyConMap
    tcm Bool
    True (Term -> Machine -> Machine
    setTerm (Value -> Term
    valToTerm Value
    rArg) (Machine -> Machine) -> Machine -> Machine
    forall a b. (a -> b) -> a -> b
    $ Machine -> Machine
    stackClear Machine
    mach1)
        -> case [ Term
    lArgWHNF, Term
    rArgWHNF ] of
             [ Data DataCon
    lCon, Data DataCon
    rCon ] ->
               Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Machine
    mach2
                 { mStack :: Stack
    mStack = Machine -> Stack
    mStack Machine
    mach
                 , mTerm :: Term
    mTerm = TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (DataCon -> Bool
    isTrueDC DataCon
    lCon Bool -> Bool -> Bool
    && DataCon -> Bool
    isTrueDC DataCon
    rCon)
                 }

             [ Data DataCon
    lCon, Term
    _ ]
               | DataCon -> Bool
    isTrueDC DataCon
    lCon -> Term -> Maybe Machine
    reduce Term
    rArgWHNF
               | Bool
    otherwise     -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty Bool
    False)

             [ Term
    _, Data DataCon
    rCon ]
               | DataCon -> Bool
    isTrueDC DataCon
    rCon -> Term -> Maybe Machine
    reduce Term
    lArgWHNF
               | Bool
    otherwise     -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty Bool
    False)

             [Term]
    _ -> Maybe Machine
    forall a. Maybe a
    Nothing

      Text
    "GHC.Classes.||"
        | [ Value
    lArg , Value
    rArg ] <- [Value]
    args
        , Evaluator
    eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
    Evaluator Step
    ghcStep Unwind
    ghcUnwind PrimStep
    ghcPrimStep PrimUnwind
    ghcPrimUnwind
        -- evaluation of the arguments is deferred until the evaluation of the ghcPrimUnwindWith
        -- to make `||` lazy in both arguments
        , mach1 :: Machine
    mach1@Machine{mStack :: Machine -> Stack
    mStack=[],mTerm :: Machine -> Term
    mTerm=Term
    lArgWHNF} <- Evaluator -> TyConMap -> Bool -> Machine -> Machine
    whnf Evaluator
    eval TyConMap
    tcm Bool
    True (Term -> Machine -> Machine
    setTerm (Value -> Term
    valToTerm Value
    lArg) (Machine -> Machine) -> Machine -> Machine
    forall a b. (a -> b) -> a -> b
    $ Machine -> Machine
    stackClear Machine
    mach)
        , mach2 :: Machine
    mach2@Machine{mStack :: Machine -> Stack
    mStack=[],mTerm :: Machine -> Term
    mTerm=Term
    rArgWHNF} <- Evaluator -> TyConMap -> Bool -> Machine -> Machine
    whnf Evaluator
    eval TyConMap
    tcm Bool
    True (Term -> Machine -> Machine
    setTerm (Value -> Term
    valToTerm Value
    rArg) (Machine -> Machine) -> Machine -> Machine
    forall a b. (a -> b) -> a -> b
    $ Machine -> Machine
    stackClear Machine
    mach1)
        -> case [ Term
    lArgWHNF, Term
    rArgWHNF ] of
             [ Data DataCon
    lCon, Data DataCon
    rCon ] ->
               Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Machine
    mach2
                 { mStack :: Stack
    mStack = Machine -> Stack
    mStack Machine
    mach
                 , mTerm :: Term
    mTerm = TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (DataCon -> Bool
    isTrueDC DataCon
    lCon Bool -> Bool -> Bool
    || DataCon -> Bool
    isTrueDC DataCon
    rCon)
                 }

             [ Data DataCon
    lCon, Term
    _ ]
               | DataCon -> Bool
    isFalseDC DataCon
    lCon -> Term -> Maybe Machine
    reduce Term
    rArgWHNF
               | Bool
    otherwise      -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty Bool
    True)

             [ Term
    _, Data DataCon
    rCon ]
               | DataCon -> Bool
    isFalseDC DataCon
    rCon -> Term -> Maybe Machine
    reduce Term
    lArgWHNF
               | Bool
    otherwise      -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty Bool
    True)

             [Term]
    _ -> Maybe Machine
    forall a. Maybe a
    Nothing

      Text
    "GHC.Classes.divInt#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    intLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `div` Integer
    j))

      -- modInt# :: Int# -> Int# -> Int#
      Text
    "GHC.Classes.modInt#"
        | [Integer
    dividend, Integer
    divisor] <- [Value] -> [Integer]
    intLiterals' [Value]
    args
        ->
          if Integer
    divisor Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    0 then
            let iTy :: Type
    iTy = ([Either TyVar Type], Type) -> Type
    forall a b. (a, b) -> b
    snd (Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty) in
            Term -> Maybe Machine
    reduce (Term -> Type -> Term
    TyApp (PrimInfo -> Term
    Prim PrimInfo
    NP.undefined) Type
    iTy)
          else
            Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Integer
    dividend Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `mod` Integer
    divisor)))

      Text
    "GHC.Classes.not"
        | [DC DataCon
    bCon [Either Term Type]
    _] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Name DataCon -> Text
    forall a. Name a -> Text
    nameOcc (DataCon -> Name DataCon
    dcName DataCon
    bCon) Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    "GHC.Types.False"))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerLogBase#"
        | Just (Integer
    a,Integer
    b) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        , Just Unique
    c <- Integer -> Integer -> Maybe Unique
    flogBase Integer
    a Integer
    b
        -> (Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Unique -> Term) -> Unique -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    WordLiteral (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger) Unique
    c

      Text
    "GHC.Num.Integer.integerToFloat#"
        | [Value
    v] <- [Value]
    args
        , Just Integer
    i <- Value -> Maybe Integer
    integerLiteral Value
    v
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Float -> Term) -> Float -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Float -> Literal) -> Float -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word32 -> Literal
    FloatLiteral (Word32 -> Literal) -> (Float -> Word32) -> Float -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Float -> Word32
    floatToWord (Float -> Maybe Machine) -> Float -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Float# -> Float
    F# (Integer -> Float#
    integerToFloat# Integer
    i)

      Text
    "GHC.Num.Integer.integerToDouble#"
        | [Value
    v] <- [Value]
    args
        , Just Integer
    i <- Value -> Maybe Integer
    integerLiteral Value
    v
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Double -> Term) -> Double -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Double -> Literal) -> Double -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Literal
    DoubleLiteral (Word64 -> Literal) -> (Double -> Word64) -> Double -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Double -> Word64
    doubleToWord (Double -> Maybe Machine) -> Double -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Double# -> Double
    D# (Integer -> Double#
    integerToDouble# Integer
    i)

      Text
    "GHC.Float.integerToFloat#"
        | [Value
    v] <- [Value]
    args
        , Just Integer
    i <- Value -> Maybe Integer
    integerLiteral Value
    v
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Float -> Term) -> Float -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Float -> Literal) -> Float -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word32 -> Literal
    FloatLiteral (Word32 -> Literal) -> (Float -> Word32) -> Float -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Float -> Word32
    floatToWord (Float -> Maybe Machine) -> Float -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Float# -> Float
    F# (Integer -> Float#
    integerToFloat# Integer
    i)

      Text
    "GHC.Float.integerToDouble#"
        | [Value
    v] <- [Value]
    args
        , Just Integer
    i <- Value -> Maybe Integer
    integerLiteral Value
    v
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Double -> Term) -> Double -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Double -> Literal) -> Double -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Literal
    DoubleLiteral (Word64 -> Literal) -> (Double -> Word64) -> Double -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Double -> Word64
    doubleToWord (Double -> Maybe Machine) -> Double -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Double# -> Double
    D# (Integer -> Double#
    integerToDouble# Integer
    i)

      Text
    "GHC.Num.Natural.naturalLogBase#"
        | Just (Integer
    a,Integer
    b) <- [Value] -> Maybe (Integer, Integer)
    naturalLiterals [Value]
    args
        , Just Unique
    c <- Integer -> Integer -> Maybe Unique
    flogBase Integer
    a Integer
    b
        -> (Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Unique -> Term) -> Unique -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    WordLiteral (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger) Unique
    c
    #else
      "GHC.Integer.Logarithms.integerLogBase#"
        | Just (a,b) <- integerLiterals args
        , Just c <- flogBase a b
        -> (reduce . Literal . IntLiteral . toInteger) c
    #endif

    #if !MIN_VERSION_base(4,15,0)
      "GHC.Integer.Type.smallInteger"
        | [Lit (IntLiteral i)] <- args
        -> reduce (Literal (IntegerLiteral i))
    #endif

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerToInt#"
    #else
      "GHC.Integer.Type.integerToInt"
    #endif
        | [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntLiteral Integer
    i)

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerDecodeDouble#" -- :: Double# -> (#Integer, Int##)
    #else
      "GHC.Integer.Type.decodeDoubleInteger" -- :: Double# -> (#Integer, Int##)
    #endif
        | [Lit (DoubleLiteral Word64
    i)] <- [Value]
    args
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               !(D# Double#
    a)  = Word64 -> Double
    wordToDouble Word64
    i
               !(# Integer
    b, Int#
    c #) = Double# -> (# Integer, Int# #)
    decodeDoubleInteger Double#
    a
        in Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
           Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                    [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Integer -> Term
    integerToIntegerLiteral Integer
    b)
                    , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Integer -> Term
    integerToIntLiteral (Integer -> Term) -> (Unique -> Integer) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Term) -> Unique -> Term
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    c)])

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerEncodeDouble#" -- :: Integer -> Int# -> Double
    #else
      "GHC.Integer.Type.encodeDoubleInteger" -- :: Integer -> Int# -> Double
    #endif
        | [Value
    iV, Lit (IntLiteral Integer
    j)] <- [Value]
    args
        , [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value
    iV]
        -> let !(I# Int#
    k') = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
               r :: Double#
    r = Integer -> Int# -> Double#
    encodeDoubleInteger Integer
    i Int#
    k'
        in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Double -> Term) -> Double -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Double -> Literal) -> Double -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Literal
    DoubleLiteral (Word64 -> Literal) -> (Double -> Word64) -> Double -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Double -> Word64
    doubleToWord (Double -> Maybe Machine) -> Double -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Double# -> Double
    D# Double#
    r

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerEncodeFloat#"
        | [Value
    iV, Lit (IntLiteral Integer
    j)] <- [Value]
    args
        , [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value
    iV]
        -> let !(I# Int#
    k') = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
               r :: Float#
    r = Integer -> Int# -> Float#
    integerEncodeFloat# Integer
    i Int#
    k'
            in Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Float -> Term) -> Float -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Term) -> (Float -> Literal) -> Float -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word32 -> Literal
    FloatLiteral (Word32 -> Literal) -> (Float -> Word32) -> Float -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Float -> Word32
    floatToWord (Float -> Maybe Machine) -> Float -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Float# -> Float
    F# Float#
    r
    #endif

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerQuotRem#" -- :: Integer -> Integer -> (#Integer, Integer#)
    #else
      "GHC.Integer.Type.quotRemInteger" -- :: Integer -> Integer -> (#Integer, Integer#)
    #endif
        | [Integer
    i, Integer
    j] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               (Integer
    q,Integer
    r) = Integer -> Integer -> (Integer, Integer)
    forall a. Integral a => a -> a -> (a, a)
    quotRem Integer
    i Integer
    j
        in Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
             Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                    [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Either Term Type) -> Term -> Either Term Type
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Integer -> Term
    integerToIntegerLiteral Integer
    q)
                    , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Either Term Type) -> Term -> Either Term Type
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Integer -> Term
    integerToIntegerLiteral Integer
    r)])

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerAdd"
    #else
      "GHC.Integer.Type.plusInteger"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntegerLiteral (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    +Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerSub"
    #else
      "GHC.Integer.Type.minusInteger"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntegerLiteral (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerMul"
    #else
      "GHC.Integer.Type.timesInteger"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntegerLiteral (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    *Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerNegate"
    #else
      "GHC.Integer.Type.negateInteger"
    #endif
        | [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntegerLiteral (Integer -> Integer
    forall a. Num a => a -> a
    negate Integer
    i))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerDiv"
    #else
      "GHC.Integer.Type.divInteger"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Integer -> Term
    integerToIntegerLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `div` Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerMod"
    #else
      "GHC.Integer.Type.modInteger"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Integer -> Term
    integerToIntegerLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `mod` Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerQuot"
    #else
      "GHC.Integer.Type.quotInteger"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Integer -> Term
    integerToIntegerLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `quot` Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerRem"
    #else
      "GHC.Integer.Type.remInteger"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Integer -> Term
    integerToIntegerLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `rem` Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerDivMod#"
    #else
      "GHC.Integer.Type.divModInteger"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    ubTupTcNm [Type
    liftedKi,Type
    _,Type
    intTy,Type
    _]) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    ubTupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    ubTupTcNm TyConMap
    tcm
               [DataCon
    ubTupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    ubTupTc
               (Integer
    d,Integer
    m) = Integer -> Integer -> (Integer, Integer)
    forall a. Integral a => a -> a -> (a, a)
    divMod Integer
    i Integer
    j
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    ubTupDc) [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    liftedKi, Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    liftedKi
                                     , Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    intTy,    Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    intTy
                                     , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Either Term Type) -> Term -> Either Term Type
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral Integer
    d))
                                     , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Either Term Type) -> Term -> Either Term Type
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral Integer
    m))
                                     ]

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerGt"
    #else
      "GHC.Integer.Type.gtInteger"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    > Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerGe"
    #else
      "GHC.Integer.Type.geInteger"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerEq"
    #else
      "GHC.Integer.Type.eqInteger"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerNe"
    #else
      "GHC.Integer.Type.neqInteger"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    /= Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerLt"
    #else
      "GHC.Integer.Type.ltInteger"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    < Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerLe"
    #else
      "GHC.Integer.Type.leInteger"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <= Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerGt#"
    #else
      "GHC.Integer.Type.gtInteger#"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    > Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerGe#"
    #else
      "GHC.Integer.Type.geInteger#"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerEq#"
    #else
      "GHC.Integer.Type.eqInteger#"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerNe#"
    #else
      "GHC.Integer.Type.neqInteger#"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    /= Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerLt#"
    #else
      "GHC.Integer.Type.ltInteger#"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    < Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerLe#"
    #else
      "GHC.Integer.Type.leInteger#"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <= Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerCompare"
    #else
      "GHC.Integer.Type.compareInteger" -- :: Integer -> Integer -> Ordering
    #endif
        | [Integer
    i, Integer
    j] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> let -- Get the required result type (viewed as an applied type constructor name)
               ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               -- Find the type constructor from the name
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               -- Get the data constructors of that type
               -- The type is 'Ordering', so they are: 'LT', 'EQ', 'GT'
               [DataCon
    ltDc, DataCon
    eqDc, DataCon
    gtDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               -- Do the actual compile-time evaluation
               ordVal :: Ordering
    ordVal = Integer -> Integer -> Ordering
    compareInteger Integer
    i Integer
    j
            in Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ case Ordering
    ordVal of
                Ordering
    LT -> DataCon -> Term
    Data DataCon
    ltDc
                Ordering
    EQ -> DataCon -> Term
    Data DataCon
    eqDc
                Ordering
    GT -> DataCon -> Term
    Data DataCon
    gtDc

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerShiftR#"
        | [Value
    iV, Lit (WordLiteral Integer
    j)] <- [Value]
    args
    #else
      "GHC.Integer.Type.shiftRInteger"
        | [iV, Lit (IntLiteral j)] <- args
    #endif
        , [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value
    iV]
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntegerLiteral (Integer
    i Integer -> Unique -> Integer
    forall a. Bits a => a -> Unique -> a
    `shiftR` Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerShiftL#"
        | [Value
    iV, Lit (WordLiteral Integer
    j)] <- [Value]
    args
    #else
      "GHC.Integer.Type.shiftLInteger"
        | [iV, Lit (IntLiteral j)] <- args
    #endif
        , [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value
    iV]
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntegerLiteral (Integer
    i Integer -> Unique -> Integer
    forall a. Bits a => a -> Unique -> a
    `shiftL` Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerFromWord#"
    #else
      "GHC.Integer.Type.wordToInteger"
    #endif
        | [Lit (WordLiteral Integer
    w)] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral Integer
    w))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerToWord#"
    #else
      "GHC.Integer.Type.integerToWord"
    #endif
        | [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToWordLiteral Integer
    i)

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerTestBit#" -- :: Integer -> Int# -> Int#
        | [Lit (IntegerLiteral Integer
    i), Lit (WordLiteral Integer
    j)] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer -> Unique -> Bool
    forall a. Bits a => a -> Unique -> Bool
    testBit Integer
    i (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j)))
    #else
      "GHC.Integer.Type.testBitInteger" -- :: Integer -> Int# -> Bool
        | [Lit (IntegerLiteral i), Lit (IntLiteral j)] <- args
        -> reduce (boolToBoolLiteral tcm ty (testBit i (fromInteger j)))
    #endif

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Natural.NS"
        | [Lit (WordLiteral Integer
    w)] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral Integer
    w))
      Text
    "GHC.Num.Natural.NB"
        | [Lit (ByteArrayLiteral (BA.ByteArray ByteArray#
    ba))] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (ByteArray# -> Integer
    IP ByteArray#
    ba)))
        | [Lit Literal
    l] <- [Value]
    args
        -> [Char] -> Maybe Machine
    forall a. HasCallStack => [Char] -> a
    error ([Char]
    "NB: " [Char] -> [Char] -> [Char]
    forall a. Semigroup a => a -> a -> a
    <> Literal -> [Char]
    forall a. Show a => a -> [Char]
    show Literal
    l)
      Text
    "GHC.Num.Integer.IS"
        | [Lit (IntLiteral Integer
    i)] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral Integer
    i))
      Text
    "GHC.Num.Integer.IP"
        | [Lit (ByteArrayLiteral (BA.ByteArray ByteArray#
    ba))] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral (ByteArray# -> Integer
    IP ByteArray#
    ba)))
        | [Lit Literal
    l] <- [Value]
    args
        -> [Char] -> Maybe Machine
    forall a. HasCallStack => [Char] -> a
    error ([Char]
    "IP: " [Char] -> [Char] -> [Char]
    forall a. Semigroup a => a -> a -> a
    <> Literal -> [Char]
    forall a. Show a => a -> [Char]
    show Literal
    l)
      Text
    "GHC.Num.Integer.IN"
        | [Lit Literal
    l] <- [Value]
    args
        -> [Char] -> Maybe Machine
    forall a. HasCallStack => [Char] -> a
    error ([Char]
    "IN: " [Char] -> [Char] -> [Char]
    forall a. Semigroup a => a -> a -> a
    <> Literal -> [Char]
    forall a. Show a => a -> [Char]
    show Literal
    l)
    #else
      "GHC.Natural.NatS#"
        | [Lit (WordLiteral w)] <- args
        -> reduce (Literal (NaturalLiteral w))
    #endif

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerFromNatural"
    #else
      "GHC.Natural.naturalToInteger"
    #endif
        | [Integer
    i] <- [Value] -> [Integer]
    naturalLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral (Integer -> Integer
    forall a. Integral a => a -> Integer
    toInteger Integer
    i)))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerToNatural"
    #else
      "GHC.Natural.naturalFromInteger"
    #endif
        | [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        ->
         let nTy :: Type
    nTy = ([Either TyVar Type], Type) -> Type
    forall a b. (a, b) -> b
    snd (Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty) in
         Term -> Maybe Machine
    reduce (Type -> Integer -> (Natural -> Natural) -> Term
    checkNaturalRange1 Type
    nTy Integer
    i Natural -> Natural
    forall a. a -> a
    id)

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerToNaturalClamp"
        | [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> if Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    < Integer
    0 then
             Term -> Maybe Machine
    reduce (Natural -> Term
    naturalToNaturalLiteral Natural
    0)
           else
             Term -> Maybe Machine
    reduce (Natural -> Term
    naturalToNaturalLiteral (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger Integer
    i))

      Text
    "GHC.Num.Integer.integerToNaturalThrow"
        | [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> let nTy :: Type
    nTy = ([Either TyVar Type], Type) -> Type
    forall a b. (a, b) -> b
    snd (Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty) in
           Term -> Maybe Machine
    reduce (Type -> Integer -> (Natural -> Natural) -> Term
    checkNaturalRange1 Type
    nTy Integer
    i Natural -> Natural
    forall a. a -> a
    id)
    #endif

      Text
    "GHC.Num.Integer.integerToInt64#"
        | [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToInt64Literal Integer
    i)

      Text
    "GHC.Num.Integer.integerToWord64#"
        | [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToWord64Literal Integer
    i)

    #if MIN_VERSION_base(4,17,0)
      Text
    "GHC.Num.Integer.integerFromWord64#"
        | [Integer
    w] <- [Value] -> [Integer]
    word64Literals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral Integer
    w))
    #endif

    #if !MIN_VERSION_base(4,15,0)
      -- GHC.shiftLNatural --- XXX: Fragile worker of GHC.shiflLNatural
      "GHC.Natural.$wshiftLNatural"
        | [nV,iV] <- args
        , [n] <- naturalLiterals' [nV]
        , [i] <- fromInteger <$> intLiterals' [iV]
        ->
         let nTy = snd (splitFunForallTy ty) in
         reduce (checkNaturalRange1 nTy n ((flip shiftL) i))
    #endif

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Natural.naturalAdd"
    #else
      "GHC.Natural.plusNatural"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    naturalLiterals [Value]
    args
        ->
         let nTy :: Type
    nTy = ([Either TyVar Type], Type) -> Type
    forall a b. (a, b) -> b
    snd (Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty) in
         Term -> Maybe Machine
    reduce (Type
    -> Integer -> Integer -> (Natural -> Natural -> Natural) -> Term
    checkNaturalRange2 Type
    nTy Integer
    i Integer
    j Natural -> Natural -> Natural
    forall a. Num a => a -> a -> a
    (+))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Natural.naturalMul"
    #else
      "GHC.Natural.timesNatural"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    naturalLiterals [Value]
    args
        ->
         let nTy :: Type
    nTy = ([Either TyVar Type], Type) -> Type
    forall a b. (a, b) -> b
    snd (Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty) in
         Term -> Maybe Machine
    reduce (Type
    -> Integer -> Integer -> (Natural -> Natural -> Natural) -> Term
    checkNaturalRange2 Type
    nTy Integer
    i Integer
    j Natural -> Natural -> Natural
    forall a. Num a => a -> a -> a
    (*))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Natural.naturalSubUnsafe"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    naturalLiterals [Value]
    args
        ->
         let nTy :: Type
    nTy = ([Either TyVar Type], Type) -> Type
    forall a b. (a, b) -> b
    snd (Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty) in
         Term -> Maybe Machine
    reduce (Type -> [Integer] -> ([Natural] -> Term) -> Term
    checkNaturalRange Type
    nTy [Integer
    i, Integer
    j] (\[Natural
    i', Natural
    j'] ->
          Natural -> Term
    naturalToNaturalLiteral (Natural -> Natural -> Natural
    naturalSubUnsafe Natural
    i' Natural
    j')))

      Text
    "GHC.Num.Natural.naturalSubThrow"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    naturalLiterals [Value]
    args
        ->
         let nTy :: Type
    nTy = ([Either TyVar Type], Type) -> Type
    forall a b. (a, b) -> b
    snd (Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty) in
         Term -> Maybe Machine
    reduce (Type -> [Integer] -> ([Natural] -> Term) -> Term
    checkNaturalRange Type
    nTy [Integer
    i, Integer
    j] (\[Natural
    i', Natural
    j'] ->
                    case Natural -> Natural -> Maybe Natural
    minusNaturalMaybe Natural
    i' Natural
    j' of
                      Maybe Natural
    Nothing -> Type -> Integer -> (Natural -> Natural) -> Term
    checkNaturalRange1 Type
    nTy (-Integer
    1) Natural -> Natural
    forall a. a -> a
    id
                      Just Natural
    n -> Natural -> Term
    naturalToNaturalLiteral Natural
    n))
    #else
      "GHC.Natural.minusNatural"
        | Just (i,j) <- naturalLiterals args
        ->
         let nTy = snd (splitFunForallTy ty) in
         reduce (checkNaturalRange nTy [i, j] (\[i', j'] ->
                    case minusNaturalMaybe i' j' of
                      Nothing -> checkNaturalRange1 nTy (-1) id
                      Just n -> naturalToNaturalLiteral n))
    #endif

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Natural.naturalFromWord#"
    #else
      "GHC.Natural.wordToNatural#"
    #endif
        | [Lit (WordLiteral Integer
    w)] <- [Value]
    args
        ->
         let nTy :: Type
    nTy = ([Either TyVar Type], Type) -> Type
    forall a b. (a, b) -> b
    snd (Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty) in
         Term -> Maybe Machine
    reduce (Type -> Integer -> (Natural -> Natural) -> Term
    checkNaturalRange1 Type
    nTy Integer
    w Natural -> Natural
    forall a. a -> a
    id)

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Natural.naturalToWord#"
        | [Integer
    i] <- [Value] -> [Integer]
    naturalLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToWordLiteral Integer
    i)

      Text
    "GHC.Num.Natural.naturalQuot"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    naturalLiterals [Value]
    args
        ->
         let nTy :: Type
    nTy = ([Either TyVar Type], Type) -> Type
    forall a b. (a, b) -> b
    snd (Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty) in
         Term -> Maybe Machine
    reduce (Type
    -> Integer -> Integer -> (Natural -> Natural -> Natural) -> Term
    checkNaturalRange2 Type
    nTy Integer
    i Integer
    j Natural -> Natural -> Natural
    forall a. Integral a => a -> a -> a
    quot)

      Text
    "GHC.Num.Natural.naturalRem"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    naturalLiterals [Value]
    args
        ->
         let nTy :: Type
    nTy = ([Either TyVar Type], Type) -> Type
    forall a b. (a, b) -> b
    snd (Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty) in
         Term -> Maybe Machine
    reduce (Type
    -> Integer -> Integer -> (Natural -> Natural -> Natural) -> Term
    checkNaturalRange2 Type
    nTy Integer
    i Integer
    j Natural -> Natural -> Natural
    forall a. Integral a => a -> a -> a
    rem)
    #endif

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Natural.naturalQuotRem#" -- :: Natural -> Natural -> (#Natural, Natural#)
        | [Integer
    i, Integer
    j] <- [Value] -> [Integer]
    naturalLiterals' [Value]
    args
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               (Natural
    q,Natural
    r) = Natural -> Natural -> (Natural, Natural)
    forall a. Integral a => a -> a -> (a, a)
    quotRem (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger Integer
    i) (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger Integer
    j)
        in Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
             Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                    [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Either Term Type) -> Term -> Either Term Type
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Natural -> Term
    naturalToNaturalLiteral Natural
    q)
                    , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Either Term Type) -> Term -> Either Term Type
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Natural -> Term
    naturalToNaturalLiteral Natural
    r)])
    #endif

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Natural.naturalGcd"
    #else
      "GHC.Natural.gcdNatural"
    #endif
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    naturalLiterals [Value]
    args
        ->
         let nTy :: Type
    nTy = ([Either TyVar Type], Type) -> Type
    forall a b. (a, b) -> b
    snd (Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty) in
         Term -> Maybe Machine
    reduce (Type
    -> Integer -> Integer -> (Natural -> Natural -> Natural) -> Term
    checkNaturalRange2 Type
    nTy Integer
    i Integer
    j Natural -> Natural -> Natural
    forall a. Integral a => a -> a -> a
    gcd)

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Natural.naturalLcm"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    naturalLiterals [Value]
    args
        ->
         let nTy :: Type
    nTy = ([Either TyVar Type], Type) -> Type
    forall a b. (a, b) -> b
    snd (Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty) in
         Term -> Maybe Machine
    reduce (Type
    -> Integer -> Integer -> (Natural -> Natural -> Natural) -> Term
    checkNaturalRange2 Type
    nTy Integer
    i Integer
    j Natural -> Natural -> Natural
    forall a. Integral a => a -> a -> a
    lcm)
    #endif

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Natural.naturalGt#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    naturalLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    > Integer
    j))

      Text
    "GHC.Num.Natural.naturalGe#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    naturalLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Integer
    j))

      Text
    "GHC.Num.Natural.naturalEq#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    naturalLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    j))

      Text
    "GHC.Num.Natural.naturalNe#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    naturalLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    /= Integer
    j))

      Text
    "GHC.Num.Natural.naturalLt#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    naturalLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    < Integer
    j))

      Text
    "GHC.Num.Natural.naturalLe#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    naturalLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Bool -> Term
    boolToIntLiteral (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <= Integer
    j))

      Text
    "GHC.Num.Natural.naturalShiftL#"
        | [Value
    iV, Lit (WordLiteral Integer
    j)] <- [Value]
    args
        , [Integer
    i] <- [Value] -> [Integer]
    naturalLiterals' [Value
    iV]
        -> Term -> Maybe Machine
    reduce (Natural -> Term
    naturalToNaturalLiteral (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger (Integer
    i Integer -> Unique -> Integer
    forall a. Bits a => a -> Unique -> a
    `shiftL` Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j)))

      Text
    "GHC.Num.Natural.naturalShiftR#"
        | [Value
    iV, Lit (WordLiteral Integer
    j)] <- [Value]
    args
        , [Integer
    i] <- [Value] -> [Integer]
    naturalLiterals' [Value
    iV]
        -> Term -> Maybe Machine
    reduce (Natural -> Term
    naturalToNaturalLiteral (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger (Integer
    i Integer -> Unique -> Integer
    forall a. Bits a => a -> Unique -> a
    `shiftR` Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j)))

      Text
    "GHC.Num.Natural.naturalCompare"
        | [Integer
    i, Integer
    j] <- [Value] -> [Integer]
    naturalLiterals' [Value]
    args
        -> let -- Get the required result type (viewed as an applied type constructor name)
               ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               -- Find the type constructor from the name
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               -- Get the data constructors of that type
               -- The type is 'Ordering', so they are: 'LT', 'EQ', 'GT'
               [DataCon
    ltDc, DataCon
    eqDc, DataCon
    gtDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               -- Do the actual compile-time evaluation
               ordVal :: Ordering
    ordVal = Integer -> Integer -> Ordering
    compareInteger Integer
    i Integer
    j
            in Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ case Ordering
    ordVal of
                Ordering
    LT -> DataCon -> Term
    Data DataCon
    ltDc
                Ordering
    EQ -> DataCon -> Term
    Data DataCon
    eqDc
                Ordering
    GT -> DataCon -> Term
    Data DataCon
    gtDc

      Text
    "GHC.Num.Natural.naturalSignum"
        | [Integer
    i] <- [Value] -> [Integer]
    naturalLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer -> Integer
    forall a. Num a => a -> a
    signum Integer
    i)))

      Text
    "GHC.Num.Natural.$wnaturalSignum"
        | [Integer
    i] <- [Value] -> [Integer]
    naturalLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    WordLiteral (Integer -> Integer
    forall a. Num a => a -> a
    signum Integer
    i)))
    #endif

      -- GHC.Real.^  -- XXX: Very fragile
      --   ^_f, $wf, $wf1 are specialisations of the internal function f in the implementation of (^) in GHC.Real
      Text
    "GHC.Real.^_f"  -- :: Integer -> Integer -> Integer
        | [Integer
    i,Integer
    j] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntegerLiteral (Integer -> Term) -> Integer -> Term
    forall a b. (a -> b) -> a -> b
    $ Integer
    i Integer -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^ Integer
    j)
      Text
    "GHC.Real.$wf"  -- :: Integer -> Int# -> Integer
        | [Value
    iV, Lit (IntLiteral Integer
    j)] <- [Value]
    args
        , [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value
    iV]
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntegerLiteral (Integer -> Term) -> Integer -> Term
    forall a b. (a -> b) -> a -> b
    $ Integer
    i Integer -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^ Integer
    j)
      Text
    "GHC.Real.$wf1" -- :: Int# -> Int# -> Int#
        | [Lit (IntLiteral Integer
    i), Lit (IntLiteral Integer
    j)] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntLiteral (Integer -> Term) -> Integer -> Term
    forall a b. (a -> b) -> a -> b
    $ Integer
    i Integer -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^ Integer
    j)

      -- Type level ^    -- XXX: Very fragile
      -- These is are specialized versions of ^_f, named by some combination of ghc and singletons.
      Text
    "Data.Singletons.TypeLits.Internal.$fSingI->^@#@$_f" -- ghc-8.6.5, singletons-2.5.1
        | [Integer
    i,Integer
    j] <- [Value] -> [Integer]
    naturalLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    i Integer -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^ Integer
    j)))
      Text
    "Data.Singletons.TypeLits.Internal.%^_f"             -- ghc-8.8.1, singletons-2.6
        | [Integer
    i,Integer
    j] <- [Value] -> [Integer]
    naturalLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    i Integer -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^ Integer
    j)))

      Text
    "GHC.TypeLits.natVal"
        | [Lit (NaturalLiteral Integer
    n), Value
    _] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntegerLiteral Integer
    n)

      Text
    "GHC.TypeNats.natVal"
        | [Lit (NaturalLiteral Integer
    n), Value
    _] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral Integer
    n))

      Text
    "GHC.TypeNats.someNatVal"
        | [Lit (NaturalLiteral Integer
    n)] <- [Value]
    args
        -> let resTy :: Type
    resTy = TyConMap -> Type -> [Type] -> Type
    getResultTy TyConMap
    tcm Type
    ty [Type]
    tys
            in Term -> Maybe Machine
    reduce (TyConMap -> Integer -> Type -> Term
    mkSomeNat TyConMap
    tcm Integer
    n Type
    resTy)

      Text
    "GHC.Types.I#"
        | Bool
    isSubj
        , [Lit (IntLiteral Integer
    i)] <- [Value]
    args
        ->  let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    intTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                (Just TyCon
    intTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    intTcNm TyConMap
    tcm
                [DataCon
    intDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    intTc
            in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    intDc) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral Integer
    i))])

      Text
    "GHC.Int.I8#"
        | Bool
    isSubj
    #if MIN_VERSION_base(4,16,0)
        , [Lit (Int8Literal Integer
    i)] <- [Value]
    args
    #else
        , [Lit (IntLiteral i)] <- args
    #endif
        ->  let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    intTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                (Just TyCon
    intTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    intTcNm TyConMap
    tcm
                [DataCon
    intDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    intTc
    #if MIN_VERSION_base(4,16,0)
            in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    intDc) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Int8Literal Integer
    i))])
    #else
            in  reduce (mkApps (Data intDc) [Left (Literal (IntLiteral i))])
    #endif
      Text
    "GHC.Int.I16#"
        | Bool
    isSubj
    #if MIN_VERSION_base(4,16,0)
        , [Lit (Int16Literal Integer
    i)] <- [Value]
    args
    #else
        , [Lit (IntLiteral i)] <- args
    #endif
        ->  let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    intTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                (Just TyCon
    intTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    intTcNm TyConMap
    tcm
                [DataCon
    intDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    intTc
    #if MIN_VERSION_base(4,16,0)
            in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    intDc) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Int16Literal Integer
    i))])
    #else
            in  reduce (mkApps (Data intDc) [Left (Literal (IntLiteral i))])
    #endif
      Text
    "GHC.Int.I32#"
        | Bool
    isSubj
    #if MIN_VERSION_base(4,16,0)
        , [Lit (Int32Literal Integer
    i)] <- [Value]
    args
    #else
        , [Lit (IntLiteral i)] <- args
    #endif
        ->  let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    intTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                (Just TyCon
    intTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    intTcNm TyConMap
    tcm
                [DataCon
    intDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    intTc
    #if MIN_VERSION_base(4,16,0)
            in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    intDc) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Int32Literal Integer
    i))])
    #else
            in  reduce (mkApps (Data intDc) [Left (Literal (IntLiteral i))])
    #endif
      Text
    "GHC.Int.I64#"
        | Bool
    isSubj
    #if MIN_VERSION_base(4,16,0)
        , [Lit (Int64Literal Integer
    i)] <- [Value]
    args
    #else
        , [Lit (IntLiteral i)] <- args
    #endif
        ->  let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    intTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                (Just TyCon
    intTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    intTcNm TyConMap
    tcm
                [DataCon
    intDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    intTc
    #if MIN_VERSION_base(4,16,0)
            in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    intDc) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Int64Literal Integer
    i))])
    #else
            in  reduce (mkApps (Data intDc) [Left (Literal (IntLiteral i))])
    #endif

      Text
    "GHC.Word.W8#"
        | Bool
    isSubj
    #if MIN_VERSION_base(4,16,0)
        , [Lit (Word8Literal Integer
    c)] <- [Value]
    args
    #else
        , [Lit (WordLiteral c)] <- args
    #endif
        ->  let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    wordTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                (Just TyCon
    wordTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    wordTcNm TyConMap
    tcm
                [DataCon
    wordDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    wordTc
    #if MIN_VERSION_base(4,16,0)
            in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    wordDc) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Word8Literal Integer
    c))])
    #else
            in  reduce (mkApps (Data wordDc) [Left (Literal (WordLiteral c))])
    #endif
      Text
    "GHC.Word.W16#"
        | Bool
    isSubj
    #if MIN_VERSION_base(4,16,0)
        , [Lit (Word16Literal Integer
    c)] <- [Value]
    args
    #else
        , [Lit (WordLiteral c)] <- args
    #endif
        ->  let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    wordTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                (Just TyCon
    wordTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    wordTcNm TyConMap
    tcm
                [DataCon
    wordDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    wordTc
    #if MIN_VERSION_base(4,16,0)
            in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    wordDc) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Word16Literal Integer
    c))])
    #else
            in  reduce (mkApps (Data wordDc) [Left (Literal (WordLiteral c))])
    #endif
      Text
    "GHC.Word.W32#"
        | Bool
    isSubj
    #if MIN_VERSION_base(4,16,0)
        , [Lit (Word32Literal Integer
    c)] <- [Value]
    args
    #else
        , [Lit (WordLiteral c)] <- args
    #endif
        ->  let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    wordTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                (Just TyCon
    wordTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    wordTcNm TyConMap
    tcm
                [DataCon
    wordDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    wordTc
    #if MIN_VERSION_base(4,16,0)
            in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    wordDc) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Word32Literal Integer
    c))])
    #else
            in  reduce (mkApps (Data wordDc) [Left (Literal (WordLiteral c))])
    #endif
      Text
    "GHC.Word.W64#"
        | Bool
    isSubj
    #if MIN_VERSION_base(4,16,0)
        , [Lit (Word64Literal Integer
    c)] <- [Value]
    args
    #else
        , [Lit (WordLiteral c)] <- args
    #endif
        ->  let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    wordTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                (Just TyCon
    wordTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    wordTcNm TyConMap
    tcm
                [DataCon
    wordDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    wordTc
    #if MIN_VERSION_base(4,16,0)
            in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    wordDc) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    Word64Literal Integer
    c))])
    #else
            in  reduce (mkApps (Data wordDc) [Left (Literal (WordLiteral c))])
    #endif

      Text
    "GHC.Types.W#"
        | Bool
    isSubj
        , [Lit (WordLiteral Integer
    i)] <- [Value]
    args
        ->  let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    intTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                (Just TyCon
    intTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    intTcNm TyConMap
    tcm
                [DataCon
    intDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    intTc
            in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    intDc) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    WordLiteral Integer
    i))])

      Text
    "GHC.Float.$w$sfromRat''" -- XXX: Very fragile
        | [Lit (IntLiteral Integer
    _minEx)
          ,Lit (IntLiteral Integer
    matDigs)
          ,Value
    nV
          ,Value
    dV] <- [Value]
    args
        , [Integer
    n,Integer
    d] <- [Value] -> [Integer]
    integerLiterals' [Value
    nV,Value
    dV]
        -> case Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    matDigs of
              Unique
    matDigs'
                | Unique
    matDigs' Unique -> Unique -> Bool
    forall a. Eq a => a -> a -> Bool
    == Float -> Unique
    forall a. RealFloat a => a -> Unique
    floatDigits (Float
    forall a. HasCallStack => a
    undefined :: Float)
                -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Word32 -> Literal
    FloatLiteral (Float -> Word32
    floatToWord (Rational -> Float
    forall a. Fractional a => Rational -> a
    fromRational (Integer
    n Integer -> Integer -> Rational
    forall a. a -> a -> Ratio a
    :% Integer
    d)))))
                | Unique
    matDigs' Unique -> Unique -> Bool
    forall a. Eq a => a -> a -> Bool
    == Double -> Unique
    forall a. RealFloat a => a -> Unique
    floatDigits (Double
    forall a. HasCallStack => a
    undefined :: Double)
                -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Word64 -> Literal
    DoubleLiteral (Double -> Word64
    doubleToWord (Rational -> Double
    forall a. Fractional a => Rational -> a
    fromRational (Integer
    n Integer -> Integer -> Rational
    forall a. a -> a -> Ratio a
    :% Integer
    d)))))
              Unique
    _ -> [Char] -> Maybe Machine
    forall a. HasCallStack => [Char] -> a
    error ([Char] -> Maybe Machine) -> [Char] -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ $(curLoc) [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "GHC.Float.$w$sfromRat'': Not a Float or Double"

      Text
    "GHC.Float.$w$sfromRat''1" -- XXX: Very fragile
        | [Lit (IntLiteral Integer
    _minEx)
          ,Lit (IntLiteral Integer
    matDigs)
          ,Value
    nV
          ,Value
    dV] <- [Value]
    args
        , [Integer
    n,Integer
    d] <- [Value] -> [Integer]
    integerLiterals' [Value
    nV,Value
    dV]
        -> case Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    matDigs of
              Unique
    matDigs'
                | Unique
    matDigs' Unique -> Unique -> Bool
    forall a. Eq a => a -> a -> Bool
    == Float -> Unique
    forall a. RealFloat a => a -> Unique
    floatDigits (Float
    forall a. HasCallStack => a
    undefined :: Float)
                -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Word32 -> Literal
    FloatLiteral (Float -> Word32
    floatToWord (Rational -> Float
    forall a. Fractional a => Rational -> a
    fromRational (Integer
    n Integer -> Integer -> Rational
    forall a. a -> a -> Ratio a
    :% Integer
    d)))))
                | Unique
    matDigs' Unique -> Unique -> Bool
    forall a. Eq a => a -> a -> Bool
    == Double -> Unique
    forall a. RealFloat a => a -> Unique
    floatDigits (Double
    forall a. HasCallStack => a
    undefined :: Double)
                -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Word64 -> Literal
    DoubleLiteral (Double -> Word64
    doubleToWord (Rational -> Double
    forall a. Fractional a => Rational -> a
    fromRational (Integer
    n Integer -> Integer -> Rational
    forall a. a -> a -> Ratio a
    :% Integer
    d)))))
              Unique
    _ -> [Char] -> Maybe Machine
    forall a. HasCallStack => [Char] -> a
    error ([Char] -> Maybe Machine) -> [Char] -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ $(curLoc) [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "GHC.Float.$w$sfromRat'': Not a Float or Double"

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerSignum#"
    #else
      "GHC.Integer.Type.$wsignumInteger" -- XXX: Not super-fragile, but still..
    #endif
        | [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Integer -> Integer
    forall a. Num a => a -> a
    signum Integer
    i)))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerSignum"
    #else
      "GHC.Integer.Type.signumInteger"
    #endif
        | [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral (Integer -> Integer
    signumInteger Integer
    i)))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.$wintegerSignum"
        | [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Integer -> Integer
    forall a. Num a => a -> a
    signum Integer
    i)))
    #endif

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerAbs"
    #else
      "GHC.Integer.Type.absInteger"
    #endif
        | [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral (Integer -> Integer
    absInteger Integer
    i)))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerBit#"
        | [Integer
    i] <- [Value] -> [Integer]
    wordLiterals' [Value]
    args
    #else
      "GHC.Integer.Type.bitInteger"
        | [i] <- intLiterals' args
    #endif
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral (Unique -> Integer
    forall a. Bits a => Unique -> a
    bit (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i))))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerComplement"
    #else
      "GHC.Integer.Type.complementInteger"
    #endif
        | [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral (Integer -> Integer
    complementInteger Integer
    i)))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerOr"
    #else
      "GHC.Integer.Type.orInteger"
    #endif
        | [Integer
    i, Integer
    j] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral (Integer -> Integer -> Integer
    orInteger Integer
    i Integer
    j)))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerXor"
    #else
      "GHC.Integer.Type.xorInteger"
    #endif
        | [Integer
    i, Integer
    j] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral (Integer -> Integer -> Integer
    xorInteger Integer
    i Integer
    j)))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerAnd"
    #else
      "GHC.Integer.Type.andInteger"
    #endif
        | [Integer
    i, Integer
    j] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral (Integer -> Integer -> Integer
    andInteger Integer
    i Integer
    j)))

    #if MIN_VERSION_base(4,15,0)
      Text
    "GHC.Num.Integer.integerToDouble#"
    #else
      "GHC.Integer.Type.doubleFromInteger"
    #endif
        | [Integer
    i] <- [Value] -> [Integer]
    integerLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Literal -> Term
    Literal (Word64 -> Literal
    DoubleLiteral (Double -> Word64
    doubleToWord (Integer -> Double
    forall a. Num a => Integer -> a
    fromInteger Integer
    i))))

    #if MIN_VERSION_base(4,17,0)
      Text
    "GHC.Num.Integer.$wintegerFromInt64#"
        | [Integer
    i] <- [Value] -> [Integer]
    int64Literals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine)
    -> (Literal -> Term) -> Literal -> Maybe Machine
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Literal -> Term
    Literal (Literal -> Maybe Machine) -> Literal -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Integer -> Literal
    IntLiteral Integer
    i
    #endif

      Text
    "GHC.Base.eqString"
        | [PrimVal PrimInfo
    _ [Type]
    _ [Lit (StringLiteral [Char]
    s1)]
          ,PrimVal PrimInfo
    _ [Type]
    _ [Lit (StringLiteral [Char]
    s2)]
          ] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty ([Char]
    s1 [Char] -> [Char] -> Bool
    forall a. Eq a => a -> a -> Bool
    == [Char]
    s2))
        | Bool
    otherwise -> [Char] -> Maybe Machine
    forall a. HasCallStack => [Char] -> a
    error ([Value] -> [Char]
    forall a. Show a => a -> [Char]
    show [Value]
    args)

      Text
    "GHC.Base.quotInt"
        | [ DC DataCon
    intDc [Left (Literal (IntLiteral Integer
    i))]
          , DC DataCon
    _     [Left (Literal (IntLiteral Integer
    j))]
          ] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Term -> Term
    App (DataCon -> Term
    Data DataCon
    intDc) (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `quot` Integer
    j))))

      Text
    "GHC.Base.remInt"
        | [ DC DataCon
    intDc [Left (Literal (IntLiteral Integer
    i))]
          , DC DataCon
    _     [Left (Literal (IntLiteral Integer
    j))]
          ] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Term -> Term
    App (DataCon -> Term
    Data DataCon
    intDc) (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `rem` Integer
    j))))

      Text
    "GHC.Base.divInt"
        | [ DC DataCon
    intDc [Left (Literal (IntLiteral Integer
    i))]
          , DC DataCon
    _     [Left (Literal (IntLiteral Integer
    j))]
          ] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Term -> Term
    App (DataCon -> Term
    Data DataCon
    intDc) (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `div` Integer
    j))))

      Text
    "GHC.Base.modInt"
        | [ DC DataCon
    intDc [Left (Literal (IntLiteral Integer
    i))]
          , DC DataCon
    _     [Left (Literal (IntLiteral Integer
    j))]
          ] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Term -> Term
    App (DataCon -> Term
    Data DataCon
    intDc) (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `mod` Integer
    j))))

      Text
    "Clash.Class.BitPack.Internal.packDouble#" -- :: Double -> BitVector 64
        | [DC DataCon
    _ [Left Term
    arg]] <- [Value]
    args
        , Evaluator
    eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
    Evaluator Step
    ghcStep Unwind
    ghcUnwind PrimStep
    ghcPrimStep PrimUnwind
    ghcPrimUnwind
        , mach2 :: Machine
    mach2@Machine{mStack :: Machine -> Stack
    mStack=[],mTerm :: Machine -> Term
    mTerm=Literal (DoubleLiteral Word64
    i)} <- Evaluator -> TyConMap -> Bool -> Machine -> Machine
    whnf Evaluator
    eval TyConMap
    tcm Bool
    True (Term -> Machine -> Machine
    setTerm Term
    arg (Machine -> Machine) -> Machine -> Machine
    forall a b. (a -> b) -> a -> b
    $ Machine -> Machine
    stackClear Machine
    mach)
        -> let resTyInfo :: (Type, Type, Integer)
    resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo TyConMap
    tcm Type
    ty [Type]
    tys
            in Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Machine
    mach2
                 { mStack :: Stack
    mStack = Machine -> Stack
    mStack Machine
    mach
                 , mTerm :: Term
    mTerm = (Type, Type, Integer) -> Integer -> Integer -> Term
    mkBitVectorLit' (Type, Type, Integer)
    resTyInfo Integer
    0 (BitVector 64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (BitVector 64 -> Integer) -> BitVector 64 -> Integer
    forall a b. (a -> b) -> a -> b
    $ (Word64 -> BitVector 64
    Word64 -> BitVector (BitSize Word64)
    forall a. BitPack a => a -> BitVector (BitSize a)
    pack :: Word64 -> BitVector 64) Word64
    i)
                 }

      Text
    "Clash.Class.BitPack.Internal.packFloat#" -- :: Float -> BitVector 32
        | [DC DataCon
    _ [Left Term
    arg]] <- [Value]
    args
        , Evaluator
    eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
    Evaluator Step
    ghcStep Unwind
    ghcUnwind PrimStep
    ghcPrimStep PrimUnwind
    ghcPrimUnwind
        , mach2 :: Machine
    mach2@Machine{mStack :: Machine -> Stack
    mStack=[],mTerm :: Machine -> Term
    mTerm=Literal (FloatLiteral Word32
    i)} <- Evaluator -> TyConMap -> Bool -> Machine -> Machine
    whnf Evaluator
    eval TyConMap
    tcm Bool
    True (Term -> Machine -> Machine
    setTerm Term
    arg (Machine -> Machine) -> Machine -> Machine
    forall a b. (a -> b) -> a -> b
    $ Machine -> Machine
    stackClear Machine
    mach)
        -> let resTyInfo :: (Type, Type, Integer)
    resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo TyConMap
    tcm Type
    ty [Type]
    tys
            in Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Machine
    mach2
                 { mStack :: Stack
    mStack = Machine -> Stack
    mStack Machine
    mach
                 , mTerm :: Term
    mTerm = (Type, Type, Integer) -> Integer -> Integer -> Term
    mkBitVectorLit' (Type, Type, Integer)
    resTyInfo Integer
    0 (BitVector 32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (BitVector 32 -> Integer) -> BitVector 32 -> Integer
    forall a b. (a -> b) -> a -> b
    $ (Word32 -> BitVector 32
    Word32 -> BitVector (BitSize Word32)
    forall a. BitPack a => a -> BitVector (BitSize a)
    pack :: Word32 -> BitVector 32) Word32
    i)
                 }

      Text
    "Clash.Class.BitPack.Internal.unpackFloat#"
        | [(Integer, Integer)
    i] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> let resTy :: Type
    resTy = TyConMap -> Type -> [Type] -> Type
    getResultTy TyConMap
    tcm Type
    ty [Type]
    tys
               val :: Word32
    val = BitVector (BitSize Word32) -> Word32
    forall a. BitPack a => BitVector (BitSize a) -> a
    unpack ((Integer, Integer) -> BitVector 32
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i :: BitVector 32)
            in Term -> Maybe Machine
    reduce (TyConMap -> Word32 -> Type -> Term
    mkFloatCLit TyConMap
    tcm Word32
    val Type
    resTy)

      Text
    "Clash.Class.BitPack.Internal.unpackDouble#"
        | [(Integer, Integer)
    i] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> let resTy :: Type
    resTy = TyConMap -> Type -> [Type] -> Type
    getResultTy TyConMap
    tcm Type
    ty [Type]
    tys
               val :: Word64
    val = BitVector (BitSize Word64) -> Word64
    forall a. BitPack a => BitVector (BitSize a) -> a
    unpack ((Integer, Integer) -> BitVector 64
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i :: BitVector 64)
            in Term -> Maybe Machine
    reduce (TyConMap -> Word64 -> Type -> Term
    mkDoubleCLit TyConMap
    tcm Word64
    val Type
    resTy)

      Text
    "Clash.Class.BitPack.Internal.xToBV"
        | Bool
    isSubj
        , Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -- The second argument to `xToBV` is always going to be suspended.
        -- See Note [Lazy primitives]
        , [ Value
    _, (Suspend Term
    arg) ] <- [Value]
    args
        , Evaluator
    eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
    Evaluator Step
    ghcStep Unwind
    ghcUnwind PrimStep
    ghcPrimStep PrimUnwind
    ghcPrimUnwind
        , mach1 :: Machine
    mach1@Machine{mStack :: Machine -> Stack
    mStack=[],mTerm :: Machine -> Term
    mTerm=Term
    argWHNF} <-
            Evaluator -> TyConMap -> Bool -> Machine -> Machine
    whnf Evaluator
    eval TyConMap
    tcm Bool
    True (Term -> Machine -> Machine
    setTerm Term
    arg (Machine -> Machine
    stackClear Machine
    mach))
        , let undefBitVector :: Maybe Machine
    undefBitVector =
                Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Machine
    mach1
                     { mStack :: Stack
    mStack = Machine -> Stack
    mStack Machine
    mach
                     , mTerm :: Term
    mTerm  = Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    ty Type
    nTy Integer
    kn (Unique -> Integer
    forall a. Bits a => Unique -> a
    bit (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    kn)Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1) Integer
    0
                     }
        -> case Term -> Either [Char] Term
    forall a. a -> Either [Char] a
    isX Term
    argWHNF of
             Left [Char]
    _ -> Maybe Machine
    undefBitVector
             Either [Char] Term
    _ -> case Term -> (Term, [Either Term Type])
    collectArgs Term
    argWHNF of
               (Prim PrimInfo
    p,[Either Term Type]
    _) | PrimInfo -> Text
    primName PrimInfo
    p Text -> [Text] -> Bool
    forall a. Eq a => a -> [a] -> Bool
    forall (t :: Type -> Type) a.
    (Foldable t, Eq a) =>
    a -> t a -> Bool
    `elem` [Text]
    undefinedXPrims -> Maybe Machine
    undefBitVector
               (Term, [Either Term Type])
    _ -> Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Machine
    mach1
                         { mStack :: Stack
    mStack = Machine -> Stack
    mStack Machine
    mach
                         , mTerm :: Term
    mTerm  = Term
    argWHNF
                         }

      -- expIndex#
      --   :: KnownNat m
      --   => Index m
      --   -> SNat n
      --   -> Index (n^m)
      Text
    "Clash.Class.Exp.expIndex#"
        | [Integer
    b] <- [Value] -> [Integer]
    indexLiterals' [Value]
    args
        , [(Type
    _mTy, Integer
    km), (Type
    _, Integer
    e)] <- TyConMap -> [Type] -> [(Type, Integer)]
    extractKnownNats TyConMap
    tcm [Type]
    tys
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkIndexLit Type
    ty (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    kmInteger -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^Integer
    e))) (Integer
    kmInteger -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^Integer
    e) (Integer
    bInteger -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^Integer
    e))

      -- expSigned#
      --   :: KnownNat m
      --   => Signed m
      --   -> SNat n
      --   -> Signed (n*m)
      Text
    "Clash.Class.Exp.expSigned#"
        | [Integer
    b] <- [Value] -> [Integer]
    signedLiterals' [Value]
    args
        , [(Type
    _mTy, Integer
    km), (Type
    _, Integer
    e)] <- TyConMap -> [Type] -> [(Type, Integer)]
    extractKnownNats TyConMap
    tcm [Type]
    tys
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    kmInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    *Integer
    e))) (Integer
    kmInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    *Integer
    e) (Integer
    bInteger -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^Integer
    e))

      -- expUnsigned#
      --   :: KnownNat m
      --   => Unsigned m
      --   -> SNat n
      --   -> Unsigned m
      Text
    "Clash.Class.Exp.expUnsigned#"
        | [Integer
    b] <- [Value] -> [Integer]
    unsignedLiterals' [Value]
    args
        , [(Type
    _mTy, Integer
    km), (Type
    _, Integer
    e)] <- TyConMap -> [Type] -> [(Type, Integer)]
    extractKnownNats TyConMap
    tcm [Type]
    tys
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    ty (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    kmInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    *Integer
    e))) (Integer
    kmInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    *Integer
    e) (Integer
    bInteger -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^Integer
    e))

      Text
    "Clash.Promoted.Nat.powSNat"
        | [Right Integer
    a, Right Integer
    b] <- (Type -> Either [Char] Integer)
    -> [Type] -> [Either [Char] Integer]
    forall a b. (a -> b) -> [a] -> [b]
    map (Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (Except [Char] Integer -> Either [Char] Integer)
    -> (Type -> Except [Char] Integer) -> Type -> Either [Char] Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm) [Type]
    tys
        -> let c :: Integer
    c = case Integer
    a of
                     Integer
    2 -> Integer
    1 Integer -> Unique -> Integer
    forall a. Bits a => a -> Unique -> a
    `shiftL` (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    b)
                     Integer
    _ -> Integer
    a Integer -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^ Integer
    b
               ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    snatTcNm [Type]
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    snatTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    snatTcNm TyConMap
    tcm
               [DataCon
    snatDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    snatTc
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    snatDc) [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy Integer
    c))
                                    , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral Integer
    c))]

      Text
    "Clash.Promoted.Nat.flogBaseSNat"
        | [Right Integer
    a, Right Integer
    b] <- (Type -> Either [Char] Integer)
    -> [Type] -> [Either [Char] Integer]
    forall a b. (a -> b) -> [a] -> [b]
    map (Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (Except [Char] Integer -> Either [Char] Integer)
    -> (Type -> Except [Char] Integer) -> Type -> Either [Char] Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm) [Type]
    tys
        , Just Unique
    c <- Integer -> Integer -> Maybe Unique
    flogBase Integer
    a Integer
    b
        , let c' :: Integer
    c' = Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger Unique
    c
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    snatTcNm [Type]
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    snatTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    snatTcNm TyConMap
    tcm
               [DataCon
    snatDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    snatTc
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    snatDc) [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy Integer
    c'))
                                    , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral Integer
    c'))]

      Text
    "Clash.Promoted.Nat.clogBaseSNat"
        | [Right Integer
    a, Right Integer
    b] <- (Type -> Either [Char] Integer)
    -> [Type] -> [Either [Char] Integer]
    forall a b. (a -> b) -> [a] -> [b]
    map (Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (Except [Char] Integer -> Either [Char] Integer)
    -> (Type -> Except [Char] Integer) -> Type -> Either [Char] Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm) [Type]
    tys
        , Just Unique
    c <- Integer -> Integer -> Maybe Unique
    clogBase Integer
    a Integer
    b
        , let c' :: Integer
    c' = Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger Unique
    c
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    snatTcNm [Type]
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    snatTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    snatTcNm TyConMap
    tcm
               [DataCon
    snatDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    snatTc
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    snatDc) [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy Integer
    c'))
                                    , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral Integer
    c'))]
        | Bool
    otherwise
        -> [Char] -> Maybe Machine
    forall a. HasCallStack => [Char] -> a
    error ([Char]
    "clogBaseSNat: args = " [Char] -> [Char] -> [Char]
    forall a. Semigroup a => a -> a -> a
    <> [Value] -> [Char]
    forall a. Show a => a -> [Char]
    show [Value]
    args [Char] -> [Char] -> [Char]
    forall a. Semigroup a => a -> a -> a
    <> [Char]
    ", tys = " [Char] -> [Char] -> [Char]
    forall a. Semigroup a => a -> a -> a
    <> [Type] -> [Char]
    forall a. Show a => a -> [Char]
    show [Type]
    tys)

      Text
    "Clash.Promoted.Nat.logBaseSNat"
        | [Right Integer
    a, Right Integer
    b] <- (Type -> Either [Char] Integer)
    -> [Type] -> [Either [Char] Integer]
    forall a b. (a -> b) -> [a] -> [b]
    map (Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (Except [Char] Integer -> Either [Char] Integer)
    -> (Type -> Except [Char] Integer) -> Type -> Either [Char] Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm) [Type]
    tys
        , Just Unique
    c <- Integer -> Integer -> Maybe Unique
    flogBase Integer
    a Integer
    b
        , let c' :: Integer
    c' = Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger Unique
    c
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    snatTcNm [Type]
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    snatTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    snatTcNm TyConMap
    tcm
               [DataCon
    snatDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    snatTc
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    snatDc) [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy Integer
    c'))
                                    , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral Integer
    c'))]

    ------------
    -- BitVector
    ------------
    -- Constructor
      Text
    "Clash.Sized.Internal.BitVector.BV"
        | [Right Integer
    _] <- (Type -> Either [Char] Integer)
    -> [Type] -> [Either [Char] Integer]
    forall a b. (a -> b) -> [a] -> [b]
    map (Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (Except [Char] Integer -> Either [Char] Integer)
    -> (Type -> Except [Char] Integer) -> Type -> Either [Char] Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm) [Type]
    tys
        , Just (Integer
    m,Integer
    i) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> let resTyInfo :: (Type, Type, Integer)
    resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo TyConMap
    tcm Type
    ty [Type]
    tys
           in  Term -> Maybe Machine
    reduce ((Type, Type, Integer) -> Integer -> Integer -> Term
    mkBitVectorLit' (Type, Type, Integer)
    resTyInfo Integer
    m Integer
    i)

      Text
    "Clash.Sized.Internal.BitVector.Bit"
        | Just (Integer
    m,Integer
    i) <- [Value] -> Maybe (Integer, Integer)
    integerLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Type -> Integer -> Integer -> Term
    mkBitLit Type
    ty Integer
    m Integer
    i)

    -- Initialisation
      Text
    "Clash.Sized.Internal.BitVector.size#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    intTcNm [Type]
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    intTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    intTcNm TyConMap
    tcm
               [DataCon
    intCon] = TyCon -> [DataCon]
    tyConDataCons TyCon
    intTc
           in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    intCon) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral Integer
    kn))])
      Text
    "Clash.Sized.Internal.BitVector.maxIndex#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    intTcNm [Type]
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    intTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    intTcNm TyConMap
    tcm
               [DataCon
    intCon] = TyCon -> [DataCon]
    tyConDataCons TyCon
    intTc
           in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    intCon) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Integer
    knInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))])

    -- Construction
      Text
    "Clash.Sized.Internal.BitVector.high"
        -> Term -> Maybe Machine
    reduce (Type -> Integer -> Integer -> Term
    mkBitLit Type
    ty Integer
    0 Integer
    1)
      Text
    "Clash.Sized.Internal.BitVector.low"
        -> Term -> Maybe Machine
    reduce (Type -> Integer -> Integer -> Term
    mkBitLit Type
    ty Integer
    0 Integer
    0)

      Text
    "Clash.Sized.Internal.BitVector.undefined#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> let resTyInfo :: (Type, Type, Integer)
    resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo TyConMap
    tcm Type
    ty [Type]
    tys
               mask :: Integer
    mask = Unique -> Integer
    forall a. Bits a => Unique -> a
    bit (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    kn) Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1
           in Term -> Maybe Machine
    reduce ((Type, Type, Integer) -> Integer -> Integer -> Term
    mkBitVectorLit' (Type, Type, Integer)
    resTyInfo Integer
    mask Integer
    0)

    -- Eq
      Text
    "Clash.Sized.Internal.BitVector.eq##" | [(Integer
    0,Integer
    i),(Integer
    0,Integer
    j)] <- [Value] -> [(Integer, Integer)]
    bitLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    j))
      Text
    "Clash.Sized.Internal.BitVector.neq##" | [(Integer
    0,Integer
    i),(Integer
    0,Integer
    j)] <- [Value] -> [(Integer, Integer)]
    bitLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    /= Integer
    j))

    -- Ord
      Text
    "Clash.Sized.Internal.BitVector.lt##" | [(Integer
    0,Integer
    i),(Integer
    0,Integer
    j)] <- [Value] -> [(Integer, Integer)]
    bitLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <  Integer
    j))
      Text
    "Clash.Sized.Internal.BitVector.ge##" | [(Integer
    0,Integer
    i),(Integer
    0,Integer
    j)] <- [Value] -> [(Integer, Integer)]
    bitLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Integer
    j))
      Text
    "Clash.Sized.Internal.BitVector.gt##" | [(Integer
    0,Integer
    i),(Integer
    0,Integer
    j)] <- [Value] -> [(Integer, Integer)]
    bitLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    >  Integer
    j))
      Text
    "Clash.Sized.Internal.BitVector.le##" | [(Integer
    0,Integer
    i),(Integer
    0,Integer
    j)] <- [Value] -> [(Integer, Integer)]
    bitLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <= Integer
    j))

    -- Enum
      Text
    "Clash.Sized.Internal.BitVector.toEnum##"
        | [Integer
    i] <- [Value] -> [Integer]
    intCLiterals' [Value]
    args
        -> let Bit Word
    msk Word
    val = Unique -> Bit
    BitVector.toEnum## (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i)
           in Term -> Maybe Machine
    reduce (Type -> Integer -> Integer -> Term
    mkBitLit Type
    ty (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    msk) (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    val))

    -- Bits
      Text
    "Clash.Sized.Internal.BitVector.and##"
        | [(Integer, Integer)
    i,(Integer, Integer)
    j] <- [Value] -> [(Integer, Integer)]
    bitLiterals [Value]
    args
        -> let Bit Word
    msk Word
    val = Bit -> Bit -> Bit
    BitVector.and## ((Integer, Integer) -> Bit
    toBit (Integer, Integer)
    i) ((Integer, Integer) -> Bit
    toBit (Integer, Integer)
    j)
           in Term -> Maybe Machine
    reduce (Type -> Integer -> Integer -> Term
    mkBitLit Type
    ty (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    msk) (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    val))
      Text
    "Clash.Sized.Internal.BitVector.or##"
        | [(Integer, Integer)
    i,(Integer, Integer)
    j] <- [Value] -> [(Integer, Integer)]
    bitLiterals [Value]
    args
        -> let Bit Word
    msk Word
    val = Bit -> Bit -> Bit
    BitVector.or## ((Integer, Integer) -> Bit
    toBit (Integer, Integer)
    i) ((Integer, Integer) -> Bit
    toBit (Integer, Integer)
    j)
           in Term -> Maybe Machine
    reduce (Type -> Integer -> Integer -> Term
    mkBitLit Type
    ty (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    msk) (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    val))
      Text
    "Clash.Sized.Internal.BitVector.xor##"
        | [(Integer, Integer)
    i,(Integer, Integer)
    j] <- [Value] -> [(Integer, Integer)]
    bitLiterals [Value]
    args
        -> let Bit Word
    msk Word
    val = Bit -> Bit -> Bit
    BitVector.xor## ((Integer, Integer) -> Bit
    toBit (Integer, Integer)
    i) ((Integer, Integer) -> Bit
    toBit (Integer, Integer)
    j)
           in Term -> Maybe Machine
    reduce (Type -> Integer -> Integer -> Term
    mkBitLit Type
    ty (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    msk) (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    val))

      Text
    "Clash.Sized.Internal.BitVector.complement##"
        | [(Integer, Integer)
    i] <- [Value] -> [(Integer, Integer)]
    bitLiterals [Value]
    args
        -> let Bit Word
    msk Word
    val = Bit -> Bit
    BitVector.complement## ((Integer, Integer) -> Bit
    toBit (Integer, Integer)
    i)
           in Term -> Maybe Machine
    reduce (Type -> Integer -> Integer -> Term
    mkBitLit Type
    ty (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    msk) (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    val))

    -- Pack
      Text
    "Clash.Sized.Internal.BitVector.pack#"
        | [(Integer
    msk,Integer
    i)] <- [Value] -> [(Integer, Integer)]
    bitLiterals [Value]
    args
        -> let resTyInfo :: (Type, Type, Integer)
    resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo TyConMap
    tcm Type
    ty [Type]
    tys
           in  Term -> Maybe Machine
    reduce ((Type, Type, Integer) -> Integer -> Integer -> Term
    mkBitVectorLit' (Type, Type, Integer)
    resTyInfo Integer
    msk Integer
    i)

      Text
    "Clash.Sized.Internal.BitVector.unpack#"
        | [(Integer
    msk,Integer
    i)] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Type -> Integer -> Integer -> Term
    mkBitLit Type
    ty Integer
    msk Integer
    i)

    -- Concatenation
      Text
    "Clash.Sized.Internal.BitVector.++#" -- :: KnownNat m => BitVector n -> BitVector m -> BitVector (n + m)
        | Just (Type
    _,Integer
    m) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [(Integer
    mski,Integer
    i),(Integer
    mskj,Integer
    j)] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> let val :: Integer
    val = Integer
    i Integer -> Unique -> Integer
    forall a. Bits a => a -> Unique -> a
    `shiftL` Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    m Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .|. Integer
    j
               msk :: Integer
    msk = Integer
    mski Integer -> Unique -> Integer
    forall a. Bits a => a -> Unique -> a
    `shiftL` Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    m Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .|. Integer
    mskj
               resTyInfo :: (Type, Type, Integer)
    resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo TyConMap
    tcm Type
    ty [Type]
    tys
           in Term -> Maybe Machine
    reduce ((Type, Type, Integer) -> Integer -> Integer -> Term
    mkBitVectorLit' (Type, Type, Integer)
    resTyInfo Integer
    msk Integer
    val)

    -- Reduction
      Text
    "Clash.Sized.Internal.BitVector.reduceAnd#" -- :: KnownNat n => BitVector n -> Bit
        | [(Integer, Integer)
    i] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        , Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> let resTy :: Type
    resTy = TyConMap -> Type -> [Type] -> Type
    getResultTy TyConMap
    tcm Type
    ty [Type]
    tys
               val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (BitVector n -> Proxy n -> Integer
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> Integer
    op ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i))
           in Term -> Maybe Machine
    reduce (Type -> Integer -> Integer -> Term
    mkBitLit Type
    resTy Integer
    0 Integer
    val)
        where
          op :: KnownNat n => BitVector n -> Proxy n -> Integer
          op :: forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> Integer
    op BitVector n
    u Proxy n
    _ = Bit -> Integer
    forall a. Integral a => a -> Integer
    toInteger (BitVector n -> Bit
    forall (n :: Natural). KnownNat n => BitVector n -> Bit
    BitVector.reduceAnd# BitVector n
    u)
      Text
    "Clash.Sized.Internal.BitVector.reduceOr#" -- :: KnownNat n => BitVector n -> Bit
        | [(Integer, Integer)
    i] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        , Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> let resTy :: Type
    resTy = TyConMap -> Type -> [Type] -> Type
    getResultTy TyConMap
    tcm Type
    ty [Type]
    tys
               val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (BitVector n -> Proxy n -> Integer
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> Integer
    op ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i))
           in Term -> Maybe Machine
    reduce (Type -> Integer -> Integer -> Term
    mkBitLit Type
    resTy Integer
    0 Integer
    val)
        where
          op :: KnownNat n => BitVector n -> Proxy n -> Integer
          op :: forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> Integer
    op BitVector n
    u Proxy n
    _ = Bit -> Integer
    forall a. Integral a => a -> Integer
    toInteger (BitVector n -> Bit
    forall (n :: Natural). KnownNat n => BitVector n -> Bit
    BitVector.reduceOr# BitVector n
    u)
      Text
    "Clash.Sized.Internal.BitVector.reduceXor#" -- :: KnownNat n => BitVector n -> Bit
        | [(Integer, Integer)
    i] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        , Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> let resTy :: Type
    resTy = TyConMap -> Type -> [Type] -> Type
    getResultTy TyConMap
    tcm Type
    ty [Type]
    tys
               val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (BitVector n -> Proxy n -> Integer
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> Integer
    op ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i))
           in Term -> Maybe Machine
    reduce (Type -> Integer -> Integer -> Term
    mkBitLit Type
    resTy Integer
    0 Integer
    val)
        where
          op :: KnownNat n => BitVector n -> Proxy n -> Integer
          op :: forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> Integer
    op BitVector n
    u Proxy n
    _ = Bit -> Integer
    forall a. Integral a => a -> Integer
    toInteger (BitVector n -> Bit
    forall (n :: Natural). KnownNat n => BitVector n -> Bit
    BitVector.reduceXor# BitVector n
    u)

    -- Indexing
      Text
    "Clash.Sized.Internal.BitVector.index#" -- :: KnownNat n => BitVector n -> Int -> Bit
        | Just (Type
    _,Integer
    kn,(Integer, Integer)
    i,Integer
    j) <- TyConMap
    -> [Type]
    -> [Value]
    -> Maybe (Type, Integer, (Integer, Integer), Integer)
    bitVectorLitIntLit TyConMap
    tcm [Type]
    tys [Value]
    args
          -> let resTy :: Type
    resTy = TyConMap -> Type -> [Type] -> Type
    getResultTy TyConMap
    tcm Type
    ty [Type]
    tys
                 (Integer
    msk,Integer
    val) = Integer
    -> (forall (n :: Natural).
        KnownNat n =>
        Proxy n -> (Integer, Integer))
    -> (Integer, Integer)
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (BitVector n -> Unique -> Proxy n -> (Integer, Integer)
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> Proxy n -> (Integer, Integer)
    op ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i) (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j))
             in Term -> Maybe Machine
    reduce (Type -> Integer -> Integer -> Term
    mkBitLit Type
    resTy Integer
    msk Integer
    val)
          where
            op :: KnownNat n => BitVector n -> Int -> Proxy n -> (Integer,Integer)
            op :: forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> Proxy n -> (Integer, Integer)
    op BitVector n
    u Unique
    i Proxy n
    _ = (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    m, Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    v)
              where Bit Word
    m Word
    v = (BitVector n -> Unique -> Bit
    forall (n :: Natural). KnownNat n => BitVector n -> Unique -> Bit
    BitVector.index# BitVector n
    u Unique
    i)
      Text
    "Clash.Sized.Internal.BitVector.replaceBit#" -- :: :: KnownNat n => BitVector n -> Int -> Bit -> BitVector n
        | Just (Type
    _, Integer
    n) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [ Value
    _
          , PrimVal PrimInfo
    bvP [Type]
    _ [Value
    _, Lit (NaturalLiteral Integer
    mskBv), Lit (IntegerLiteral Integer
    bv)]
          , Value -> Maybe [Term]
    valArgs -> Just [Literal (IntLiteral Integer
    i)]
          , PrimVal PrimInfo
    bP [Type]
    _ [Lit (WordLiteral Integer
    mskB), Lit (IntegerLiteral Integer
    b)]
          ] <- [Value]
    args
        , PrimInfo -> Text
    primName PrimInfo
    bvP Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    "Clash.Sized.Internal.BitVector.fromInteger#"
        , PrimInfo -> Text
    primName PrimInfo
    bP  Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    "Clash.Sized.Internal.BitVector.fromInteger##"
          -> let resTyInfo :: (Type, Type, Integer)
    resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo TyConMap
    tcm Type
    ty [Type]
    tys
                 (Integer
    mskVal,Integer
    val) = Integer
    -> (forall (n :: Natural).
        KnownNat n =>
        Proxy n -> (Integer, Integer))
    -> (Integer, Integer)
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    n (BitVector n -> Unique -> Bit -> Proxy n -> (Integer, Integer)
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> Bit -> Proxy n -> (Integer, Integer)
    op (Natural -> Natural -> BitVector n
    forall (n :: Natural). Natural -> Natural -> BitVector n
    BV (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger Integer
    mskBv) (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger Integer
    bv))
                                               (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    i)
                                               (Word -> Word -> Bit
    Bit (Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    mskB) (Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    b)))
          in Term -> Maybe Machine
    reduce ((Type, Type, Integer) -> Integer -> Integer -> Term
    mkBitVectorLit' (Type, Type, Integer)
    resTyInfo Integer
    mskVal Integer
    val)
          where
            op :: KnownNat n => BitVector n -> Int -> Bit -> Proxy n -> (Integer,Integer)
            -- op bv i b _ = (BitVector.unsafeMask res, BitVector.unsafeToInteger res)
            op :: forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> Bit -> Proxy n -> (Integer, Integer)
    op BitVector n
    bv Unique
    i Bit
    b Proxy n
    _ = BitVector n -> (Integer, Integer)
    forall (n :: Natural). BitVector n -> (Integer, Integer)
    splitBV (BitVector n -> Unique -> Bit -> BitVector n
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> Bit -> BitVector n
    BitVector.replaceBit# BitVector n
    bv Unique
    i Bit
    b)
      Text
    "Clash.Sized.Internal.BitVector.setSlice#"
      -- :: SNat (m+1+i) -> BitVector (m + 1 + i) -> SNat m -> SNat n -> BitVector (m + 1 - n) -> BitVector (m + 1 + i)
        | Type
    mTy : Type
    iTy : Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    m <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    mTy)
        , Right Integer
    iN <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    iTy)
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        , [(Integer, Integer)
    i,(Integer, Integer)
    j] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> let BV Natural
    msk Natural
    val = SNat ((Any + 1) + Any)
    -> BitVector ((Any + 1) + Any)
    -> SNat Any
    -> SNat Any
    -> BitVector ((Any + 1) - Any)
    -> BitVector ((Any + 1) + Any)
    forall (m :: Natural) (i :: Natural) (n :: Natural).
    SNat ((m + 1) + i)
    -> BitVector ((m + 1) + i)
    -> SNat m
    -> SNat n
    -> BitVector ((m + 1) - n)
    -> BitVector ((m + 1) + i)
    BitVector.setSlice# (Integer -> SNat ((Any + 1) + Any)
    forall (k :: Natural). Integer -> SNat k
    unsafeSNat (Integer
    mInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    +Integer
    1Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    +Integer
    iN)) ((Integer, Integer) -> BitVector ((Any + 1) + Any)
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i) (Integer -> SNat Any
    forall (k :: Natural). Integer -> SNat k
    unsafeSNat Integer
    m) (Integer -> SNat Any
    forall (k :: Natural). Integer -> SNat k
    unsafeSNat Integer
    n) ((Integer, Integer) -> BitVector ((Any + 1) - Any)
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    j)
               resTyInfo :: (Type, Type, Integer)
    resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo TyConMap
    tcm Type
    ty [Type]
    tys
           in  Term -> Maybe Machine
    reduce ((Type, Type, Integer) -> Integer -> Integer -> Term
    mkBitVectorLit' (Type, Type, Integer)
    resTyInfo (Natural -> Integer
    forall a. Integral a => a -> Integer
    toInteger Natural
    msk) (Natural -> Integer
    forall a. Integral a => a -> Integer
    toInteger Natural
    val))
      Text
    "Clash.Sized.Internal.BitVector.slice#"
      -- :: BitVector (m + 1 + i) -> SNat m -> SNat n -> BitVector (m + 1 - n)
        | Type
    mTy : Type
    _ : Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    m <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    mTy)
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        , [(Integer, Integer)
    i] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> let BV Natural
    msk Natural
    val = BitVector ((Any + 1) + Any)
    -> SNat Any -> SNat Any -> BitVector ((Any + 1) - Any)
    forall (m :: Natural) (i :: Natural) (n :: Natural).
    BitVector ((m + 1) + i)
    -> SNat m -> SNat n -> BitVector ((m + 1) - n)
    BitVector.slice# ((Integer, Integer) -> BitVector ((Any + 1) + Any)
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i) (Integer -> SNat Any
    forall (k :: Natural). Integer -> SNat k
    unsafeSNat Integer
    m) (Integer -> SNat Any
    forall (k :: Natural). Integer -> SNat k
    unsafeSNat Integer
    n)
               resTyInfo :: (Type, Type, Integer)
    resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo TyConMap
    tcm Type
    ty [Type]
    tys
           in  Term -> Maybe Machine
    reduce ((Type, Type, Integer) -> Integer -> Integer -> Term
    mkBitVectorLit' (Type, Type, Integer)
    resTyInfo (Natural -> Integer
    forall a. Integral a => a -> Integer
    toInteger Natural
    msk) (Natural -> Integer
    forall a. Integral a => a -> Integer
    toInteger Natural
    val))
      Text
    "Clash.Sized.Internal.BitVector.split#" -- :: forall n m. KnownNat n => BitVector (m + n) -> (BitVector m, BitVector n)
        | Type
    nTy : Type
    mTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    n <-  Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        , Right Integer
    m <-  Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    mTy)
        , [(Integer
    mski,Integer
    i)] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> let ty' :: Type
    ty' = HasCallStack => TyConMap -> Type -> [Type] -> Type
    TyConMap -> Type -> [Type] -> Type
    piResultTys TyConMap
    tcm Type
    ty [Type]
    tys
               ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty'
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               Type
    bvTy : [Type]
    _ = [Type]
    tyArgs
               valM :: Integer
    valM = Integer
    i Integer -> Unique -> Integer
    forall a. Bits a => a -> Unique -> a
    `shiftR` Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    n
               mskM :: Integer
    mskM = Integer
    mski Integer -> Unique -> Integer
    forall a. Bits a => a -> Unique -> a
    `shiftR` Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    n
               valN :: Integer
    valN = Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .&. Integer
    mask
               mskN :: Integer
    mskN = Integer
    mski Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .&. Integer
    mask
               mask :: Integer
    mask = Unique -> Integer
    forall a. Bits a => Unique -> a
    bit (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    n) Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1
        in Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
           Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                    [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    bvTy Type
    mTy Integer
    m Integer
    mskM Integer
    valM)
                    , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    bvTy Type
    nTy Integer
    n Integer
    mskN Integer
    valN)])

      Text
    "Clash.Sized.Internal.BitVector.msb#" -- :: forall n. KnownNat n => BitVector n -> Bit
        | [(Integer, Integer)
    i] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        , Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> let resTy :: Type
    resTy = TyConMap -> Type -> [Type] -> Type
    getResultTy TyConMap
    tcm Type
    ty [Type]
    tys
               (Word
    msk,Word
    val) = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> (Word, Word))
    -> (Word, Word)
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (BitVector n -> Proxy n -> (Word, Word)
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> (Word, Word)
    op ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i))
           in Term -> Maybe Machine
    reduce (Type -> Integer -> Integer -> Term
    mkBitLit Type
    resTy (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    msk) (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    val))
        where
          op :: KnownNat n => BitVector n -> Proxy n -> (Word,Word)
          op :: forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> (Word, Word)
    op BitVector n
    u Proxy n
    _ = (Bit -> Word
    unsafeMask# Bit
    res, Bit -> Word
    BitVector.unsafeToInteger# Bit
    res)
            where
              res :: Bit
    res = BitVector n -> Bit
    forall (n :: Natural). KnownNat n => BitVector n -> Bit
    BitVector.msb# BitVector n
    u
      Text
    "Clash.Sized.Internal.BitVector.lsb#" -- :: BitVector n -> Bit
        | [(Integer, Integer)
    i] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> let resTy :: Type
    resTy = TyConMap -> Type -> [Type] -> Type
    getResultTy TyConMap
    tcm Type
    ty [Type]
    tys
               Bit Word
    msk Word
    val = BitVector Any -> Bit
    forall (n :: Natural). BitVector n -> Bit
    BitVector.lsb# ((Integer, Integer) -> BitVector Any
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i)
        in Term -> Maybe Machine
    reduce (Type -> Integer -> Integer -> Term
    mkBitLit Type
    resTy (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    msk) (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    val))

    -- Eq
      -- eq#, neq# :: KnownNat n => BitVector n -> BitVector n -> Bool
      Text
    "Clash.Sized.Internal.BitVector.eq#"
        | Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    0 <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty Bool
    True)
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((BitVector n -> BitVector n -> Bool)
    -> Type -> TyConMap -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (BitVector n -> BitVector n -> Bool)
    -> Type -> TyConMap -> [Value] -> Proxy n -> Maybe Term
    liftBitVector2Bool BitVector n -> BitVector n -> Bool
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> BitVector n -> Bool
    BitVector.eq# Type
    ty TyConMap
    tcm [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val

      Text
    "Clash.Sized.Internal.BitVector.neq#"
        | Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    0 <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty Bool
    False)
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((BitVector n -> BitVector n -> Bool)
    -> Type -> TyConMap -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (BitVector n -> BitVector n -> Bool)
    -> Type -> TyConMap -> [Value] -> Proxy n -> Maybe Term
    liftBitVector2Bool BitVector n -> BitVector n -> Bool
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> BitVector n -> Bool
    BitVector.neq# Type
    ty TyConMap
    tcm [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val

    -- Ord
      -- lt#,ge#,gt#,le# :: KnownNat n => BitVector n -> BitVector n -> Bool
      Text
    "Clash.Sized.Internal.BitVector.lt#"
        | Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    0 <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty Bool
    False)
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((BitVector n -> BitVector n -> Bool)
    -> Type -> TyConMap -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (BitVector n -> BitVector n -> Bool)
    -> Type -> TyConMap -> [Value] -> Proxy n -> Maybe Term
    liftBitVector2Bool BitVector n -> BitVector n -> Bool
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> BitVector n -> Bool
    BitVector.lt# Type
    ty TyConMap
    tcm [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val
      Text
    "Clash.Sized.Internal.BitVector.ge#"
        | Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    0 <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty Bool
    True)
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((BitVector n -> BitVector n -> Bool)
    -> Type -> TyConMap -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (BitVector n -> BitVector n -> Bool)
    -> Type -> TyConMap -> [Value] -> Proxy n -> Maybe Term
    liftBitVector2Bool BitVector n -> BitVector n -> Bool
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> BitVector n -> Bool
    BitVector.ge# Type
    ty TyConMap
    tcm [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val
      Text
    "Clash.Sized.Internal.BitVector.gt#"
        | Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    0 <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty Bool
    False)
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((BitVector n -> BitVector n -> Bool)
    -> Type -> TyConMap -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (BitVector n -> BitVector n -> Bool)
    -> Type -> TyConMap -> [Value] -> Proxy n -> Maybe Term
    liftBitVector2Bool BitVector n -> BitVector n -> Bool
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> BitVector n -> Bool
    BitVector.gt# Type
    ty TyConMap
    tcm [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val
      Text
    "Clash.Sized.Internal.BitVector.le#"
        | Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    0 <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty Bool
    True)
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((BitVector n -> BitVector n -> Bool)
    -> Type -> TyConMap -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (BitVector n -> BitVector n -> Bool)
    -> Type -> TyConMap -> [Value] -> Proxy n -> Maybe Term
    liftBitVector2Bool BitVector n -> BitVector n -> Bool
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> BitVector n -> Bool
    BitVector.le# Type
    ty TyConMap
    tcm [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val

    -- Enum

      Text
    "Clash.Sized.Internal.BitVector.toEnum#"
        | let resTyInfo :: (Type, Type, Integer)
    resTyInfo@(Type
    _,Type
    _,Integer
    kn) = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo TyConMap
    tcm Type
    ty [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((Integer -> BitVector n)
    -> (Type, Type, Integer) -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (Integer -> BitVector n)
    -> (Type, Type, Integer) -> [Value] -> Proxy n -> Maybe Term
    liftInteger2BitVector (Unique -> BitVector n
    forall (n :: Natural). KnownNat n => Unique -> BitVector n
    BitVector.toEnum# (Unique -> BitVector n)
    -> (Integer -> Unique) -> Integer -> BitVector n
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger) (Type, Type, Integer)
    resTyInfo [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val

      Text
    "Clash.Sized.Internal.BitVector.fromEnum#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , let resTy :: Type
    resTy = TyConMap -> Type -> [Type] -> Type
    getResultTy TyConMap
    tcm Type
    ty [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (TyConMap
    -> Type
    -> (BitVector n -> Integer)
    -> [Value]
    -> Proxy n
    -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    TyConMap
    -> Type
    -> (BitVector n -> Integer)
    -> [Value]
    -> Proxy n
    -> Maybe Term
    liftBitVector2CInt TyConMap
    tcm Type
    resTy (Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer)
    -> (BitVector n -> Unique) -> BitVector n -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . BitVector n -> Unique
    forall (n :: Natural). KnownNat n => BitVector n -> Unique
    BitVector.fromEnum#) [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val

    -- Bounded
      Text
    "Clash.Sized.Internal.BitVector.minBound#"
        | Just (Type
    nTy,Integer
    len) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    ty Type
    nTy Integer
    len Integer
    0 Integer
    0)
      Text
    "Clash.Sized.Internal.BitVector.maxBound#"
        | Just (Type
    litTy,Integer
    mb) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> let maxB :: Integer
    maxB = (Integer
    2 Integer -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^ Integer
    mb) Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1
           in  Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    ty Type
    litTy Integer
    mb Integer
    0 Integer
    maxB)

    -- Num
      Text
    "Clash.Sized.Internal.BitVector.+#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftBitVector2 BitVector n -> BitVector n -> BitVector n
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> BitVector n -> BitVector n
    (BitVector.+#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val
      Text
    "Clash.Sized.Internal.BitVector.-#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftBitVector2 BitVector n -> BitVector n -> BitVector n
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> BitVector n -> BitVector n
    (BitVector.-#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val
      Text
    "Clash.Sized.Internal.BitVector.*#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftBitVector2 BitVector n -> BitVector n -> BitVector n
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> BitVector n -> BitVector n
    (BitVector.*#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val
      Text
    "Clash.Sized.Internal.BitVector.negate#"
        | Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [(Integer, Integer)
    i] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> let (Integer
    msk,Integer
    val) = Integer
    -> (forall (n :: Natural).
        KnownNat n =>
        Proxy n -> (Integer, Integer))
    -> (Integer, Integer)
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (BitVector n -> Proxy n -> (Integer, Integer)
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> (Integer, Integer)
    op ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i))
        in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    ty Type
    nTy Integer
    kn Integer
    msk Integer
    val)
        where
          op :: KnownNat n => BitVector n -> Proxy n -> (Integer,Integer)
          op :: forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> (Integer, Integer)
    op BitVector n
    u Proxy n
    _ = BitVector n -> (Integer, Integer)
    forall (n :: Natural). BitVector n -> (Integer, Integer)
    splitBV (BitVector n -> BitVector n
    forall (n :: Natural). KnownNat n => BitVector n -> BitVector n
    BitVector.negate# BitVector n
    u)

    -- ExtendingNum
      Text
    "Clash.Sized.Internal.BitVector.plus#" -- :: (KnownNat n, KnownNat m) => BitVector m -> BitVector n -> BitVector (Max m n + 1)
        | [(Integer
    0,Integer
    i),(Integer
    0,Integer
    j)] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> let ty' :: Type
    ty' = HasCallStack => TyConMap -> Type -> [Type] -> Type
    TyConMap -> Type -> [Type] -> Type
    piResultTys TyConMap
    tcm Type
    ty [Type]
    tys
               ([Either TyVar Type]
    _,Type
    resTy) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty'
               (TyConApp TyConName
    _ [Type
    resSizeTy]) = Type -> TypeView
    tyView Type
    resTy
               Right Integer
    resSizeInt = Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    resSizeTy)
           in  Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    resTy Type
    resSizeTy Integer
    resSizeInt Integer
    0 (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    +Integer
    j))

      Text
    "Clash.Sized.Internal.BitVector.minus#"
        | [(Integer
    0,Integer
    i),(Integer
    0,Integer
    j)] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> let ty' :: Type
    ty' = HasCallStack => TyConMap -> Type -> [Type] -> Type
    TyConMap -> Type -> [Type] -> Type
    piResultTys TyConMap
    tcm Type
    ty [Type]
    tys
               ([Either TyVar Type]
    _,Type
    resTy) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty'
               (TyConApp TyConName
    _ [Type
    resSizeTy]) = Type -> TypeView
    tyView Type
    resTy
               Right Integer
    resSizeInt = Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    resSizeTy)
               val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    resSizeInt ((BitVector n -> BitVector n -> BitVector n)
    -> Integer -> Integer -> Proxy n -> Integer
    forall (n :: Natural) (sized :: Natural -> Type).
    (KnownNat n, Integral (sized n)) =>
    (sized n -> sized n -> sized n)
    -> Integer -> Integer -> Proxy n -> Integer
    runSizedF BitVector n -> BitVector n -> BitVector n
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> BitVector n -> BitVector n
    (BitVector.-#) Integer
    i Integer
    j)
          in  Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    resTy Type
    resSizeTy Integer
    resSizeInt Integer
    0 Integer
    val)

      Text
    "Clash.Sized.Internal.BitVector.times#"
        | [(Integer
    0,Integer
    i),(Integer
    0,Integer
    j)] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> let ty' :: Type
    ty' = HasCallStack => TyConMap -> Type -> [Type] -> Type
    TyConMap -> Type -> [Type] -> Type
    piResultTys TyConMap
    tcm Type
    ty [Type]
    tys
               ([Either TyVar Type]
    _,Type
    resTy) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty'
               (TyConApp TyConName
    _ [Type
    resSizeTy]) = Type -> TypeView
    tyView Type
    resTy
               Right Integer
    resSizeInt = Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    resSizeTy)
           in  Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    resTy Type
    resSizeTy Integer
    resSizeInt Integer
    0 (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    *Integer
    j))

    -- Integral
      Text
    "Clash.Sized.Internal.BitVector.quot#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftBitVector2 (BitVector n -> BitVector n -> BitVector n
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> BitVector n -> BitVector n
    BitVector.quot#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero Term
    val
      Text
    "Clash.Sized.Internal.BitVector.rem#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftBitVector2 (BitVector n -> BitVector n -> BitVector n
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> BitVector n -> BitVector n
    BitVector.rem#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero Term
    val
      Text
    "Clash.Sized.Internal.BitVector.toInteger#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [(Integer, Integer)
    i] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (BitVector n -> Proxy n -> Integer
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> Integer
    op ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i))
        in Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntegerLiteral Integer
    val)
        where
          op :: KnownNat n => BitVector n -> Proxy n -> Integer
          op :: forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> Integer
    op BitVector n
    u Proxy n
    _ = BitVector n -> Integer
    forall (n :: Natural). KnownNat n => BitVector n -> Integer
    BitVector.toInteger# BitVector n
    u

    -- Bits
      Text
    "Clash.Sized.Internal.BitVector.and#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftBitVector2 (BitVector n -> BitVector n -> BitVector n
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> BitVector n -> BitVector n
    BitVector.and#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val
      Text
    "Clash.Sized.Internal.BitVector.or#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftBitVector2 (BitVector n -> BitVector n -> BitVector n
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> BitVector n -> BitVector n
    BitVector.or#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val
      Text
    "Clash.Sized.Internal.BitVector.xor#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftBitVector2 (BitVector n -> BitVector n -> BitVector n
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> BitVector n -> BitVector n
    BitVector.xor#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val

      Text
    "Clash.Sized.Internal.BitVector.complement#"
        | [(Integer, Integer)
    i] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        , Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> let (Integer
    msk,Integer
    val) = Integer
    -> (forall (n :: Natural).
        KnownNat n =>
        Proxy n -> (Integer, Integer))
    -> (Integer, Integer)
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (BitVector n -> Proxy n -> (Integer, Integer)
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> (Integer, Integer)
    op ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i))
        in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    ty Type
    nTy Integer
    kn Integer
    msk Integer
    val)
        where
          op :: KnownNat n => BitVector n -> Proxy n -> (Integer,Integer)
          op :: forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> (Integer, Integer)
    op BitVector n
    u Proxy n
    _ = BitVector n -> (Integer, Integer)
    forall (n :: Natural). BitVector n -> (Integer, Integer)
    splitBV (BitVector n -> (Integer, Integer))
    -> BitVector n -> (Integer, Integer)
    forall a b. (a -> b) -> a -> b
    $ BitVector n -> BitVector n
    forall (n :: Natural). KnownNat n => BitVector n -> BitVector n
    BitVector.complement# BitVector n
    u

      Text
    "Clash.Sized.Internal.BitVector.shiftL#"
        | Just (Type
    nTy,Integer
    kn,(Integer, Integer)
    i,Integer
    j) <- TyConMap
    -> [Type]
    -> [Value]
    -> Maybe (Type, Integer, (Integer, Integer), Integer)
    bitVectorLitIntLit TyConMap
    tcm [Type]
    tys [Value]
    args
          -> let (Integer
    msk,Integer
    val) = Integer
    -> (forall (n :: Natural).
        KnownNat n =>
        Proxy n -> (Integer, Integer))
    -> (Integer, Integer)
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (BitVector n -> Unique -> Proxy n -> (Integer, Integer)
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> Proxy n -> (Integer, Integer)
    op ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i) (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j))
          in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    ty Type
    nTy Integer
    kn Integer
    msk Integer
    val)
          where
            op :: KnownNat n => BitVector n -> Int -> Proxy n -> (Integer,Integer)
            op :: forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> Proxy n -> (Integer, Integer)
    op BitVector n
    u Unique
    i Proxy n
    _ = BitVector n -> (Integer, Integer)
    forall (n :: Natural). BitVector n -> (Integer, Integer)
    splitBV (BitVector n -> Unique -> BitVector n
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> BitVector n
    BitVector.shiftL# BitVector n
    u Unique
    i)
      Text
    "Clash.Sized.Internal.BitVector.shiftR#"
        | Just (Type
    nTy,Integer
    kn,(Integer, Integer)
    i,Integer
    j) <- TyConMap
    -> [Type]
    -> [Value]
    -> Maybe (Type, Integer, (Integer, Integer), Integer)
    bitVectorLitIntLit TyConMap
    tcm [Type]
    tys [Value]
    args
          -> let (Integer
    msk,Integer
    val) = Integer
    -> (forall (n :: Natural).
        KnownNat n =>
        Proxy n -> (Integer, Integer))
    -> (Integer, Integer)
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (BitVector n -> Unique -> Proxy n -> (Integer, Integer)
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> Proxy n -> (Integer, Integer)
    op ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i) (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j))
          in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    ty Type
    nTy Integer
    kn Integer
    msk Integer
    val)
          where
            op :: KnownNat n => BitVector n -> Int -> Proxy n -> (Integer,Integer)
            op :: forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> Proxy n -> (Integer, Integer)
    op BitVector n
    u Unique
    i Proxy n
    _ = BitVector n -> (Integer, Integer)
    forall (n :: Natural). BitVector n -> (Integer, Integer)
    splitBV (BitVector n -> Unique -> BitVector n
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> BitVector n
    BitVector.shiftR# BitVector n
    u Unique
    i)
      Text
    "Clash.Sized.Internal.BitVector.rotateL#"
        | Just (Type
    nTy,Integer
    kn,(Integer, Integer)
    i,Integer
    j) <- TyConMap
    -> [Type]
    -> [Value]
    -> Maybe (Type, Integer, (Integer, Integer), Integer)
    bitVectorLitIntLit TyConMap
    tcm [Type]
    tys [Value]
    args
          -> let (Integer
    msk,Integer
    val) = Integer
    -> (forall (n :: Natural).
        KnownNat n =>
        Proxy n -> (Integer, Integer))
    -> (Integer, Integer)
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (BitVector n -> Unique -> Proxy n -> (Integer, Integer)
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> Proxy n -> (Integer, Integer)
    op ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i) (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j))
          in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    ty Type
    nTy Integer
    kn Integer
    msk Integer
    val)
          where
            op :: KnownNat n => BitVector n -> Int -> Proxy n -> (Integer,Integer)
            op :: forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> Proxy n -> (Integer, Integer)
    op BitVector n
    u Unique
    i Proxy n
    _ = BitVector n -> (Integer, Integer)
    forall (n :: Natural). BitVector n -> (Integer, Integer)
    splitBV (BitVector n -> Unique -> BitVector n
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> BitVector n
    BitVector.rotateL# BitVector n
    u Unique
    i)
      Text
    "Clash.Sized.Internal.BitVector.rotateR#"
        | Just (Type
    nTy,Integer
    kn,(Integer, Integer)
    i,Integer
    j) <- TyConMap
    -> [Type]
    -> [Value]
    -> Maybe (Type, Integer, (Integer, Integer), Integer)
    bitVectorLitIntLit TyConMap
    tcm [Type]
    tys [Value]
    args
          -> let (Integer
    msk,Integer
    val) = Integer
    -> (forall (n :: Natural).
        KnownNat n =>
        Proxy n -> (Integer, Integer))
    -> (Integer, Integer)
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (BitVector n -> Unique -> Proxy n -> (Integer, Integer)
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> Proxy n -> (Integer, Integer)
    op ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i) (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j))
          in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    ty Type
    nTy Integer
    kn Integer
    msk Integer
    val)
          where
            op :: KnownNat n => BitVector n -> Int -> Proxy n -> (Integer,Integer)
            op :: forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> Proxy n -> (Integer, Integer)
    op BitVector n
    u Unique
    i Proxy n
    _ = BitVector n -> (Integer, Integer)
    forall (n :: Natural). BitVector n -> (Integer, Integer)
    splitBV (BitVector n -> Unique -> BitVector n
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Unique -> BitVector n
    BitVector.rotateR# BitVector n
    u Unique
    i)

    -- truncateB
      Text
    "Clash.Sized.Internal.BitVector.truncateB#" -- forall a b . KnownNat a => BitVector (a + b) -> BitVector a
        | Type
    aTy  : [Type]
    _ <- [Type]
    tys
        , Right Integer
    ka <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    aTy)
        , [(Integer
    mski,Integer
    i)] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> let bitsKeep :: Integer
    bitsKeep = (Unique -> Integer
    forall a. Bits a => Unique -> a
    bit (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    ka)) Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1
               val :: Integer
    val = Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .&. Integer
    bitsKeep
               msk :: Integer
    msk = Integer
    mski Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .&. Integer
    bitsKeep
        in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    ty Type
    aTy Integer
    ka Integer
    msk Integer
    val)

    --------
    -- Index
    --------
    -- BitPack
      Text
    "Clash.Sized.Internal.Index.pack#"
        | Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    _ <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        , [Integer
    i] <- [Value] -> [Integer]
    indexLiterals' [Value]
    args
        -> let resTyInfo :: (Type, Type, Integer)
    resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo TyConMap
    tcm Type
    ty [Type]
    tys
           in  Term -> Maybe Machine
    reduce ((Type, Type, Integer) -> Integer -> Integer -> Term
    mkBitVectorLit' (Type, Type, Integer)
    resTyInfo Integer
    0 Integer
    i)
      Text
    "Clash.Sized.Internal.Index.unpack#"
        | Just (Type
    nTy,Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [(Integer
    0,Integer
    i)] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkIndexLit Type
    ty Type
    nTy Integer
    kn Integer
    i)

    -- Eq
      Text
    "Clash.Sized.Internal.Index.eq#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    indexLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    j))
      Text
    "Clash.Sized.Internal.Index.neq#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    indexLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    /= Integer
    j))

    -- Ord
      Text
    "Clash.Sized.Internal.Index.lt#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    indexLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    < Integer
    j))
      Text
    "Clash.Sized.Internal.Index.ge#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    indexLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Integer
    j))
      Text
    "Clash.Sized.Internal.Index.gt#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    indexLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    > Integer
    j))
      Text
    "Clash.Sized.Internal.Index.le#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    indexLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <= Integer
    j))

    -- Enum
      Text
    "Clash.Sized.Internal.Index.toEnum#"
        | [Integer
    i] <- [Value] -> [Integer]
    intCLiterals' [Value]
    args
        , Just (Type
    nTy, Integer
    mb) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkIndexLit Type
    ty Type
    nTy Integer
    mb Integer
    i)

      Text
    "Clash.Sized.Internal.Index.fromEnum#"
        | [Integer
    i] <- [Value] -> [Integer]
    indexLiterals' [Value]
    args
        -> let resTy :: Type
    resTy = TyConMap -> Type -> [Type] -> Type
    getResultTy TyConMap
    tcm Type
    ty [Type]
    tys
            in Term -> Maybe Machine
    reduce (TyConMap -> Integer -> Type -> Term
    mkIntCLit TyConMap
    tcm Integer
    i Type
    resTy)

    -- Bounded
      Text
    "Clash.Sized.Internal.Index.maxBound#"
        | Just (Type
    nTy,Integer
    mb) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkIndexLit Type
    ty Type
    nTy Integer
    mb (Integer
    mb Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1))

    -- Num
      Text
    "Clash.Sized.Internal.Index.+#"
        | Just (Type
    nTy,Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [Integer
    i,Integer
    j] <- [Value] -> [Integer]
    indexLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkIndexLit Type
    ty Type
    nTy Integer
    kn (Integer
    i Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    + Integer
    j))
      Text
    "Clash.Sized.Internal.Index.-#"
        | Just (Type
    nTy,Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [Integer
    i,Integer
    j] <- [Value] -> [Integer]
    indexLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkIndexLit Type
    ty Type
    nTy Integer
    kn (Integer
    i Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    j))
      Text
    "Clash.Sized.Internal.Index.*#"
        | Just (Type
    nTy,Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [Integer
    i,Integer
    j] <- [Value] -> [Integer]
    indexLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkIndexLit Type
    ty Type
    nTy Integer
    kn (Integer
    i Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    * Integer
    j))

    -- ExtendingNum
      Text
    "Clash.Sized.Internal.Index.plus#"
        | Type
    mTy : Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    _ <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    mTy)
        , Right Integer
    _ <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        , Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    indexLiterals [Value]
    args
        -> let resTyInfo :: (Type, Type, Integer)
    resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo TyConMap
    tcm Type
    ty [Type]
    tys
           in  Term -> Maybe Machine
    reduce ((Type, Type, Integer) -> Integer -> Term
    mkIndexLit' (Type, Type, Integer)
    resTyInfo (Integer
    i Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    + Integer
    j))
      Text
    "Clash.Sized.Internal.Index.minus#"
        | Type
    mTy : Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    _ <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    mTy)
        , Right Integer
    _ <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        , Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    indexLiterals [Value]
    args
        -> let resTyInfo :: (Type, Type, Integer)
    resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo TyConMap
    tcm Type
    ty [Type]
    tys
           in  Term -> Maybe Machine
    reduce ((Type, Type, Integer) -> Integer -> Term
    mkIndexLit' (Type, Type, Integer)
    resTyInfo (Integer
    i Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    j))
      Text
    "Clash.Sized.Internal.Index.times#"
        | Type
    mTy : Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    _ <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    mTy)
        , Right Integer
    _ <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        , Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    indexLiterals [Value]
    args
        -> let resTyInfo :: (Type, Type, Integer)
    resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo TyConMap
    tcm Type
    ty [Type]
    tys
           in  Term -> Maybe Machine
    reduce ((Type, Type, Integer) -> Integer -> Term
    mkIndexLit' (Type, Type, Integer)
    resTyInfo (Integer
    i Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    * Integer
    j))

    -- Integral
      Text
    "Clash.Sized.Internal.Index.quot#"
        | Just (Type
    nTy,Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    indexLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Type -> Type -> Integer -> Integer -> Term
    mkIndexLit Type
    ty Type
    nTy Integer
    kn (Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `quot` Integer
    j))
      Text
    "Clash.Sized.Internal.Index.rem#"
        | Just (Type
    nTy,Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    indexLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero (Type -> Type -> Integer -> Integer -> Term
    mkIndexLit Type
    ty Type
    nTy Integer
    kn (Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `rem` Integer
    j))
      Text
    "Clash.Sized.Internal.Index.toInteger#"
        | [PrimVal PrimInfo
    p [Type]
    _ [Value
    _, Lit (IntegerLiteral Integer
    i)]] <- [Value]
    args
        , PrimInfo -> Text
    primName PrimInfo
    p Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    "Clash.Sized.Internal.Index.fromInteger#"
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntegerLiteral Integer
    i)

    -- Resize
      Text
    "Clash.Sized.Internal.Index.resize#"
        | Just (Type
    mTy,Integer
    m) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [Integer
    i] <- [Value] -> [Integer]
    indexLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkIndexLit Type
    ty Type
    mTy Integer
    m Integer
    i)

    ---------
    -- Signed
    ---------
      Text
    "Clash.Sized.Internal.Signed.size#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    intTcNm [Type]
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    intTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    intTcNm TyConMap
    tcm
               [DataCon
    intCon] = TyCon -> [DataCon]
    tyConDataCons TyCon
    intTc
           in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    intCon) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral Integer
    kn))])

    -- BitPack
      Text
    "Clash.Sized.Internal.Signed.pack#"
        | Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [Integer
    i] <- [Value] -> [Integer]
    signedLiterals' [Value]
    args
        -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (Signed n -> Proxy n -> Integer
    forall (n :: Natural). KnownNat n => Signed n -> Proxy n -> Integer
    op (Integer -> Signed n
    forall a. Num a => Integer -> a
    fromInteger Integer
    i))
           in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    ty Type
    nTy Integer
    kn Integer
    0 Integer
    val)
        where
            op :: KnownNat n => Signed n -> Proxy n -> Integer
            op :: forall (n :: Natural). KnownNat n => Signed n -> Proxy n -> Integer
    op Signed n
    s Proxy n
    _ = BitVector n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Signed n -> BitVector n
    forall (n :: Natural). KnownNat n => Signed n -> BitVector n
    Signed.pack# Signed n
    s)
      Text
    "Clash.Sized.Internal.Signed.unpack#"
        | Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [(Integer
    0,Integer
    i)] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (BitVector n -> Proxy n -> Integer
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> Integer
    op (Integer -> BitVector n
    forall a. Num a => Integer -> a
    fromInteger Integer
    i))
           in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty Type
    nTy Integer
    kn Integer
    val)
        where
            op :: KnownNat n => BitVector n -> Proxy n -> Integer
            op :: forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> Integer
    op BitVector n
    s Proxy n
    _ = Signed n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (BitVector n -> Signed n
    forall (n :: Natural). KnownNat n => BitVector n -> Signed n
    Signed.unpack# BitVector n
    s)

    -- Eq
      Text
    "Clash.Sized.Internal.Signed.eq#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    signedLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    j))
      Text
    "Clash.Sized.Internal.Signed.neq#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    signedLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    /= Integer
    j))

    -- Ord
      Text
    "Clash.Sized.Internal.Signed.lt#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    signedLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <  Integer
    j))
      Text
    "Clash.Sized.Internal.Signed.ge#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    signedLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Integer
    j))
      Text
    "Clash.Sized.Internal.Signed.gt#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    signedLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    >  Integer
    j))
      Text
    "Clash.Sized.Internal.Signed.le#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    signedLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <= Integer
    j))

    -- Enum
      Text
    "Clash.Sized.Internal.Signed.toEnum#"
        | [Integer
    i] <- [Value] -> [Integer]
    intCLiterals' [Value]
    args
        , Just (Type
    litTy, Integer
    mb) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty Type
    litTy Integer
    mb Integer
    i)

      Text
    "Clash.Sized.Internal.Signed.fromEnum#"
        | [Integer
    i] <- [Value] -> [Integer]
    signedLiterals' [Value]
    args
        -> let resTy :: Type
    resTy = TyConMap -> Type -> [Type] -> Type
    getResultTy TyConMap
    tcm Type
    ty [Type]
    tys
            in Term -> Maybe Machine
    reduce (TyConMap -> Integer -> Type -> Term
    mkIntCLit TyConMap
    tcm Integer
    i Type
    resTy)

    -- Bounded
      Text
    "Clash.Sized.Internal.Signed.minBound#"
        | Just (Type
    litTy,Integer
    mb) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> let minB :: Integer
    minB = Integer -> Integer
    forall a. Num a => a -> a
    negate (Integer
    2 Integer -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^ (Integer
    mb Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1))
           in  Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty Type
    litTy Integer
    mb Integer
    minB)
      Text
    "Clash.Sized.Internal.Signed.maxBound#"
        | Just (Type
    litTy,Integer
    mb) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> let maxB :: Integer
    maxB = (Integer
    2 Integer -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^ (Integer
    mb Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1)) Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1
           in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty Type
    litTy Integer
    mb Integer
    maxB)

    -- Num
      Text
    "Clash.Sized.Internal.Signed.+#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((Signed n -> Signed n -> Signed n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (Signed n -> Signed n -> Signed n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftSigned2 Signed n -> Signed n -> Signed n
    forall (n :: Natural).
    KnownNat n =>
    Signed n -> Signed n -> Signed n
    (Signed.+#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce (Term
    val)
      Text
    "Clash.Sized.Internal.Signed.-#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((Signed n -> Signed n -> Signed n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (Signed n -> Signed n -> Signed n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftSigned2 Signed n -> Signed n -> Signed n
    forall (n :: Natural).
    KnownNat n =>
    Signed n -> Signed n -> Signed n
    (Signed.-#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce (Term
    val)
      Text
    "Clash.Sized.Internal.Signed.*#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((Signed n -> Signed n -> Signed n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (Signed n -> Signed n -> Signed n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftSigned2 Signed n -> Signed n -> Signed n
    forall (n :: Natural).
    KnownNat n =>
    Signed n -> Signed n -> Signed n
    (Signed.*#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce (Term
    val)
      Text
    "Clash.Sized.Internal.Signed.negate#"
        | Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [Integer
    i] <- [Value] -> [Integer]
    signedLiterals' [Value]
    args
        -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (Signed n -> Proxy n -> Integer
    forall (n :: Natural). KnownNat n => Signed n -> Proxy n -> Integer
    op (Integer -> Signed n
    forall a. Num a => Integer -> a
    fromInteger Integer
    i))
        in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty Type
    nTy Integer
    kn Integer
    val)
        where
          op :: KnownNat n => Signed n -> Proxy n -> Integer
          op :: forall (n :: Natural). KnownNat n => Signed n -> Proxy n -> Integer
    op Signed n
    s Proxy n
    _ = Signed n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Signed n -> Signed n
    forall (n :: Natural). KnownNat n => Signed n -> Signed n
    Signed.negate# Signed n
    s)
      Text
    "Clash.Sized.Internal.Signed.abs#"
        | Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [Integer
    i] <- [Value] -> [Integer]
    signedLiterals' [Value]
    args
        -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (Signed n -> Proxy n -> Integer
    forall (n :: Natural). KnownNat n => Signed n -> Proxy n -> Integer
    op (Integer -> Signed n
    forall a. Num a => Integer -> a
    fromInteger Integer
    i))
        in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty Type
    nTy Integer
    kn Integer
    val)
        where
          op :: KnownNat n => Signed n -> Proxy n -> Integer
          op :: forall (n :: Natural). KnownNat n => Signed n -> Proxy n -> Integer
    op Signed n
    s Proxy n
    _ = Signed n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Signed n -> Signed n
    forall (n :: Natural). KnownNat n => Signed n -> Signed n
    Signed.abs# Signed n
    s)

    -- ExtendingNum
      Text
    "Clash.Sized.Internal.Signed.plus#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    signedLiterals [Value]
    args
        -> let ty' :: Type
    ty' = HasCallStack => TyConMap -> Type -> [Type] -> Type
    TyConMap -> Type -> [Type] -> Type
    piResultTys TyConMap
    tcm Type
    ty [Type]
    tys
               ([Either TyVar Type]
    _,Type
    resTy) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty'
               (TyConApp TyConName
    _ [Type
    resSizeTy]) = Type -> TypeView
    tyView Type
    resTy
               Right Integer
    resSizeInt = Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    resSizeTy)
           in  Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    resTy Type
    resSizeTy Integer
    resSizeInt (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    +Integer
    j))

      Text
    "Clash.Sized.Internal.Signed.minus#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    signedLiterals [Value]
    args
        -> let ty' :: Type
    ty' = HasCallStack => TyConMap -> Type -> [Type] -> Type
    TyConMap -> Type -> [Type] -> Type
    piResultTys TyConMap
    tcm Type
    ty [Type]
    tys
               ([Either TyVar Type]
    _,Type
    resTy) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty'
               (TyConApp TyConName
    _ [Type
    resSizeTy]) = Type -> TypeView
    tyView Type
    resTy
               Right Integer
    resSizeInt = Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    resSizeTy)
           in  Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    resTy Type
    resSizeTy Integer
    resSizeInt (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    j))

      Text
    "Clash.Sized.Internal.Signed.times#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    signedLiterals [Value]
    args
        -> let ty' :: Type
    ty' = HasCallStack => TyConMap -> Type -> [Type] -> Type
    TyConMap -> Type -> [Type] -> Type
    piResultTys TyConMap
    tcm Type
    ty [Type]
    tys
               ([Either TyVar Type]
    _,Type
    resTy) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty'
               (TyConApp TyConName
    _ [Type
    resSizeTy]) = Type -> TypeView
    tyView Type
    resTy
               Right Integer
    resSizeInt = Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    resSizeTy)
           in  Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    resTy Type
    resSizeTy Integer
    resSizeInt (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    *Integer
    j))

    -- Integral
      Text
    "Clash.Sized.Internal.Signed.quot#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((Signed n -> Signed n -> Signed n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (Signed n -> Signed n -> Signed n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftSigned2 (Signed n -> Signed n -> Signed n
    forall (n :: Natural).
    KnownNat n =>
    Signed n -> Signed n -> Signed n
    Signed.quot#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero Term
    val
      Text
    "Clash.Sized.Internal.Signed.rem#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((Signed n -> Signed n -> Signed n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (Signed n -> Signed n -> Signed n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftSigned2 (Signed n -> Signed n -> Signed n
    forall (n :: Natural). Signed n -> Signed n -> Signed n
    Signed.rem#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero Term
    val
      Text
    "Clash.Sized.Internal.Signed.div#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((Signed n -> Signed n -> Signed n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (Signed n -> Signed n -> Signed n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftSigned2 (Signed n -> Signed n -> Signed n
    forall (n :: Natural).
    KnownNat n =>
    Signed n -> Signed n -> Signed n
    Signed.div#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero Term
    val
      Text
    "Clash.Sized.Internal.Signed.mod#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((Signed n -> Signed n -> Signed n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (Signed n -> Signed n -> Signed n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftSigned2 (Signed n -> Signed n -> Signed n
    forall (n :: Natural). Signed n -> Signed n -> Signed n
    Signed.mod#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero Term
    val
      Text
    "Clash.Sized.Internal.Signed.toInteger#"
        | [PrimVal PrimInfo
    p [Type]
    _ [Value
    _, Lit (IntegerLiteral Integer
    i)]] <- [Value]
    args
        , PrimInfo -> Text
    primName PrimInfo
    p Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    "Clash.Sized.Internal.Signed.fromInteger#"
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntegerLiteral Integer
    i)

    -- Bits
      Text
    "Clash.Sized.Internal.Signed.and#"
        | [Integer
    i,Integer
    j] <- [Value] -> [Integer]
    signedLiterals' [Value]
    args
        , Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty Type
    nTy Integer
    kn (Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .&. Integer
    j))
      Text
    "Clash.Sized.Internal.Signed.or#"
        | [Integer
    i,Integer
    j] <- [Value] -> [Integer]
    signedLiterals' [Value]
    args
        , Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty Type
    nTy Integer
    kn (Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .|. Integer
    j))
      Text
    "Clash.Sized.Internal.Signed.xor#"
        | [Integer
    i,Integer
    j] <- [Value] -> [Integer]
    signedLiterals' [Value]
    args
        , Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty Type
    nTy Integer
    kn (Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    `xor` Integer
    j))

      Text
    "Clash.Sized.Internal.Signed.complement#"
        | [Integer
    i] <- [Value] -> [Integer]
    signedLiterals' [Value]
    args
        , Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (Signed n -> Proxy n -> Integer
    forall (n :: Natural). KnownNat n => Signed n -> Proxy n -> Integer
    op (Integer -> Signed n
    forall a. Num a => Integer -> a
    fromInteger Integer
    i))
        in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty Type
    nTy Integer
    kn Integer
    val)
        where
          op :: KnownNat n => Signed n -> Proxy n -> Integer
          op :: forall (n :: Natural). KnownNat n => Signed n -> Proxy n -> Integer
    op Signed n
    u Proxy n
    _ = Signed n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Signed n -> Signed n
    forall (n :: Natural). KnownNat n => Signed n -> Signed n
    Signed.complement# Signed n
    u)

      Text
    "Clash.Sized.Internal.Signed.shiftL#"
        | Just (Type
    nTy,Integer
    kn,Integer
    i,Integer
    j) <- TyConMap
    -> [Type] -> [Value] -> Maybe (Type, Integer, Integer, Integer)
    signedLitIntLit TyConMap
    tcm [Type]
    tys [Value]
    args
          -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (Signed n -> Unique -> Proxy n -> Integer
    forall (n :: Natural).
    KnownNat n =>
    Signed n -> Unique -> Proxy n -> Integer
    op (Integer -> Signed n
    forall a. Num a => Integer -> a
    fromInteger Integer
    i) (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j))
          in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty Type
    nTy Integer
    kn Integer
    val)
          where
            op :: KnownNat n => Signed n -> Int -> Proxy n -> Integer
            op :: forall (n :: Natural).
    KnownNat n =>
    Signed n -> Unique -> Proxy n -> Integer
    op Signed n
    u Unique
    i Proxy n
    _ = Signed n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Signed n -> Unique -> Signed n
    forall (n :: Natural). KnownNat n => Signed n -> Unique -> Signed n
    Signed.shiftL# Signed n
    u Unique
    i)
      Text
    "Clash.Sized.Internal.Signed.shiftR#"
        | Just (Type
    nTy,Integer
    kn,Integer
    i,Integer
    j) <- TyConMap
    -> [Type] -> [Value] -> Maybe (Type, Integer, Integer, Integer)
    signedLitIntLit TyConMap
    tcm [Type]
    tys [Value]
    args
          -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (Signed n -> Unique -> Proxy n -> Integer
    forall (n :: Natural).
    KnownNat n =>
    Signed n -> Unique -> Proxy n -> Integer
    op (Integer -> Signed n
    forall a. Num a => Integer -> a
    fromInteger Integer
    i) (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j))
          in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty Type
    nTy Integer
    kn Integer
    val)
          where
            op :: KnownNat n => Signed n -> Int -> Proxy n -> Integer
            op :: forall (n :: Natural).
    KnownNat n =>
    Signed n -> Unique -> Proxy n -> Integer
    op Signed n
    u Unique
    i Proxy n
    _ = Signed n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Signed n -> Unique -> Signed n
    forall (n :: Natural). KnownNat n => Signed n -> Unique -> Signed n
    Signed.shiftR# Signed n
    u Unique
    i)
      Text
    "Clash.Sized.Internal.Signed.rotateL#"
        | Just (Type
    nTy,Integer
    kn,Integer
    i,Integer
    j) <- TyConMap
    -> [Type] -> [Value] -> Maybe (Type, Integer, Integer, Integer)
    signedLitIntLit TyConMap
    tcm [Type]
    tys [Value]
    args
          -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (Signed n -> Unique -> Proxy n -> Integer
    forall (n :: Natural).
    KnownNat n =>
    Signed n -> Unique -> Proxy n -> Integer
    op (Integer -> Signed n
    forall a. Num a => Integer -> a
    fromInteger Integer
    i) (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j))
          in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty Type
    nTy Integer
    kn Integer
    val)
          where
            op :: KnownNat n => Signed n -> Int -> Proxy n -> Integer
            op :: forall (n :: Natural).
    KnownNat n =>
    Signed n -> Unique -> Proxy n -> Integer
    op Signed n
    u Unique
    i Proxy n
    _ = Signed n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Signed n -> Unique -> Signed n
    forall (n :: Natural). KnownNat n => Signed n -> Unique -> Signed n
    Signed.rotateL# Signed n
    u Unique
    i)
      Text
    "Clash.Sized.Internal.Signed.rotateR#"
        | Just (Type
    nTy,Integer
    kn,Integer
    i,Integer
    j) <- TyConMap
    -> [Type] -> [Value] -> Maybe (Type, Integer, Integer, Integer)
    signedLitIntLit TyConMap
    tcm [Type]
    tys [Value]
    args
          -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (Signed n -> Unique -> Proxy n -> Integer
    forall (n :: Natural).
    KnownNat n =>
    Signed n -> Unique -> Proxy n -> Integer
    op (Integer -> Signed n
    forall a. Num a => Integer -> a
    fromInteger Integer
    i) (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j))
          in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty Type
    nTy Integer
    kn Integer
    val)
          where
            op :: KnownNat n => Signed n -> Int -> Proxy n -> Integer
            op :: forall (n :: Natural).
    KnownNat n =>
    Signed n -> Unique -> Proxy n -> Integer
    op Signed n
    u Unique
    i Proxy n
    _ = Signed n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Signed n -> Unique -> Signed n
    forall (n :: Natural). KnownNat n => Signed n -> Unique -> Signed n
    Signed.rotateR# Signed n
    u Unique
    i)

    -- Resize
      Text
    "Clash.Sized.Internal.Signed.resize#" -- forall m n. (KnownNat n, KnownNat m) => Signed n -> Signed m
        | Type
    mTy : Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    mInt <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    mTy)
        , Right Integer
    nInt <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        , [Integer
    i] <- [Value] -> [Integer]
    signedLiterals' [Value]
    args
        -> let val :: Integer
    val | Integer
    nInt Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <= Integer
    mInt = Integer
    extended
                   | Bool
    otherwise    = Integer
    truncated
               extended :: Integer
    extended  = Integer
    i
               mask :: Integer
    mask      = Integer
    1 Integer -> Unique -> Integer
    forall a. Bits a => a -> Unique -> a
    `shiftL` Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger (Integer
    mInt Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1)
               i' :: Integer
    i'        = Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `mod` Integer
    mask
               truncated :: Integer
    truncated = if Integer -> Unique -> Bool
    forall a. Bits a => a -> Unique -> Bool
    testBit Integer
    i (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    nInt Unique -> Unique -> Unique
    forall a. Num a => a -> a -> a
    - Unique
    1)
                              then (Integer
    i' Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    mask)
                              else Integer
    i'
           in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty Type
    mTy Integer
    mInt Integer
    val)
      Text
    "Clash.Sized.Internal.Signed.truncateB#" -- KnownNat m => Signed (m + n) -> Signed m
        | Just (Type
    mTy, Integer
    km) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [Integer
    i] <- [Value] -> [Integer]
    signedLiterals' [Value]
    args
        -> let bitsKeep :: Integer
    bitsKeep = (Unique -> Integer
    forall a. Bits a => Unique -> a
    bit (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    km)) Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1
               val :: Integer
    val = Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .&. Integer
    bitsKeep
        in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    ty Type
    mTy Integer
    km Integer
    val)

    -- SaturatingNum
    -- No need to manually evaluate Clash.Sized.Internal.Signed.minBoundSym#
    -- It is just implemented in terms of other primitives.

    -----------
    -- Unsigned
    -----------
      Text
    "Clash.Sized.Internal.Unsigned.size#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> let ([Either TyVar Type]
    _,Type
    ty') = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (TyConApp TyConName
    intTcNm [Type]
    _) = Type -> TypeView
    tyView Type
    ty'
               (Just TyCon
    intTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    intTcNm TyConMap
    tcm
               [DataCon
    intCon] = TyCon -> [DataCon]
    tyConDataCons TyCon
    intTc
           in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    intCon) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral Integer
    kn))])

    -- BitPack
      Text
    "Clash.Sized.Internal.Unsigned.pack#"
        | Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [Integer
    i] <- [Value] -> [Integer]
    unsignedLiterals' [Value]
    args
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    ty Type
    nTy Integer
    kn Integer
    0 Integer
    i)
      Text
    "Clash.Sized.Internal.Unsigned.unpack#"
        | Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [(Integer, Integer)
    i] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
        -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (BitVector n -> Proxy n -> Integer
    forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> Integer
    op ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i))
        in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    ty Type
    nTy Integer
    kn Integer
    val)
        where
          op :: KnownNat n => BitVector n -> Proxy n -> Integer
          op :: forall (n :: Natural).
    KnownNat n =>
    BitVector n -> Proxy n -> Integer
    op BitVector n
    u Proxy n
    _ = Unsigned n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (BitVector n -> Unsigned n
    forall (n :: Natural). KnownNat n => BitVector n -> Unsigned n
    Unsigned.unpack# BitVector n
    u)

    -- Eq
      Text
    "Clash.Sized.Internal.Unsigned.eq#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    unsignedLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    j))
      Text
    "Clash.Sized.Internal.Unsigned.neq#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    unsignedLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    /= Integer
    j))

    -- Ord
      Text
    "Clash.Sized.Internal.Unsigned.lt#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    unsignedLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <  Integer
    j))
      Text
    "Clash.Sized.Internal.Unsigned.ge#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    unsignedLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Integer
    j))
      Text
    "Clash.Sized.Internal.Unsigned.gt#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    unsignedLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    >  Integer
    j))
      Text
    "Clash.Sized.Internal.Unsigned.le#" | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    unsignedLiterals [Value]
    args
        -> Term -> Maybe Machine
    reduce (TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty (Integer
    i Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <= Integer
    j))

    -- Enum
      Text
    "Clash.Sized.Internal.Unsigned.toEnum#"
        | [Integer
    i] <- [Value] -> [Integer]
    intCLiterals' [Value]
    args
        , Just (Type
    litTy, Integer
    mb) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    ty Type
    litTy Integer
    mb Integer
    i)

      Text
    "Clash.Sized.Internal.Unsigned.fromEnum#"
        | [Integer
    i] <- [Value] -> [Integer]
    unsignedLiterals' [Value]
    args
        -> let resTy :: Type
    resTy = TyConMap -> Type -> [Type] -> Type
    getResultTy TyConMap
    tcm Type
    ty [Type]
    tys
            in Term -> Maybe Machine
    reduce (TyConMap -> Integer -> Type -> Term
    mkIntCLit TyConMap
    tcm Integer
    i Type
    resTy)

    -- Bounded
      Text
    "Clash.Sized.Internal.Unsigned.minBound#"
        | Just (Type
    nTy,Integer
    len) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    ty Type
    nTy Integer
    len Integer
    0)
      Text
    "Clash.Sized.Internal.Unsigned.maxBound#"
        | Just (Type
    litTy,Integer
    mb) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> let maxB :: Integer
    maxB = (Integer
    2 Integer -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^ Integer
    mb) Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1
           in  Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    ty Type
    litTy Integer
    mb Integer
    maxB)

    -- Num
      Text
    "Clash.Sized.Internal.Unsigned.+#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((Unsigned n -> Unsigned n -> Unsigned n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (Unsigned n -> Unsigned n -> Unsigned n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftUnsigned2 Unsigned n -> Unsigned n -> Unsigned n
    forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Unsigned n -> Unsigned n
    (Unsigned.+#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val
      Text
    "Clash.Sized.Internal.Unsigned.-#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((Unsigned n -> Unsigned n -> Unsigned n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (Unsigned n -> Unsigned n -> Unsigned n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftUnsigned2 Unsigned n -> Unsigned n -> Unsigned n
    forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Unsigned n -> Unsigned n
    (Unsigned.-#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val
      Text
    "Clash.Sized.Internal.Unsigned.*#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((Unsigned n -> Unsigned n -> Unsigned n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (Unsigned n -> Unsigned n -> Unsigned n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftUnsigned2 Unsigned n -> Unsigned n -> Unsigned n
    forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Unsigned n -> Unsigned n
    (Unsigned.*#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce Term
    val
      Text
    "Clash.Sized.Internal.Unsigned.negate#"
        | Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , [Integer
    i] <- [Value] -> [Integer]
    unsignedLiterals' [Value]
    args
        -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (Unsigned n -> Proxy n -> Integer
    forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Proxy n -> Integer
    op (Integer -> Unsigned n
    forall a. Num a => Integer -> a
    fromInteger Integer
    i))
        in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    ty Type
    nTy Integer
    kn Integer
    val)
        where
          op :: KnownNat n => Unsigned n -> Proxy n -> Integer
          op :: forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Proxy n -> Integer
    op Unsigned n
    u Proxy n
    _ = Unsigned n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unsigned n -> Unsigned n
    forall (n :: Natural). KnownNat n => Unsigned n -> Unsigned n
    Unsigned.negate# Unsigned n
    u)

    -- ExtendingNum
      Text
    "Clash.Sized.Internal.Unsigned.plus#" -- :: Unsigned m -> Unsigned n -> Unsigned (Max m n + 1)
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    unsignedLiterals [Value]
    args
        -> let ty' :: Type
    ty' = HasCallStack => TyConMap -> Type -> [Type] -> Type
    TyConMap -> Type -> [Type] -> Type
    piResultTys TyConMap
    tcm Type
    ty [Type]
    tys
               ([Either TyVar Type]
    _,Type
    resTy) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty'
               (TyConApp TyConName
    _ [Type
    resSizeTy]) = Type -> TypeView
    tyView Type
    resTy
               Right Integer
    resSizeInt = Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    resSizeTy)
           in  Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    resTy Type
    resSizeTy Integer
    resSizeInt (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    +Integer
    j))

      Text
    "Clash.Sized.Internal.Unsigned.minus#"
        | [Integer
    i,Integer
    j] <- [Value] -> [Integer]
    unsignedLiterals' [Value]
    args
        -> let ty' :: Type
    ty' = HasCallStack => TyConMap -> Type -> [Type] -> Type
    TyConMap -> Type -> [Type] -> Type
    piResultTys TyConMap
    tcm Type
    ty [Type]
    tys
               ([Either TyVar Type]
    _,Type
    resTy) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty'
               (TyConApp TyConName
    _ [Type
    resSizeTy]) = Type -> TypeView
    tyView Type
    resTy
               Right Integer
    resSizeInt = Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    resSizeTy)
               val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    resSizeInt ((Unsigned n -> Unsigned n -> Unsigned n)
    -> Integer -> Integer -> Proxy n -> Integer
    forall (n :: Natural) (sized :: Natural -> Type).
    (KnownNat n, Integral (sized n)) =>
    (sized n -> sized n -> sized n)
    -> Integer -> Integer -> Proxy n -> Integer
    runSizedF Unsigned n -> Unsigned n -> Unsigned n
    forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Unsigned n -> Unsigned n
    (Unsigned.-#) Integer
    i Integer
    j)
          in   Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    resTy Type
    resSizeTy Integer
    resSizeInt Integer
    val)

      Text
    "Clash.Sized.Internal.Unsigned.times#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    unsignedLiterals [Value]
    args
        -> let ty' :: Type
    ty' = HasCallStack => TyConMap -> Type -> [Type] -> Type
    TyConMap -> Type -> [Type] -> Type
    piResultTys TyConMap
    tcm Type
    ty [Type]
    tys
               ([Either TyVar Type]
    _,Type
    resTy) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty'
               (TyConApp TyConName
    _ [Type
    resSizeTy]) = Type -> TypeView
    tyView Type
    resTy
               Right Integer
    resSizeInt = Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    resSizeTy)
           in  Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    resTy Type
    resSizeTy Integer
    resSizeInt (Integer
    iInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    *Integer
    j))

    -- Integral
      Text
    "Clash.Sized.Internal.Unsigned.quot#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((Unsigned n -> Unsigned n -> Unsigned n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (Unsigned n -> Unsigned n -> Unsigned n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftUnsigned2 (Unsigned n -> Unsigned n -> Unsigned n
    forall (n :: Natural). Unsigned n -> Unsigned n -> Unsigned n
    Unsigned.quot#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero Term
    val
      Text
    "Clash.Sized.Internal.Unsigned.rem#"
        | Just (Type
    _, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        , Just Term
    val <- Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Maybe Term)
    -> Maybe Term
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn ((Unsigned n -> Unsigned n -> Unsigned n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    forall (n :: Natural).
    KnownNat n =>
    (Unsigned n -> Unsigned n -> Unsigned n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftUnsigned2 (Unsigned n -> Unsigned n -> Unsigned n
    forall (n :: Natural). Unsigned n -> Unsigned n -> Unsigned n
    Unsigned.rem#) Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args)
        -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    catchDivByZero Term
    val
      Text
    "Clash.Sized.Internal.Unsigned.toInteger#"
        | [PrimVal PrimInfo
    p [Type]
    _ [Value
    _, Lit (IntegerLiteral Integer
    i)]] <- [Value]
    args
        , PrimInfo -> Text
    primName PrimInfo
    p Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    "Clash.Sized.Internal.Unsigned.fromInteger#"
        -> Term -> Maybe Machine
    reduce (Integer -> Term
    integerToIntegerLiteral Integer
    i)

    -- Bits
      Text
    "Clash.Sized.Internal.Unsigned.and#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    unsignedLiterals [Value]
    args
        , Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    ty Type
    nTy Integer
    kn (Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .&. Integer
    j))
      Text
    "Clash.Sized.Internal.Unsigned.or#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    unsignedLiterals [Value]
    args
        , Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    ty Type
    nTy Integer
    kn (Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .|. Integer
    j))
      Text
    "Clash.Sized.Internal.Unsigned.xor#"
        | Just (Integer
    i,Integer
    j) <- [Value] -> Maybe (Integer, Integer)
    unsignedLiterals [Value]
    args
        , Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    ty Type
    nTy Integer
    kn (Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    `xor` Integer
    j))

      Text
    "Clash.Sized.Internal.Unsigned.complement#"
        | [Integer
    i] <- [Value] -> [Integer]
    unsignedLiterals' [Value]
    args
        , Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
        -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (Unsigned n -> Proxy n -> Integer
    forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Proxy n -> Integer
    op (Integer -> Unsigned n
    forall a. Num a => Integer -> a
    fromInteger Integer
    i))
        in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    ty Type
    nTy Integer
    kn Integer
    val)
        where
          op :: KnownNat n => Unsigned n -> Proxy n -> Integer
          op :: forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Proxy n -> Integer
    op Unsigned n
    u Proxy n
    _ = Unsigned n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unsigned n -> Unsigned n
    forall (n :: Natural). KnownNat n => Unsigned n -> Unsigned n
    Unsigned.complement# Unsigned n
    u)

      Text
    "Clash.Sized.Internal.Unsigned.shiftL#" -- :: forall n. KnownNat n => Unsigned n -> Int -> Unsigned n
        | Just (Type
    nTy,Integer
    kn,Integer
    i,Integer
    j) <- TyConMap
    -> [Type] -> [Value] -> Maybe (Type, Integer, Integer, Integer)
    unsignedLitIntLit TyConMap
    tcm [Type]
    tys [Value]
    args
          -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (Unsigned n -> Unique -> Proxy n -> Integer
    forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Unique -> Proxy n -> Integer
    op (Integer -> Unsigned n
    forall a. Num a => Integer -> a
    fromInteger Integer
    i) (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j))
          in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    ty Type
    nTy Integer
    kn Integer
    val)
          where
            op :: KnownNat n => Unsigned n -> Int -> Proxy n -> Integer
            op :: forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Unique -> Proxy n -> Integer
    op Unsigned n
    u Unique
    i Proxy n
    _ = Unsigned n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unsigned n -> Unique -> Unsigned n
    forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Unique -> Unsigned n
    Unsigned.shiftL# Unsigned n
    u Unique
    i)
      Text
    "Clash.Sized.Internal.Unsigned.shiftR#" -- :: forall n. KnownNat n => Unsigned n -> Int -> Unsigned n
        | Just (Type
    nTy,Integer
    kn,Integer
    i,Integer
    j) <- TyConMap
    -> [Type] -> [Value] -> Maybe (Type, Integer, Integer, Integer)
    unsignedLitIntLit TyConMap
    tcm [Type]
    tys [Value]
    args
          -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (Unsigned n -> Unique -> Proxy n -> Integer
    forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Unique -> Proxy n -> Integer
    op (Integer -> Unsigned n
    forall a. Num a => Integer -> a
    fromInteger Integer
    i) (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j))
          in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    ty Type
    nTy Integer
    kn Integer
    val)
          where
            op :: KnownNat n => Unsigned n -> Int -> Proxy n -> Integer
            op :: forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Unique -> Proxy n -> Integer
    op Unsigned n
    u Unique
    i Proxy n
    _ = Unsigned n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unsigned n -> Unique -> Unsigned n
    forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Unique -> Unsigned n
    Unsigned.shiftR# Unsigned n
    u Unique
    i)
      Text
    "Clash.Sized.Internal.Unsigned.rotateL#" -- :: forall n. KnownNat n => Unsigned n -> Int -> Unsigned n
        | Just (Type
    nTy,Integer
    kn,Integer
    i,Integer
    j) <- TyConMap
    -> [Type] -> [Value] -> Maybe (Type, Integer, Integer, Integer)
    unsignedLitIntLit TyConMap
    tcm [Type]
    tys [Value]
    args
          -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (Unsigned n -> Unique -> Proxy n -> Integer
    forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Unique -> Proxy n -> Integer
    op (Integer -> Unsigned n
    forall a. Num a => Integer -> a
    fromInteger Integer
    i) (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j))
          in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    ty Type
    nTy Integer
    kn Integer
    val)
          where
            op :: KnownNat n => Unsigned n -> Int -> Proxy n -> Integer
            op :: forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Unique -> Proxy n -> Integer
    op Unsigned n
    u Unique
    i Proxy n
    _ = Unsigned n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unsigned n -> Unique -> Unsigned n
    forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Unique -> Unsigned n
    Unsigned.rotateL# Unsigned n
    u Unique
    i)
      Text
    "Clash.Sized.Internal.Unsigned.rotateR#" -- :: forall n. KnownNat n => Unsigned n -> Int -> Unsigned n
        | Just (Type
    nTy,Integer
    kn,Integer
    i,Integer
    j) <- TyConMap
    -> [Type] -> [Value] -> Maybe (Type, Integer, Integer, Integer)
    unsignedLitIntLit TyConMap
    tcm [Type]
    tys [Value]
    args
          -> let val :: Integer
    val = Integer
    -> (forall (n :: Natural). KnownNat n => Proxy n -> Integer)
    -> Integer
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (Unsigned n -> Unique -> Proxy n -> Integer
    forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Unique -> Proxy n -> Integer
    op (Integer -> Unsigned n
    forall a. Num a => Integer -> a
    fromInteger Integer
    i) (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j))
          in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    ty Type
    nTy Integer
    kn Integer
    val)
          where
            op :: KnownNat n => Unsigned n -> Int -> Proxy n -> Integer
            op :: forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Unique -> Proxy n -> Integer
    op Unsigned n
    u Unique
    i Proxy n
    _ = Unsigned n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unsigned n -> Unique -> Unsigned n
    forall (n :: Natural).
    KnownNat n =>
    Unsigned n -> Unique -> Unsigned n
    Unsigned.rotateR# Unsigned n
    u Unique
    i)

    -- Resize
      Text
    "Clash.Sized.Internal.Unsigned.resize#" -- forall n m . KnownNat m => Unsigned n -> Unsigned m
        | Type
    _ : Type
    mTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    km <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    mTy)
        , [Integer
    i] <- [Value] -> [Integer]
    unsignedLiterals' [Value]
    args
        -> let bitsKeep :: Integer
    bitsKeep = (Unique -> Integer
    forall a. Bits a => Unique -> a
    bit (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    km)) Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1
               val :: Integer
    val = Integer
    i Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .&. Integer
    bitsKeep
        in Term -> Maybe Machine
    reduce (Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit Type
    ty Type
    mTy Integer
    km Integer
    val)

    -- Conversions
      Text
    "Clash.Sized.Internal.Unsigned.unsignedToWord"
        | Bool
    isSubj
        , [Integer
    a] <- [Value] -> [Integer]
    unsignedLiterals' [Value]
    args
        -> let b :: Word
    b = Unsigned 64 -> Word
    Unsigned.unsignedToWord (Natural -> Unsigned 64
    forall (n :: Natural). Natural -> Unsigned n
    U (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger Integer
    a))
               ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    wordTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    wordTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    wordTcNm TyConMap
    tcm
               [DataCon
    wordDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    wordTc
           in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    wordDc) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    WordLiteral (Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word
    b)))])

      Text
    "Clash.Sized.Internal.Unsigned.unsigned8toWord8"
        | Bool
    isSubj
        , [Integer
    a] <- [Value] -> [Integer]
    unsignedLiterals' [Value]
    args
        -> let b :: Word8
    b = Unsigned 8 -> Word8
    Unsigned.unsigned8toWord8 (Natural -> Unsigned 8
    forall (n :: Natural). Natural -> Unsigned n
    U (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger Integer
    a))
               ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    wordTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    wordTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    wordTcNm TyConMap
    tcm
               [DataCon
    wordDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    wordTc
           in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    wordDc) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    WordLiteral (Word8 -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word8
    b)))])

      Text
    "Clash.Sized.Internal.Unsigned.unsigned16toWord16"
        | Bool
    isSubj
        , [Integer
    a] <- [Value] -> [Integer]
    unsignedLiterals' [Value]
    args
        -> let b :: Word16
    b = Unsigned 16 -> Word16
    Unsigned.unsigned16toWord16 (Natural -> Unsigned 16
    forall (n :: Natural). Natural -> Unsigned n
    U (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger Integer
    a))
               ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    wordTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    wordTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    wordTcNm TyConMap
    tcm
               [DataCon
    wordDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    wordTc
           in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    wordDc) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    WordLiteral (Word16 -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word16
    b)))])

      Text
    "Clash.Sized.Internal.Unsigned.unsigned32toWord32"
        | Bool
    isSubj
        , [Integer
    a] <- [Value] -> [Integer]
    unsignedLiterals' [Value]
    args
        -> let b :: Word32
    b = Unsigned 32 -> Word32
    Unsigned.unsigned32toWord32 (Natural -> Unsigned 32
    forall (n :: Natural). Natural -> Unsigned n
    U (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger Integer
    a))
               ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    wordTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    wordTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    wordTcNm TyConMap
    tcm
               [DataCon
    wordDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    wordTc
           in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    wordDc) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    WordLiteral (Word32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger Word32
    b)))])

      Text
    "Clash.Annotations.BitRepresentation.Deriving.dontApplyInHDL"
        | Bool
    isSubj
        , Value
    f : Value
    a : [Value]
    _ <- [Value]
    args
        -> Term -> Maybe Machine
    reduceWHNF (Term -> [Either Term Type] -> Term
    mkApps (Value -> Term
    valToTerm Value
    f) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    a)])

    --------
    -- RTree
    --------
      Text
    "Clash.Sized.RTree.textract"
        | Bool
    isSubj
        , [DC DataCon
    _ [Either Term Type]
    tArgs] <- [Value]
    args
        -> Term -> Maybe Machine
    reduceWHNF ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    tArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)

      Text
    "Clash.Sized.RTree.tsplit"
        | Bool
    isSubj
        , Type
    dTy : Type
    aTy : [Type]
    _ <- [Type]
    tys
        , [DC DataCon
    _ [Either Term Type]
    tArgs] <- [Value]
    args
        , ([Either TyVar Type]
    tyArgs,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    _) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
        , TyConApp TyConName
    treeTcNm [Type]
    _ <- Type -> TypeView
    tyView ([Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights [Either TyVar Type]
    tyArgs [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    0)
        -> let (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc]      = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc)
                      [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    treeTcNm [Type
    dTy,Type
    aTy])
                      ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    treeTcNm [Type
    dTy,Type
    aTy])
                      ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    tArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
                      ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    tArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                      ]

      Text
    "Clash.Sized.RTree.tdfold"
        | Bool
    isSubj
        , Type
    pTy : Type
    kTy : Type
    aTy : [Type]
    _ <- [Type]
    tys
        , Value
    _ : Value
    p : Value
    f : Value
    g : Value
    ts : [Value]
    _ <- [Value]
    args
        , DC DataCon
    _ [Either Term Type]
    tArgs <- Value
    ts
        , Right Integer
    k' <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    kTy)
        -> case Integer
    k' of
             Integer
    0 -> Term -> Maybe Machine
    reduceWHNF (Term -> [Either Term Type] -> Term
    mkApps (Value -> Term
    valToTerm Value
    f) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    tArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)])
             Integer
    _ -> let k'ty :: Type
    k'ty = LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    k'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1))
                      ([Either TyVar Type]
    tyArgs,Type
    _)  = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                      ([Either TyVar Type]
    tyArgs',Type
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy ([Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights [Either TyVar Type]
    tyArgs [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    3)
                      TyConApp TyConName
    snatTcNm [Type]
    _ = Type -> TypeView
    tyView ([Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights [Either TyVar Type]
    tyArgs' [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    0)
                      Just TyCon
    snatTc = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    snatTcNm TyConMap
    tcm
                      [DataCon
    snatDc]    = TyCon -> [DataCon]
    tyConDataCons TyCon
    snatTc
                  in  Term -> Maybe Machine
    reduceWHNF (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                      Term -> [Either Term Type] -> Term
    mkApps (Value -> Term
    valToTerm Value
    g)
                             [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    k'ty
                             ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    snatDc)
                                           [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    k'ty
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    k'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))])
                             ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                           [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    pTy
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    k'ty
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    k'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    p)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    f)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    g)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    tArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
                                           ])
                             ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                           [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    pTy
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    k'ty
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    k'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    p)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    f)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    g)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    tArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                                           ])
                             ]

      Text
    "Clash.Sized.RTree.treplicate"
        | Bool
    isSubj
        , let ty' :: Type
    ty' = HasCallStack => TyConMap -> Type -> [Type] -> Type
    TyConMap -> Type -> [Type] -> Type
    piResultTys TyConMap
    tcm Type
    ty [Type]
    tys
        , ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    treeTcNm [Type
    lenTy,Type
    argTy]) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty'
        , Right Integer
    len <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    lenTy)
        -> let (Just TyCon
    treeTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    treeTcNm TyConMap
    tcm
               [DataCon
    lrCon,DataCon
    brCon] = TyCon -> [DataCon]
    tyConDataCons TyCon
    treeTc
           in  Term -> Maybe Machine
    reduce (DataCon -> DataCon -> Type -> Integer -> [Term] -> Term
    mkRTree DataCon
    lrCon DataCon
    brCon Type
    argTy Integer
    len (Unique -> Term -> [Term]
    forall a. Unique -> a -> [a]
    replicate (Unique
    2Unique -> Integer -> Unique
    forall a b. (Num a, Integral b) => a -> b -> a
    ^Integer
    len) (Value -> Term
    valToTerm ([Value] -> Value
    forall a. HasCallStack => [a] -> a
    last [Value]
    args))))

    ---------
    -- Vector
    ---------
      Text
    "Clash.Sized.Vector.length" -- :: KnownNat n => Vec n a -> Int
        | Bool
    isSubj
        , [Type
    nTy, Type
    _] <- [Type]
    tys
        , Right Integer
    n <-Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> let ([Either TyVar Type]
    _, Type -> TypeView
    tyView -> TyConApp TyConName
    intTcNm [Type]
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    intTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    intTcNm TyConMap
    tcm
               [DataCon
    intCon] = TyCon -> [DataCon]
    tyConDataCons TyCon
    intTc
           in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    intCon) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Integer -> Integer
    forall a. Integral a => a -> Integer
    toInteger Integer
    n)))])

      Text
    "Clash.Sized.Vector.maxIndex"
        | Bool
    isSubj
        , [Type
    nTy, Type
    _] <- [Type]
    tys
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> let ([Either TyVar Type]
    _, Type -> TypeView
    tyView -> TyConApp TyConName
    intTcNm [Type]
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    intTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    intTcNm TyConMap
    tcm
               [DataCon
    intCon] = TyCon -> [DataCon]
    tyConDataCons TyCon
    intTc
           in  Term -> Maybe Machine
    reduce (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    intCon) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Integer -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Integer
    n Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1))))])

    -- Indexing
      Text
    "Clash.Sized.Vector.index_int" -- :: KnownNat n => Vec n a -> Int
        | Type
    nTy : Type
    aTy : [Type]
    _  <- [Type]
    tys
        , Value
    _ : Value
    xs : Value
    i : [Value]
    _ <- [Value]
    args
        , DC DataCon
    intDc [Left (Literal (IntLiteral Integer
    i'))] <- Value
    i
        -> if Integer
    i' Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    < Integer
    0
              then Maybe Machine
    forall a. Maybe a
    Nothing
              else case Value
    xs of
                     DC DataCon
    _ [Either Term Type]
    vArgs  -> case Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy) of
                        Right Integer
    0  -> Maybe Machine
    forall a. Maybe a
    Nothing
                        Right Integer
    n' ->
                          if Integer
    i' Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    0
                             then Term -> Maybe Machine
    reduceWHNF ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
                             else Term -> Maybe Machine
    reduceWHNF (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                                  Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                         [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                         ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                         ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                         ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                                         ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    intDc)
                                                       [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Integer
    i'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))])
                                         ]
                        Either [Char] Integer
    _ -> Maybe Machine
    forall a. Maybe a
    Nothing
                     Value
    _ -> Maybe Machine
    forall a. Maybe a
    Nothing
      Text
    "Clash.Sized.Vector.head" -- :: Vec (n+1) a -> a
        | Bool
    isSubj
        , [DC DataCon
    _ [Either Term Type]
    vArgs] <- [Value]
    args
        -> Term -> Maybe Machine
    reduceWHNF ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
      Text
    "Clash.Sized.Vector.last" -- :: Vec (n+1) a -> a
        | Bool
    isSubj
        , [DC DataCon
    _ [Either Term Type]
    vArgs] <- [Value]
    args
        , (Right Type
    _ : Right Type
    aTy : Right Type
    nTy : [Either Term Type]
    _) <- [Either Term Type]
    vArgs
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> if Integer
    n Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    0
              then Term -> Maybe Machine
    reduceWHNF ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
              else Term -> Maybe Machine
    reduceWHNF
                    (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                         [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    nInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                         ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                         ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                                         ])
    -- - Sub-vectors
      Text
    "Clash.Sized.Vector.tail" -- :: Vec (n+1) a -> Vec n a
        | Bool
    isSubj
        , [DC DataCon
    _ [Either Term Type]
    vArgs] <- [Value]
    args
        -> Term -> Maybe Machine
    reduceWHNF ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
      Text
    "Clash.Sized.Vector.init" -- :: Vec (n+1) a -> Vec n a
        | Bool
    isSubj
        , [DC DataCon
    consCon [Either Term Type]
    vArgs] <- [Value]
    args
        , (Right Type
    _ : Right Type
    aTy : Right Type
    nTy : [Either Term Type]
    _) <- [Either Term Type]
    vArgs
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> if Integer
    n Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    0
              then Term -> Maybe Machine
    reduceWHNF ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
              else Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                   HasCallStack => DataCon -> Type -> Integer -> Term -> Term -> Term
    DataCon -> Type -> Integer -> Term -> Term -> Term
    mkVecCons DataCon
    consCon Type
    aTy Integer
    n
                      ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
                      (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                           [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    nInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)])
      Text
    "Clash.Sized.Vector.select" -- :: (CmpNat (i+s) (s*n) ~ GT) => SNat f -> SNat s -> SNat n -> Vec (f + i) a -> Vec n a
        | Bool
    isSubj
        , Type
    iTy : Type
    sTy : Type
    nTy : Type
    fTy : Type
    aTy : [Type]
    _ <- [Type]
    tys
        , Value
    eq : Value
    f : Value
    s : Value
    n : Value
    xs : [Value]
    _ <- [Value]
    args
        , Right Integer
    n' <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        , Right Integer
    f' <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    fTy)
        , Right Integer
    i' <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    iTy)
        , Right Integer
    s' <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    sTy)
        , DC DataCon
    _ [Either Term Type]
    vArgs <- Value
    xs
        -> case Integer
    n' of
             Integer
    0 -> Term -> Maybe Machine
    reduce (DataCon -> Type -> Term
    mkVecNil DataCon
    nilCon Type
    aTy)
             Integer
    _ -> case Integer
    f' of
              Integer
    0 -> let splitAtCall :: Term
    splitAtCall =
                        Term -> [Either Term Type] -> Term
    mkApps (TyConName -> TyConName -> Term
    splitAtPrim TyConName
    snatTcNm TyConName
    vecTcNm)
                               [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    sTy
                               ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    i'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    s')))
                               ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                               ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    s)
                               ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    xs)
                               ]
                       fVecTy :: Type
    fVecTy = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    sTy,Type
    aTy]
                       iVecTy :: Type
    iVecTy = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    i'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    s')),Type
    aTy]
                       -- Guaranteed no capture, so okay to use unsafe name generation
                       fNm :: Name a
    fNm    = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "fxs" Unique
    0
                       iNm :: Name a
    iNm    = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "ixs" Unique
    1
                       fId :: Id
    fId    = Type -> TmName -> Id
    mkLocalId Type
    fVecTy TmName
    forall {a}. Name a
    fNm
                       iId :: Id
    iId    = Type -> TmName -> Id
    mkLocalId Type
    iVecTy TmName
    forall {a}. Name a
    iNm
                       tupPat :: Pat
    tupPat = DataCon -> [TyVar] -> [Id] -> Pat
    DataPat DataCon
    tupDc [] [Id
    fId,Id
    iId]
                       iAlt :: (Pat, Term)
    iAlt   = (Pat
    tupPat, (Id -> Term
    Var Id
    iId))
                   in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                       HasCallStack => DataCon -> Type -> Integer -> Term -> Term -> Term
    DataCon -> Type -> Integer -> Term -> Term -> Term
    mkVecCons DataCon
    consCon Type
    aTy Integer
    n' ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1) (Term -> Term) -> Term -> Term
    forall a b. (a -> b) -> a -> b
    $
                       Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                              [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    i'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    s')))
                              ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    sTy
                              ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                              ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy Integer
    0))
                              ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                              ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    eq)
                              ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral Integer
    0))
                              ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    s)
                              ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                              ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Type -> [(Pat, Term)] -> Term
    Case Term
    splitAtCall Type
    iVecTy [(Pat, Term)
    iAlt])
                              ]
              Integer
    _ -> let splitAtCall :: Term
    splitAtCall =
                        Term -> [Either Term Type] -> Term
    mkApps (TyConName -> TyConName -> Term
    splitAtPrim TyConName
    snatTcNm TyConName
    vecTcNm)
                               [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    fTy
                               ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    iTy
                               ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                               ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    f)
                               ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    xs)
                               ]
                       fVecTy :: Type
    fVecTy = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    fTy,Type
    aTy]
                       iVecTy :: Type
    iVecTy = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    iTy,Type
    aTy]
                       -- Guaranteed no capture, so okay to use unsafe name generation
                       fNm :: Name a
    fNm    = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "fxs" Unique
    0
                       iNm :: Name a
    iNm    = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "ixs" Unique
    1
                       fId :: Id
    fId    = Type -> TmName -> Id
    mkLocalId Type
    fVecTy TmName
    forall {a}. Name a
    fNm
                       iId :: Id
    iId    = Type -> TmName -> Id
    mkLocalId Type
    iVecTy TmName
    forall {a}. Name a
    iNm
                       tupPat :: Pat
    tupPat = DataCon -> [TyVar] -> [Id] -> Pat
    DataPat DataCon
    tupDc [] [Id
    fId,Id
    iId]
                       iAlt :: (Pat, Term)
    iAlt   = (Pat
    tupPat, (Id -> Term
    Var Id
    iId))
                   in  Term -> Maybe Machine
    reduceWHNF (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                       Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                         [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    iTy
                         ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    sTy
                         ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    nTy
                         ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy Integer
    0))
                         ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                         ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    eq)
                         ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral Integer
    0))
                         ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    s)
                         ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    n)
                         ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Type -> [(Pat, Term)] -> Term
    Case Term
    splitAtCall Type
    iVecTy [(Pat, Term)
    iAlt])
                         ]
        where
          ([Either TyVar Type]
    tyArgs,Type -> TypeView
    tyView -> TyConApp TyConName
    vecTcNm [Type]
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
          Just TyCon
    vecTc          = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    vecTcNm TyConMap
    tcm
          [DataCon
    nilCon,DataCon
    consCon]    = TyCon -> [DataCon]
    tyConDataCons TyCon
    vecTc
          TyConApp TyConName
    snatTcNm [Type]
    _ = Type -> TypeView
    tyView ([Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights [Either TyVar Type]
    tyArgs [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
          tupTcNm :: TyConName
    tupTcNm            = TyCon -> TyConName
    ghcTyconToTyConName (Boxity -> Unique -> TyCon
    tupleTyCon Boxity
    Boxed Unique
    2)
          (Just TyCon
    tupTc)       = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
          [DataCon
    tupDc]            = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
    -- - Splitting
      Text
    "Clash.Sized.Vector.splitAt" -- :: SNat m -> Vec (m + n) a -> (Vec m a, Vec n a)
        | Bool
    isSubj
        , (DC DataCon
    snatDc (Right Type
    mTy:[Either Term Type]
    _)):[Value]
    _ <- [Value]
    args
        , Right Integer
    m <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    mTy)
        -> let Type
    _:Type
    nTy:Type
    aTy:[Type]
    _ = [Type]
    tys
               -- Get the tuple data-constructor
               ty1 :: Type
    ty1 = HasCallStack => TyConMap -> Type -> [Type] -> Type
    TyConMap -> Type -> [Type] -> Type
    piResultTys TyConMap
    tcm Type
    ty [Type]
    tys
               ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm tyArgs :: [Type]
    tyArgs@(Type
    tyArg:[Type]
    _)) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty1
               (Just TyCon
    tupTc)       = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc]            = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               -- Get the vector data-constructors
               TyConApp TyConName
    vecTcNm [Type]
    _ = Type -> TypeView
    tyView Type
    tyArg
               Just TyCon
    vecTc         = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    vecTcNm TyConMap
    tcm
               [DataCon
    nilCon,DataCon
    consCon]   = TyCon -> [DataCon]
    tyConDataCons TyCon
    vecTc
               -- Recursive call to @splitAt@
               splitAtRec :: Term -> Term
    splitAtRec Term
    v =
                Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                       [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    mInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                       ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    nTy
                       ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                       ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    snatDc)
                                     [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    mInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                     , Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    mInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))])
                       ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left Term
    v
                       ]
               -- Projection either the first or second field of the recursive
               -- call to @splitAt@
               splitAtSelR :: Term -> Type -> [(Pat, Term)] -> Term
    splitAtSelR Term
    v = Term -> Type -> [(Pat, Term)] -> Term
    Case (Term -> Term
    splitAtRec Term
    v)
               m1VecTy :: Type
    m1VecTy = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    mInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)),Type
    aTy]
               nVecTy :: Type
    nVecTy  = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    nTy,Type
    aTy]
               -- Guaranteed no capture, so okay to use unsafe name generation
               lNm :: Name a
    lNm     = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "l" Unique
    0
               rNm :: Name a
    rNm     = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "r" Unique
    1
               lId :: Id
    lId     = Type -> TmName -> Id
    mkLocalId Type
    m1VecTy TmName
    forall {a}. Name a
    lNm
               rId :: Id
    rId     = Type -> TmName -> Id
    mkLocalId Type
    nVecTy TmName
    forall {a}. Name a
    rNm
               tupPat :: Pat
    tupPat  = DataCon -> [TyVar] -> [Id] -> Pat
    DataPat DataCon
    tupDc [] [Id
    lId,Id
    rId]
               lAlt :: (Pat, Term)
    lAlt    = (Pat
    tupPat, (Id -> Term
    Var Id
    lId))
               rAlt :: (Pat, Term)
    rAlt    = (Pat
    tupPat, (Id -> Term
    Var Id
    rId))

           in case Integer
    m of
             -- (Nil,v)
             Integer
    0 -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                  Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ([Either Term Type] -> Term) -> [Either Term Type] -> Term
    forall a b. (a -> b) -> a -> b
    $ ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs) [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                    [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (DataCon -> Type -> Term
    mkVecNil DataCon
    nilCon Type
    aTy)
                    , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm ([Value] -> Value
    forall a. HasCallStack => [a] -> a
    last [Value]
    args))
                    ]
             -- (x:xs) <- v
             Integer
    m' | DC DataCon
    _ [Either Term Type]
    vArgs <- [Value] -> Value
    forall a. HasCallStack => [a] -> a
    last [Value]
    args
                -- (x:fst (splitAt (m-1) xs),snd (splitAt (m-1) xs))
                -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                   Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ([Either Term Type] -> Term) -> [Either Term Type] -> Term
    forall a b. (a -> b) -> a -> b
    $ ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs) [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                     [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (HasCallStack => DataCon -> Type -> Integer -> Term -> Term -> Term
    DataCon -> Type -> Integer -> Term -> Term -> Term
    mkVecCons DataCon
    consCon Type
    aTy Integer
    m' ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
                               (Term -> Type -> [(Pat, Term)] -> Term
    splitAtSelR ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2) Type
    m1VecTy [(Pat, Term)
    lAlt]))
                     , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Type -> [(Pat, Term)] -> Term
    splitAtSelR ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2) Type
    nVecTy [(Pat, Term)
    rAlt])
                     ]
             -- v doesn't reduce to a data-constructor
             Integer
    _  -> Maybe Machine
    forall a. Maybe a
    Nothing

      Text
    "Clash.Sized.Vector.unconcat" -- :: KnownNat n => SNamt m -> Vec (n * m) a -> Vec n (Vec m a)
        | Bool
    isSubj
        , Value
    kn : Value
    snat : Value
    v : [Value]
    _  <- [Value]
    args
        , Type
    nTy : Type
    mTy : Type
    aTy :[Type]
    _ <- [Type]
    tys
        , Lit (NaturalLiteral Integer
    n) <- Value
    kn
        -> let ( [Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights -> [Type]
    argTys, Type -> TypeView
    tyView -> TyConApp TyConName
    vecTcNm [Type]
    _) =
                  Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               Just TyCon
    vecTc = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    vecTcNm TyConMap
    tcm
               [DataCon
    nilCon,DataCon
    consCon]   = TyCon -> [DataCon]
    tyConDataCons TyCon
    vecTc
               tupTcNm :: TyConName
    tupTcNm            = TyCon -> TyConName
    ghcTyconToTyConName (Boxity -> Unique -> TyCon
    tupleTyCon Boxity
    Boxed Unique
    2)
               (Just TyCon
    tupTc)       = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc]            = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               TyConApp TyConName
    snatTcNm [Type]
    _ = Type -> TypeView
    tyView ([Type]
    argTys [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
               n1mTy :: Type
    n1mTy  = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    typeNatMul
                            [TyConName -> [Type] -> Type
    mkTyConApp TyConName
    typeNatSub [Type
    nTy,LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy Integer
    1)]
                            ,Type
    mTy]
               splitAtCall :: Term
    splitAtCall =
                Term -> [Either Term Type] -> Term
    mkApps (TyConName -> TyConName -> Term
    splitAtPrim TyConName
    snatTcNm TyConName
    vecTcNm)
                       [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    mTy
                       ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    n1mTy
                       ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                       ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    snat)
                       ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    v)
                       ]
               mVecTy :: Type
    mVecTy   = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    mTy,Type
    aTy]
               n1mVecTy :: Type
    n1mVecTy = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    n1mTy,Type
    aTy]
               -- Guaranteed no capture, so okay to use unsafe name generation
               asNm :: Name a
    asNm     = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "as" Unique
    0
               bsNm :: Name a
    bsNm     = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "bs" Unique
    1
               asId :: Id
    asId     = Type -> TmName -> Id
    mkLocalId Type
    mVecTy TmName
    forall {a}. Name a
    asNm
               bsId :: Id
    bsId     = Type -> TmName -> Id
    mkLocalId Type
    n1mVecTy TmName
    forall {a}. Name a
    bsNm
               tupPat :: Pat
    tupPat   = DataCon -> [TyVar] -> [Id] -> Pat
    DataPat DataCon
    tupDc [] [Id
    asId,Id
    bsId]
               asAlt :: (Pat, Term)
    asAlt    = (Pat
    tupPat, (Id -> Term
    Var Id
    asId))
               bsAlt :: (Pat, Term)
    bsAlt    = (Pat
    tupPat, (Id -> Term
    Var Id
    bsId))

           in  case Integer
    n of
             Integer
    0 -> Term -> Maybe Machine
    reduce (DataCon -> Type -> Term
    mkVecNil DataCon
    nilCon Type
    mVecTy)
             Integer
    _ -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                  HasCallStack => DataCon -> Type -> Integer -> Term -> Term -> Term
    DataCon -> Type -> Integer -> Term -> Term -> Term
    mkVecCons DataCon
    consCon Type
    mVecTy Integer
    n
                    (Term -> Type -> [(Pat, Term)] -> Term
    Case Term
    splitAtCall Type
    mVecTy [(Pat, Term)
    asAlt])
                    (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                        [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    nInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                        ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    mTy
                        ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                        ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    nInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                        ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    snat)
                        ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Type -> [(Pat, Term)] -> Term
    Case Term
    splitAtCall Type
    n1mVecTy [(Pat, Term)
    bsAlt])])
    -- Construction
    -- - initialisation
      Text
    "Clash.Sized.Vector.replicate" -- :: SNat n -> a -> Vec n a
        | Bool
    isSubj
        , let ty' :: Type
    ty' = HasCallStack => TyConMap -> Type -> [Type] -> Type
    TyConMap -> Type -> [Type] -> Type
    piResultTys TyConMap
    tcm Type
    ty [Type]
    tys
        , let ([Either TyVar Type]
    _,Type
    resTy) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty'
        , (TyConApp TyConName
    vecTcNm [Type
    lenTy,Type
    argTy]) <- Type -> TypeView
    tyView Type
    resTy
        , Right Integer
    len <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    lenTy)
        -> let (Just TyCon
    vecTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    vecTcNm TyConMap
    tcm
               [DataCon
    nilCon,DataCon
    consCon] = TyCon -> [DataCon]
    tyConDataCons TyCon
    vecTc
           in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
               DataCon -> DataCon -> Type -> Integer -> [Term] -> Term
    mkVec DataCon
    nilCon DataCon
    consCon Type
    argTy Integer
    len
                     (Unique -> Term -> [Term]
    forall a. Unique -> a -> [a]
    replicate (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    len) (Value -> Term
    valToTerm ([Value] -> Value
    forall a. HasCallStack => [a] -> a
    last [Value]
    args)))
    -- - Concatenation
      Text
    "Clash.Sized.Vector.++" -- :: Vec n a -> Vec m a -> Vec (n + m) a
        | Bool
    isSubj
        , (DC DataCon
    dc [Either Term Type]
    vArgs):[Value]
    _ <- [Value]
    args
        , Right Type
    nTy : Right Type
    aTy : [Either Term Type]
    _ <- [Either Term Type]
    vArgs
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> case Integer
    n of
             Integer
    0  -> Term -> Maybe Machine
    reduce (Value -> Term
    valToTerm ([Value] -> Value
    forall a. HasCallStack => [a] -> a
    last [Value]
    args))
             Integer
    n' | (Type
    _ : Type
    _ : Type
    mTy : [Type]
    _) <- [Type]
    tys
                , Right Integer
    m <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    mTy)
                -> -- x : (xs ++ ys)
                   Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                   HasCallStack => DataCon -> Type -> Integer -> Term -> Term -> Term
    DataCon -> Type -> Integer -> Term -> Term -> Term
    mkVecCons DataCon
    dc Type
    aTy (Integer
    n' Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    + Integer
    m) ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
                     (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                          [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                          ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                          ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    mTy
                                          ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                                          ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm ([Value] -> Value
    forall a. HasCallStack => [a] -> a
    last [Value]
    args))
                                          ])
             Integer
    _ -> Maybe Machine
    forall a. Maybe a
    Nothing
      Text
    "Clash.Sized.Vector.concat" -- :: Vec n (Vec m a) -> Vec (n * m) a
        | Bool
    isSubj
        , (Type
    nTy : Type
    mTy : Type
    aTy : [Type]
    _)  <- [Type]
    tys
        , (Value
    xs : [Value]
    _)               <- [Value]
    args
        , DC DataCon
    dc [Either Term Type]
    vArgs <- Value
    xs
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> case Integer
    n of
            Integer
    0 -> Term -> Maybe Machine
    reduce (DataCon -> Type -> Term
    mkVecNil DataCon
    dc Type
    aTy)
            Integer
    _ | Term
    _ : Term
    h' : Term
    t : [Term]
    _ <- [Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts  [Either Term Type]
    vArgs
              , ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    vecTcNm [Type]
    _) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
              -> Term -> Maybe Machine
    reduceWHNF (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                 Term -> [Either Term Type] -> Term
    mkApps (TyConName -> Term
    vecAppendPrim TyConName
    vecTcNm)
                        [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    mTy
                        ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                        ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (Type -> Either Term Type) -> Type -> Either Term Type
    forall a b. (a -> b) -> a -> b
    $ TyConName -> [Type] -> Type
    mkTyConApp TyConName
    typeNatMul
                          [TyConName -> [Type] -> Type
    mkTyConApp TyConName
    typeNatSub [Type
    nTy,LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy Integer
    1)], Type
    mTy]
                        ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left Term
    h'
                        ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Either Term Type) -> Term -> Either Term Type
    forall a b. (a -> b) -> a -> b
    $ Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                          [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    nInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                          , Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    mTy
                          , Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                          , Term -> Either Term Type
    forall a b. a -> Either a b
    Left Term
    t
                          ]
                        ]
            Integer
    _ -> Maybe Machine
    forall a. Maybe a
    Nothing

    -- Modifying vectors
      Text
    "Clash.Sized.Vector.replace_int" -- :: KnownNat n => Vec n a -> Int -> a -> Vec n a
        | Type
    nTy : Type
    aTy : [Type]
    _  <- [Type]
    tys
        , Value
    _ : Value
    xs : Value
    i : Value
    a : [Value]
    _ <- [Value]
    args
        , DC DataCon
    intDc [Left (Literal (IntLiteral Integer
    i'))] <- Value
    i
        -> if Integer
    i' Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    < Integer
    0
              then Maybe Machine
    forall a. Maybe a
    Nothing
              else case Value
    xs of
                     DC DataCon
    vecTcNm [Either Term Type]
    vArgs -> case Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy) of
                        Right Integer
    0  -> Maybe Machine
    forall a. Maybe a
    Nothing
                        Right Integer
    n' ->
                          if Integer
    i' Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    0
                             then Term -> Maybe Machine
    reduce (HasCallStack => DataCon -> Type -> Integer -> Term -> Term -> Term
    DataCon -> Type -> Integer -> Term -> Term -> Term
    mkVecCons DataCon
    vecTcNm Type
    aTy Integer
    n' (Value -> Term
    valToTerm Value
    a) ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2))
                             else Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                                  HasCallStack => DataCon -> Type -> Integer -> Term -> Term -> Term
    DataCon -> Type -> Integer -> Term -> Term -> Term
    mkVecCons DataCon
    vecTcNm Type
    aTy Integer
    n' ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
                                    (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                            [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                            ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                            ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                            ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                                            ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    intDc)
                                                          [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Integer
    i'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))])
                                            ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    a)
                                            ])
                        Either [Char] Integer
    _ -> Maybe Machine
    forall a. Maybe a
    Nothing
                     Value
    _ -> Maybe Machine
    forall a. Maybe a
    Nothing

    -- - specialized permutations
      Text
    "Clash.Sized.Vector.reverse" -- :: Vec n a -> Vec n a
        | Bool
    isSubj
        , Type
    nTy : Type
    aTy : [Type]
    _  <- [Type]
    tys
        , [DC DataCon
    vecDc [Either Term Type]
    vArgs] <- [Value]
    args
        -> case Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy) of
             Right Integer
    0 -> Term -> Maybe Machine
    reduce (DataCon -> Type -> Term
    mkVecNil DataCon
    vecDc Type
    aTy)
             Right Integer
    n
               | ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    vecTcNm [Type]
    _) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               , let (Just TyCon
    vecTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    vecTcNm TyConMap
    tcm
               , let [DataCon
    nilCon,DataCon
    consCon] = TyCon -> [DataCon]
    tyConDataCons TyCon
    vecTc
               -> Term -> Maybe Machine
    reduceWHNF (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                  Term -> [Either Term Type] -> Term
    mkApps (TyConName -> Term
    vecAppendPrim TyConName
    vecTcNm)
                    [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    nInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                    ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                    ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy Integer
    1))
                    ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                  [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    nInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                  ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                  ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                                  ])
                    ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (DataCon -> DataCon -> Type -> Integer -> [Term] -> Term
    mkVec DataCon
    nilCon DataCon
    consCon Type
    aTy Integer
    1 [[Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1])
                    ]
             Either [Char] Integer
    _ -> Maybe Machine
    forall a. Maybe a
    Nothing
      Text
    "Clash.Sized.Vector.transpose" -- :: KnownNat n => Vec m (Vec n a) -> Vec n (Vec m a)
        | Bool
    isSubj
        , Type
    nTy : Type
    mTy : Type
    aTy : [Type]
    _ <- [Type]
    tys
        , Value
    kn : Value
    xss : [Value]
    _ <- [Value]
    args
        , ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    vecTcNm [Type]
    _) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
        , DC DataCon
    _ [Either Term Type]
    vArgs <- Value
    xss
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        , Right Integer
    m <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    mTy)
        -> case Integer
    m of
          Integer
    0 -> let (Just TyCon
    vecTc)     = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    vecTcNm TyConMap
    tcm
                   [DataCon
    nilCon,DataCon
    consCon] = TyCon -> [DataCon]
    tyConDataCons TyCon
    vecTc
               in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                   DataCon -> DataCon -> Type -> Integer -> [Term] -> Term
    mkVec DataCon
    nilCon DataCon
    consCon (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    mTy,Type
    aTy]) Integer
    n
                    (Unique -> Term -> [Term]
    forall a. Unique -> a -> [a]
    replicate (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    n) (DataCon -> DataCon -> Type -> Integer -> [Term] -> Term
    mkVec DataCon
    nilCon DataCon
    consCon Type
    aTy Integer
    0 []))
          Integer
    m' -> let (Just TyCon
    vecTc)     = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    vecTcNm TyConMap
    tcm
                    [DataCon
    _,DataCon
    consCon] = TyCon -> [DataCon]
    tyConDataCons TyCon
    vecTc
                    Just (Type
    consCoTy : [Type]
    _) = DataCon -> [Type] -> Maybe [Type]
    dataConInstArgTys DataCon
    consCon
                                            [Type
    mTy,Type
    aTy,LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    m'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1))]
                in  Term -> Maybe Machine
    reduceWHNF (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                    Term -> [Either Term Type] -> Term
    mkApps (TyConName -> Term
    vecZipWithPrim TyConName
    vecTcNm)
                           [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                           , Type -> Either Term Type
    forall a b. b -> Either a b
    Right (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    m'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)),Type
    aTy])
                           , Type -> Either Term Type
    forall a b. b -> Either a b
    Right (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    mTy,Type
    aTy])
                           , Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    nTy
                           , Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    consCon)
                                           [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    mTy
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    m'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Type -> Term
    primCo Type
    consCoTy)
                                           ])
                           , Term -> Either Term Type
    forall a b. a -> Either a b
    Left  ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
                           , Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                           [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    nTy
                                           , Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    m'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                           , Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                           , Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (Value -> Term
    valToTerm Value
    kn)
                                           , Term -> Either Term Type
    forall a b. a -> Either a b
    Left  ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                                           ])
                           ]

      Text
    "Clash.Sized.Vector.rotateLeftS" -- :: KnownNat n => Vec n a -> SNat d -> Vec n a
        | Type
    nTy : Type
    aTy : Type
    _ : [Type]
    _ <- [Type]
    tys
        , Value
    kn : Value
    xs : Value
    d : [Value]
    _ <- [Value]
    args
        , DC DataCon
    dc [Either Term Type]
    vArgs <- Value
    xs
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> case Integer
    n of
             Integer
    0  -> Term -> Maybe Machine
    reduce (DataCon -> Type -> Term
    mkVecNil DataCon
    dc Type
    aTy)
             Integer
    n' | DC DataCon
    snatDc [Either Term Type
    _,Left Term
    d'] <- Value
    d
                , Evaluator
    eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
    Evaluator Step
    ghcStep Unwind
    ghcUnwind PrimStep
    ghcPrimStep PrimUnwind
    ghcPrimUnwind
                , mach2 :: Machine
    mach2@Machine{mStack :: Machine -> Stack
    mStack=[],mTerm :: Machine -> Term
    mTerm=Literal (NaturalLiteral Integer
    d2)} <- Evaluator -> TyConMap -> Bool -> Machine -> Machine
    whnf Evaluator
    eval TyConMap
    tcm Bool
    isSubj (Term -> Machine -> Machine
    setTerm Term
    d' (Machine -> Machine) -> Machine -> Machine
    forall a b. (a -> b) -> a -> b
    $ Machine -> Machine
    stackClear Machine
    mach)
                -> case (Integer
    d2 Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `mod` Integer
    n) of
                     Integer
    0  -> Term -> Maybe Machine
    reduce (Value -> Term
    valToTerm Value
    xs)
                     Integer
    d3 -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    vecTcNm [Type]
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                               (Just TyCon
    vecTc)     = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    vecTcNm TyConMap
    tcm
                               [DataCon
    nilCon,DataCon
    consCon] = TyCon -> [DataCon]
    tyConDataCons TyCon
    vecTc
                           in  Machine -> Term -> Maybe Machine
    reduceWHNF' Machine
    mach2 (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                               Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                      [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    nTy
                                      ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                      ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    d3Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                      ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    kn)
                                      ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (TyConName -> Term
    vecAppendPrim TyConName
    vecTcNm)
                                                    [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                                    ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                                    ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy Integer
    1))
                                                    ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left  ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                                                    ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (DataCon -> DataCon -> Type -> Integer -> [Term] -> Term
    mkVec DataCon
    nilCon DataCon
    consCon Type
    aTy Integer
    1 [[Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1])])
                                      ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    snatDc)
                                                    [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    d3Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                                    ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    d3Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))])
                                      ]
             Integer
    _  -> Maybe Machine
    forall a. Maybe a
    Nothing

      Text
    "Clash.Sized.Vector.rotateRightS" -- :: KnownNat n => Vec n a -> SNat d -> Vec n a
        | Bool
    isSubj
        , Type
    nTy : Type
    aTy : Type
    _ : [Type]
    _ <- [Type]
    tys
        , Value
    kn : Value
    xs : Value
    d : [Value]
    _ <- [Value]
    args
        , DC DataCon
    dc [Either Term Type]
    _ <- Value
    xs
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> case Integer
    n of
             Integer
    0  -> Term -> Maybe Machine
    reduce (DataCon -> Type -> Term
    mkVecNil DataCon
    dc Type
    aTy)
             Integer
    n' | DC DataCon
    snatDc [Either Term Type
    _,Left Term
    d'] <- Value
    d
                , Evaluator
    eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
    Evaluator Step
    ghcStep Unwind
    ghcUnwind PrimStep
    ghcPrimStep PrimUnwind
    ghcPrimUnwind
                , mach2 :: Machine
    mach2@Machine{mStack :: Machine -> Stack
    mStack=[],mTerm :: Machine -> Term
    mTerm=Literal (NaturalLiteral Integer
    d2)} <- Evaluator -> TyConMap -> Bool -> Machine -> Machine
    whnf Evaluator
    eval TyConMap
    tcm Bool
    isSubj (Term -> Machine -> Machine
    setTerm Term
    d' (Machine -> Machine) -> Machine -> Machine
    forall a b. (a -> b) -> a -> b
    $ Machine -> Machine
    stackClear Machine
    mach)
                -> case (Integer
    d2 Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `mod` Integer
    n) of
                     Integer
    0  -> Term -> Maybe Machine
    reduce (Value -> Term
    valToTerm Value
    xs)
                     Integer
    d3 -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    vecTcNm [Type]
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                           in  Machine -> Term -> Maybe Machine
    reduceWHNF' Machine
    mach2 (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                               Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                      [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    nTy
                                      ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                      ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    d3Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                      ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    kn)
                                      ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (HasCallStack => DataCon -> Type -> Integer -> Term -> Term -> Term
    DataCon -> Type -> Integer -> Term -> Term -> Term
    mkVecCons DataCon
    dc Type
    aTy Integer
    n
                                              (Term -> [Either Term Type] -> Term
    mkApps (TyConName -> Term
    vecLastPrim TyConName
    vecTcNm)
                                                      [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                                      ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                                      ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (Value -> Term
    valToTerm Value
    xs)])
                                              (Term -> [Either Term Type] -> Term
    mkApps (TyConName -> Term
    vecInitPrim TyConName
    vecTcNm)
                                                      [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                                      ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                                      ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    xs)]))
                                      ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    snatDc)
                                                    [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    d3Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                                    ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    d3Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))])
                                      ]
             Integer
    _  -> Maybe Machine
    forall a. Maybe a
    Nothing
    -- Element-wise operations
    -- - mapping
      Text
    "Clash.Sized.Vector.map" -- :: (a -> b) -> Vec n a -> Vec n b
        | Bool
    isSubj
        , DC DataCon
    dc [Either Term Type]
    vArgs <- [Value]
    args [Value] -> Unique -> Value
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1
        , Type
    aTy : Type
    bTy : Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> case Integer
    n of
             Integer
    0  -> Term -> Maybe Machine
    reduce (DataCon -> Type -> Term
    mkVecNil DataCon
    dc Type
    bTy)
             Integer
    n' -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                   HasCallStack => DataCon -> Type -> Integer -> Term -> Term -> Term
    DataCon -> Type -> Integer -> Term -> Term -> Term
    mkVecCons DataCon
    dc Type
    bTy Integer
    n'
                     (Term -> [Either Term Type] -> Term
    mkApps (Value -> Term
    valToTerm ([Value]
    args [Value] -> Unique -> Value
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    0)) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)])
                     (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                          [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                          ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    bTy
                                          ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n' Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1)))
                                          ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm ([Value]
    args [Value] -> Unique -> Value
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    0))
                                          ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)])
      Text
    "Clash.Sized.Vector.imap" -- :: forall n a b . KnownNat n => (Index n -> a -> b) -> Vec n a -> Vec n b
        | Bool
    isSubj
        , Type
    nTy : Type
    aTy : Type
    bTy : [Type]
    _ <- [Type]
    tys
        , ([Either TyVar Type]
    tyArgs,Type -> TypeView
    tyView -> TyConApp TyConName
    vecTcNm [Type]
    _) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
        , let ([Either TyVar Type]
    tyArgs',Type
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy ([Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights [Either TyVar Type]
    tyArgs [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
        , TyConApp TyConName
    indexTcNm [Type]
    _ <- Type -> TypeView
    tyView ([Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights [Either TyVar Type]
    tyArgs' [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    0)
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        , let iLit :: Term
    iLit = Type -> Type -> Integer -> Integer -> Term
    mkIndexLit ([Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights [Either TyVar Type]
    tyArgs' [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    0) Type
    nTy Integer
    n Integer
    0
        -> Term -> Maybe Machine
    reduceWHNF (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
           Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim (Text
    -> Type -> WorkInfo -> IsMultiPrim -> PrimUnfolding -> PrimInfo
    PrimInfo Text
    "Clash.Sized.Vector.imap_go" (TyConName -> TyConName -> Type
    vecImapGoTy TyConName
    vecTcNm TyConName
    indexTcNm) WorkInfo
    WorkNever IsMultiPrim
    SingleResult PrimUnfolding
    NoUnfolding))
                  [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    nTy
                  ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    nTy
                  ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                  ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    bTy
                  ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm ([Value]
    args [Value] -> Unique -> Value
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1))
                  ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm ([Value]
    args [Value] -> Unique -> Value
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2))
                  ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left Term
    iLit
                  ]

      Text
    "Clash.Sized.Vector.imap_go"
        | Bool
    isSubj
        , Type
    nTy : Type
    mTy : Type
    aTy : Type
    bTy : [Type]
    _ <- [Type]
    tys
        , Value
    f : Value
    xs : (Suspend Term
    nArg) : [Value]
    _ <- [Value]
    args
        , DC DataCon
    dc [Either Term Type]
    vArgs <- Value
    xs
        , Right Integer
    n' <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        , Right Integer
    m <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    mTy)
        -> case Integer
    m of
             Integer
    0  -> Term -> Maybe Machine
    reduce (DataCon -> Type -> Term
    mkVecNil DataCon
    dc Type
    bTy)
             Integer
    m'
              | Evaluator
    eval <- Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
    Evaluator Step
    ghcStep Unwind
    ghcUnwind PrimStep
    ghcPrimStep PrimUnwind
    ghcPrimUnwind
              , mach1 :: Machine
    mach1@Machine{mStack :: Machine -> Stack
    mStack=[],mTerm :: Machine -> Term
    mTerm=Term
    n} <-
                  Evaluator -> TyConMap -> Bool -> Machine -> Machine
    whnf Evaluator
    eval TyConMap
    tcm Bool
    True (Term -> Machine -> Machine
    setTerm Term
    nArg (Machine -> Machine
    stackClear Machine
    mach))
              ->  let ([Either TyVar Type]
    tyArgs,Type
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                      TyConApp TyConName
    indexTcNm [Type]
    _ = Type -> TypeView
    tyView ([Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights [Either TyVar Type]
    tyArgs [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                      iLit :: Term
    iLit = Type -> Type -> Integer -> Integer -> Term
    mkIndexLit ([Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights [Either TyVar Type]
    tyArgs [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2) Type
    nTy Integer
    n' Integer
    1
                   in Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ (Term -> Machine -> Machine) -> Machine -> Term -> Machine
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip Term -> Machine -> Machine
    setTerm (Machine
    mach1 {mStack :: Stack
    mStack = Machine -> Stack
    mStack Machine
    mach}) (Term -> Machine) -> Term -> Machine
    forall a b. (a -> b) -> a -> b
    $ HasCallStack => DataCon -> Type -> Integer -> Term -> Term -> Term
    DataCon -> Type -> Integer -> Term -> Term -> Term
    mkVecCons DataCon
    dc Type
    bTy Integer
    m'
                     (Term -> [Either Term Type] -> Term
    mkApps (Value -> Term
    valToTerm Value
    f) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left Term
    n,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)])
                     (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                             [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    nTy
                             ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    m'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                             ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                             ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    bTy
                             ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    f)
                             ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                             ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim (Text
    -> Type -> WorkInfo -> IsMultiPrim -> PrimUnfolding -> PrimInfo
    PrimInfo Text
    "Clash.Sized.Internal.Index.+#" (TyConName -> Type
    indexAddTy TyConName
    indexTcNm) WorkInfo
    WorkVariable IsMultiPrim
    SingleResult PrimUnfolding
    NoUnfolding))
                                           [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    nTy
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral Integer
    n'))
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left Term
    n
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left Term
    iLit
                                           ])
                             ])
              | Bool
    otherwise
              -> Maybe Machine
    forall a. Maybe a
    Nothing

      -- :: forall n a. KnownNat n => (a -> a) -> a -> Vec n a
      Text
    "Clash.Sized.Vector.iterateI"
        | Bool
    isSubj
        , [Type
    nTy, Type
    aTy] <- [Type]
    tys
        , [Value
    _n, Value
    f, Value
    a] <- [Value]
    args
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        ->
          let
            TyConApp TyConName
    vecTcNm [Type]
    _ = Type -> TypeView
    tyView (TyConMap -> Type -> [Type] -> Type
    getResultTy TyConMap
    tcm Type
    ty [Type]
    tys)
            Just TyCon
    vecTc = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    vecTcNm TyConMap
    tcm
            [DataCon
    nilCon, DataCon
    consCon] = TyCon -> [DataCon]
    tyConDataCons TyCon
    vecTc
          in case Integer
    n of
             Integer
    0 -> Term -> Maybe Machine
    reduce (DataCon -> Type -> Term
    mkVecNil DataCon
    nilCon Type
    aTy)
             Integer
    _ -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
              HasCallStack => DataCon -> Type -> Integer -> Term -> Term -> Term
    DataCon -> Type -> Integer -> Term -> Term -> Term
    mkVecCons DataCon
    consCon Type
    aTy Integer
    n
                (Value -> Term
    valToTerm Value
    a)
                (Term -> [Either Term Type] -> Term
    mkApps
                  (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                  [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1)))
                  , Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                  , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm (Literal -> Value
    Lit (Integer -> Literal
    NaturalLiteral (Integer
    n Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1))))
                  , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    f)
                  , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (Value -> Term
    valToTerm Value
    f) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    a)])
                  ])

    -- - Zipping
      Text
    "Clash.Sized.Vector.zipWith" -- :: (a -> b -> c) -> Vec n a -> Vec n b -> Vec n c
        | Bool
    isSubj
        , Type
    aTy : Type
    bTy : Type
    cTy : Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Value
    f : Value
    xs : Value
    ys : [Value]
    _   <- [Value]
    args
        , DC DataCon
    dc [Either Term Type]
    vArgs <- Value
    xs
        , ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    vecTcNm [Type]
    _) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> case Integer
    n of
             Integer
    0  -> Term -> Maybe Machine
    reduce (DataCon -> Type -> Term
    mkVecNil DataCon
    dc Type
    cTy)
             Integer
    n' -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ HasCallStack => DataCon -> Type -> Integer -> Term -> Term -> Term
    DataCon -> Type -> Integer -> Term -> Term -> Term
    mkVecCons DataCon
    dc Type
    cTy Integer
    n'
                     (Term -> [Either Term Type] -> Term
    mkApps (Value -> Term
    valToTerm Value
    f)
                                [Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
                                ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (TyConName -> Term
    vecHeadPrim TyConName
    vecTcNm)
                                        [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                        ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    bTy
                                        ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (Value -> Term
    valToTerm Value
    ys)
                                        ])
                                ])
                     (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                          [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                          ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    bTy
                                          ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    cTy
                                          ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n' Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1)))
                                          ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    f)
                                          ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                                          ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (TyConName -> Term
    vecTailPrim TyConName
    vecTcNm)
                                                        [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                                        ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    bTy
                                                        ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    ys)
                                                        ])])

    -- Folding
      Text
    "Clash.Sized.Vector.foldr" -- :: (a -> b -> b) -> b -> Vec n a -> b
        | Bool
    isSubj
        , Type
    aTy : Type
    bTy : Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Value
    f : Value
    z : Value
    xs : [Value]
    _ <- [Value]
    args
        , DC DataCon
    _ [Either Term Type]
    vArgs <- Value
    xs
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> case Integer
    n of
             Integer
    0 -> Term -> Maybe Machine
    reduce (Value -> Term
    valToTerm Value
    z)
             Integer
    _ -> Term -> Maybe Machine
    reduceWHNF (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                  Term -> [Either Term Type] -> Term
    mkApps (Value -> Term
    valToTerm Value
    f)
                         [Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
                         ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                       [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                       ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    bTy
                                       ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    nInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                       ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (Value -> Term
    valToTerm Value
    f)
                                       ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (Value -> Term
    valToTerm Value
    z)
                                       ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left  ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                                       ])
                         ]
      Text
    "Clash.Sized.Vector.fold" -- :: (a -> a -> a) -> Vec (n + 1) a -> a
        | Bool
    isSubj
        , Type
    nTy : Type
    aTy :  [Type]
    _ <- [Type]
    tys
        , Value
    f : Value
    vs : [Value]
    _ <- [Value]
    args
        , DC DataCon
    _ [Either Term Type]
    vArgs <- Value
    vs
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> case Integer
    n of
             Integer
    0 -> Term -> Maybe Machine
    reduceWHNF ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
             Integer
    _ -> let ([Either TyVar Type]
    tyArgs,Type
    _)         = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                      TyConApp TyConName
    vecTcNm [Type]
    _ = Type -> TypeView
    tyView ([Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights [Either TyVar Type]
    tyArgs [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
                      tupTcNm :: TyConName
    tupTcNm      = TyCon -> TyConName
    ghcTyconToTyConName (Boxity -> Unique -> TyCon
    tupleTyCon Boxity
    Boxed Unique
    2)
                      (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
                      [DataCon
    tupDc]      = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
                      n' :: Integer
    n'     = Integer
    nInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    +Integer
    1
                      m :: Integer
    m      = Integer
    n' Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `div` Integer
    2
                      n1 :: Integer
    n1     = Integer
    n' Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    m
                      mTy :: Type
    mTy    = LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy Integer
    m)
                      m'ty :: Type
    m'ty   = LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    mInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1))
                      n1mTy :: Type
    n1mTy  = LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy Integer
    n1)
                      n1m'ty :: Type
    n1m'ty = LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n1Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1))
                      splitAtCall :: Term
    splitAtCall =
                       Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim (Text
    -> Type -> WorkInfo -> IsMultiPrim -> PrimUnfolding -> PrimInfo
    PrimInfo Text
    "Clash.Sized.Vector.fold_split" (TyConName -> Type
    foldSplitAtTy TyConName
    vecTcNm) WorkInfo
    WorkNever IsMultiPrim
    SingleResult PrimUnfolding
    NoUnfolding))
                              [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    mTy
                              ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    n1mTy
                              ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                              ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral Integer
    m))
                              ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    vs)
                              ]
                      mVecTy :: Type
    mVecTy   = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    mTy,Type
    aTy]
                      n1mVecTy :: Type
    n1mVecTy = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    n1mTy,Type
    aTy]
                      -- Guaranteed no capture, so okay to use unsafe name generation
                      asNm :: Name a
    asNm     = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "as" Unique
    0
                      bsNm :: Name a
    bsNm     = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "bs" Unique
    1
                      asId :: Id
    asId     = Type -> TmName -> Id
    mkLocalId Type
    mVecTy TmName
    forall {a}. Name a
    asNm
                      bsId :: Id
    bsId     = Type -> TmName -> Id
    mkLocalId Type
    n1mVecTy TmName
    forall {a}. Name a
    bsNm
                      tupPat :: Pat
    tupPat   = DataCon -> [TyVar] -> [Id] -> Pat
    DataPat DataCon
    tupDc [] [Id
    asId,Id
    bsId]
                      asAlt :: (Pat, Term)
    asAlt    = (Pat
    tupPat, (Id -> Term
    Var Id
    asId))
                      bsAlt :: (Pat, Term)
    bsAlt    = (Pat
    tupPat, (Id -> Term
    Var Id
    bsId))
                  in  Term -> Maybe Machine
    reduceWHNF (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                      Term -> [Either Term Type] -> Term
    mkApps (Value -> Term
    valToTerm Value
    f)
                             [Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                           [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    m'ty
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    f)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Type -> [(Pat, Term)] -> Term
    Case Term
    splitAtCall Type
    mVecTy [(Pat, Term)
    asAlt])
                                           ])
                             ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                           [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    n1m'ty
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (Value -> Term
    valToTerm Value
    f)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (Term -> Type -> [(Pat, Term)] -> Term
    Case Term
    splitAtCall Type
    n1mVecTy [(Pat, Term)
    bsAlt])
                                           ])
                             ]

      Text
    "Clash.Sized.Vector.fold_split" -- :: Natural -> Vec (m + n) a -> (Vec m a, Vec n a)
        | Bool
    isSubj
        , Type
    mTy : Type
    nTy : Type
    aTy : [Type]
    _ <- [Type]
    tys
        , Right Integer
    m <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    mTy)
        -> let -- Get the tuple data-constructor
               ty1 :: Type
    ty1 = HasCallStack => TyConMap -> Type -> [Type] -> Type
    TyConMap -> Type -> [Type] -> Type
    piResultTys TyConMap
    tcm Type
    ty [Type]
    tys
               ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm tyArgs :: [Type]
    tyArgs@(Type
    tyArg:[Type]
    _)) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty1
               (Just TyCon
    tupTc)       = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc]            = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               -- Get the vector data-constructors
               TyConApp TyConName
    vecTcNm [Type]
    _ = Type -> TypeView
    tyView Type
    tyArg
               Just TyCon
    vecTc         = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    vecTcNm TyConMap
    tcm
               [DataCon
    nilCon,DataCon
    consCon]   = TyCon -> [DataCon]
    tyConDataCons TyCon
    vecTc
               -- Recursive call to @splitAt@
               splitAtRec :: Term -> Term
    splitAtRec Term
    v =
                Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                       [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    mInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                       ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    nTy
                       ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                       ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    mInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                       ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left Term
    v
                       ]
               -- Projection either the first or second field of the recursive
               -- call to @splitAt@
               splitAtSelR :: Term -> Type -> [(Pat, Term)] -> Term
    splitAtSelR Term
    v = Term -> Type -> [(Pat, Term)] -> Term
    Case (Term -> Term
    splitAtRec Term
    v)
               m1VecTy :: Type
    m1VecTy = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    mInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)),Type
    aTy]
               nVecTy :: Type
    nVecTy  = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    nTy,Type
    aTy]
               -- Guaranteed no capture, so okay to use unsafe name generation
               lNm :: Name a
    lNm     = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "l" Unique
    0
               rNm :: Name a
    rNm     = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "r" Unique
    1
               lId :: Id
    lId     = Type -> TmName -> Id
    mkLocalId Type
    m1VecTy TmName
    forall {a}. Name a
    lNm
               rId :: Id
    rId     = Type -> TmName -> Id
    mkLocalId Type
    nVecTy TmName
    forall {a}. Name a
    rNm
               tupPat :: Pat
    tupPat  = DataCon -> [TyVar] -> [Id] -> Pat
    DataPat DataCon
    tupDc [] [Id
    lId,Id
    rId]
               lAlt :: (Pat, Term)
    lAlt    = (Pat
    tupPat, (Id -> Term
    Var Id
    lId))
               rAlt :: (Pat, Term)
    rAlt    = (Pat
    tupPat, (Id -> Term
    Var Id
    rId))
           in case Integer
    m of
             -- (Nil,v)
             Integer
    0 -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                  Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ([Either Term Type] -> Term) -> [Either Term Type] -> Term
    forall a b. (a -> b) -> a -> b
    $ ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs) [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                    [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (DataCon -> Type -> Term
    mkVecNil DataCon
    nilCon Type
    aTy)
                    , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm ([Value] -> Value
    forall a. HasCallStack => [a] -> a
    last [Value]
    args))
                    ]
             -- (x:xs) <- v
             Integer
    m' | DC DataCon
    _ [Either Term Type]
    vArgs <- [Value] -> Value
    forall a. HasCallStack => [a] -> a
    last [Value]
    args
                -- (x:fst (splitAt (m-1) xs),snd (splitAt (m-1) xs))
                -> Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                   Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ([Either Term Type] -> Term) -> [Either Term Type] -> Term
    forall a b. (a -> b) -> a -> b
    $ ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs) [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                     [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (HasCallStack => DataCon -> Type -> Integer -> Term -> Term -> Term
    DataCon -> Type -> Integer -> Term -> Term -> Term
    mkVecCons DataCon
    consCon Type
    aTy Integer
    m' ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
                               (Term -> Type -> [(Pat, Term)] -> Term
    splitAtSelR ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2) Type
    m1VecTy [(Pat, Term)
    lAlt]))
                     , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Type -> [(Pat, Term)] -> Term
    splitAtSelR ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2) Type
    nVecTy [(Pat, Term)
    rAlt])
                     ]
             -- v doesn't reduce to a data-constructor
             Integer
    _  -> Maybe Machine
    forall a. Maybe a
    Nothing
    -- - Specialised folds
      Text
    "Clash.Sized.Vector.dfold"
        | Bool
    isSubj
        , Type
    pTy : Type
    kTy : Type
    aTy : [Type]
    _ <- [Type]
    tys
        , Value
    _ : Value
    p : Value
    f : Value
    z : Value
    xs : [Value]
    _ <- [Value]
    args
        , DC DataCon
    _ [Either Term Type]
    vArgs <- Value
    xs
        , Right Integer
    k' <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    kTy)
        -> case Integer
    k'  of
             Integer
    0 -> Term -> Maybe Machine
    reduce (Value -> Term
    valToTerm Value
    z)
             Integer
    _ -> let ([Either TyVar Type]
    tyArgs,Type
    _)  = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                      ([Either TyVar Type]
    tyArgs',Type
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy ([Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights [Either TyVar Type]
    tyArgs [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                      TyConApp TyConName
    snatTcNm [Type]
    _ = Type -> TypeView
    tyView ([Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights [Either TyVar Type]
    tyArgs' [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    0)
                      Just TyCon
    snatTc = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    snatTcNm TyConMap
    tcm
                      [DataCon
    snatDc]    = TyCon -> [DataCon]
    tyConDataCons TyCon
    snatTc
                      k'ty :: Type
    k'ty        = LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    k'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1))
                  in  Term -> Maybe Machine
    reduceWHNF (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                      Term -> [Either Term Type] -> Term
    mkApps (Value -> Term
    valToTerm Value
    f)
                             [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    k'ty
                             ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    snatDc)
                                           [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    k'ty
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    k'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))])
                             ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
                             ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                           [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    pTy
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    k'ty
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    k'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    p)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    f)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    z)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                                           ])
                             ]
      Text
    "Clash.Sized.Vector.dtfold"
        | Bool
    isSubj
        , Type
    pTy : Type
    kTy : Type
    aTy : [Type]
    _ <- [Type]
    tys
        , Value
    _ : Value
    p : Value
    f : Value
    g : Value
    xs : [Value]
    _ <- [Value]
    args
        , DC DataCon
    _ [Either Term Type]
    vArgs <- Value
    xs
        , Right Integer
    k' <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    kTy)
        -> case Integer
    k' of
             Integer
    0 -> Term -> Maybe Machine
    reduceWHNF (Term -> [Either Term Type] -> Term
    mkApps (Value -> Term
    valToTerm Value
    f) [Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)])
             Integer
    _ -> let ([Either TyVar Type]
    tyArgs,Type
    _)  = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                      TyConApp TyConName
    vecTcNm [Type]
    _ = Type -> TypeView
    tyView ([Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights [Either TyVar Type]
    tyArgs [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    4)
                      ([Either TyVar Type]
    tyArgs',Type
    _) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy ([Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights [Either TyVar Type]
    tyArgs [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    3)
                      TyConApp TyConName
    snatTcNm [Type]
    _ = Type -> TypeView
    tyView ([Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights [Either TyVar Type]
    tyArgs' [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    0)
                      Just TyCon
    snatTc = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    snatTcNm TyConMap
    tcm
                      [DataCon
    snatDc]    = TyCon -> [DataCon]
    tyConDataCons TyCon
    snatTc
                      tupTcNm :: TyConName
    tupTcNm     = TyCon -> TyConName
    ghcTyconToTyConName (Boxity -> Unique -> TyCon
    tupleTyCon Boxity
    Boxed Unique
    2)
                      (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
                      [DataCon
    tupDc]     = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
                      k'ty :: Type
    k'ty        = LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    k'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1))
                      k2ty :: Type
    k2ty        = LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    2Integer -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^(Integer
    k'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                      splitAtCall :: Term
    splitAtCall =
                       Term -> [Either Term Type] -> Term
    mkApps (TyConName -> TyConName -> Term
    splitAtPrim TyConName
    snatTcNm TyConName
    vecTcNm)
                              [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    k2ty
                              ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    k2ty
                              ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                              ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    snatDc)
                                            [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    k2ty
                                            ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    2Integer -> Integer -> Integer
    forall a b. (Num a, Integral b) => a -> b -> a
    ^(Integer
    k'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1))))])
                              ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    xs)
                              ]
                      xsSVecTy :: Type
    xsSVecTy = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    k2ty,Type
    aTy]
                      -- Guaranteed no capture, so okay to use unsafe name generation
                      xsLNm :: Name a
    xsLNm    = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "xsL" Unique
    0
                      xsRNm :: Name a
    xsRNm    = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "xsR" Unique
    1
                      xsLId :: Id
    xsLId    = Type -> TmName -> Id
    mkLocalId Type
    k2ty TmName
    forall {a}. Name a
    xsLNm
                      xsRId :: Id
    xsRId    = Type -> TmName -> Id
    mkLocalId Type
    k2ty TmName
    forall {a}. Name a
    xsRNm
                      tupPat :: Pat
    tupPat   = DataCon -> [TyVar] -> [Id] -> Pat
    DataPat DataCon
    tupDc [] [Id
    xsLId,Id
    xsRId]
                      asAlt :: (Pat, Term)
    asAlt    = (Pat
    tupPat, (Id -> Term
    Var Id
    xsLId))
                      bsAlt :: (Pat, Term)
    bsAlt    = (Pat
    tupPat, (Id -> Term
    Var Id
    xsRId))
                  in  Term -> Maybe Machine
    reduceWHNF (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                      Term -> [Either Term Type] -> Term
    mkApps (Value -> Term
    valToTerm Value
    g)
                             [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    k'ty
                             ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    snatDc)
                                           [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    k'ty
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    k'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))])
                             ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                           [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    pTy
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    k'ty
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    k'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    p)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    f)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    g)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Type -> [(Pat, Term)] -> Term
    Case Term
    splitAtCall Type
    xsSVecTy [(Pat, Term)
    asAlt])])
                             ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                           [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    pTy
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    k'ty
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    k'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    p)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    f)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    g)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Type -> [(Pat, Term)] -> Term
    Case Term
    splitAtCall Type
    xsSVecTy [(Pat, Term)
    bsAlt])])
                             ]
    -- Misc
      Text
    "Clash.Sized.Vector.lazyV"
        | Bool
    isSubj
        , Type
    nTy : Type
    aTy : [Type]
    _ <- [Type]
    tys
        , Value
    _ : Value
    xs : [Value]
    _ <- [Value]
    args
        , ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    vecTcNm [Type]
    _) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> case Integer
    n of
             Integer
    0  -> let (Just TyCon
    vecTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    vecTcNm TyConMap
    tcm
                       [DataCon
    nilCon,DataCon
    _]   = TyCon -> [DataCon]
    tyConDataCons TyCon
    vecTc
                   in  Term -> Maybe Machine
    reduce (DataCon -> Type -> Term
    mkVecNil DataCon
    nilCon Type
    aTy)
             Integer
    n' -> let (Just TyCon
    vecTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    vecTcNm TyConMap
    tcm
                       [DataCon
    _,DataCon
    consCon]  = TyCon -> [DataCon]
    tyConDataCons TyCon
    vecTc
                   in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ HasCallStack => DataCon -> Type -> Integer -> Term -> Term -> Term
    DataCon -> Type -> Integer -> Term -> Term -> Term
    mkVecCons DataCon
    consCon Type
    aTy Integer
    n'
                         (Term -> [Either Term Type] -> Term
    mkApps (TyConName -> Term
    vecHeadPrim TyConName
    vecTcNm)
                                 [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n' Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1)))
                                 , Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                 , Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (Value -> Term
    valToTerm Value
    xs)
                                 ])
                         (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                 [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n' Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1)))
                                 , Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                 , Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                 , Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (Term -> [Either Term Type] -> Term
    mkApps (TyConName -> Term
    vecTailPrim TyConName
    vecTcNm)
                                                 [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                                 , Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                                 , Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (Value -> Term
    valToTerm Value
    xs)
                                                 ])
                                 ])
    -- Traversable
      Text
    "Clash.Sized.Vector.traverse#"
        | Bool
    isSubj
        , Type
    aTy : Type
    fTy : Type
    bTy : Type
    nTy : [Type]
    _ <- [Type]
    tys
        , Value
    apDict : Value
    f : Value
    xs : [Value]
    _ <- [Value]
    args
        , DC DataCon
    dc [Either Term Type]
    vArgs <- Value
    xs
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> case Integer
    n of
             Integer
    0 -> let (Term
    pureF,Supply
    ids') = PrimEvalMonad Term -> Supply -> (Term, Supply)
    forall a. PrimEvalMonad a -> Supply -> (a, Supply)
    runPEM ([Char]
    -> InScopeSet
    -> TyConMap
    -> Term
    -> Unique
    -> Unique
    -> PrimEvalMonad Term
    forall (m :: Type -> Type).
    (HasCallStack, MonadUnique m) =>
    [Char]
    -> InScopeSet -> TyConMap -> Term -> Unique -> Unique -> m Term
    mkSelectorCase $(curLoc) InScopeSet
    is0 TyConMap
    tcm (Value -> Term
    valToTerm Value
    apDict) Unique
    1 Unique
    1) Supply
    ids
                  in  Machine -> Term -> Maybe Machine
    reduceWHNF' (Machine
    mach { mSupply :: Supply
    mSupply = Supply
    ids' }) (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                      Term -> [Either Term Type] -> Term
    mkApps Term
    pureF
                             [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (TyConName -> [Type] -> Type
    mkTyConApp (TyConName
    vecTcNm) [Type
    nTy,Type
    bTy])
                             ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left  (DataCon -> Type -> Term
    mkVecNil DataCon
    dc Type
    bTy)]
             Integer
    _ -> let ((Term
    fmapF,Term
    apF),Supply
    ids') = (PrimEvalMonad (Term, Term) -> Supply -> ((Term, Term), Supply))
    -> Supply -> PrimEvalMonad (Term, Term) -> ((Term, Term), Supply)
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip PrimEvalMonad (Term, Term) -> Supply -> ((Term, Term), Supply)
    forall a. PrimEvalMonad a -> Supply -> (a, Supply)
    runPEM Supply
    ids (PrimEvalMonad (Term, Term) -> ((Term, Term), Supply))
    -> PrimEvalMonad (Term, Term) -> ((Term, Term), Supply)
    forall a b. (a -> b) -> a -> b
    $ do
                        Term
    fDict  <- [Char]
    -> InScopeSet
    -> TyConMap
    -> Term
    -> Unique
    -> Unique
    -> PrimEvalMonad Term
    forall (m :: Type -> Type).
    (HasCallStack, MonadUnique m) =>
    [Char]
    -> InScopeSet -> TyConMap -> Term -> Unique -> Unique -> m Term
    mkSelectorCase $(curLoc) InScopeSet
    is0 TyConMap
    tcm (Value -> Term
    valToTerm Value
    apDict) Unique
    1 Unique
    0
                        Term
    fmapF' <- [Char]
    -> InScopeSet
    -> TyConMap
    -> Term
    -> Unique
    -> Unique
    -> PrimEvalMonad Term
    forall (m :: Type -> Type).
    (HasCallStack, MonadUnique m) =>
    [Char]
    -> InScopeSet -> TyConMap -> Term -> Unique -> Unique -> m Term
    mkSelectorCase $(curLoc) InScopeSet
    is0 TyConMap
    tcm Term
    fDict Unique
    1 Unique
    0
                        Term
    apF'   <- [Char]
    -> InScopeSet
    -> TyConMap
    -> Term
    -> Unique
    -> Unique
    -> PrimEvalMonad Term
    forall (m :: Type -> Type).
    (HasCallStack, MonadUnique m) =>
    [Char]
    -> InScopeSet -> TyConMap -> Term -> Unique -> Unique -> m Term
    mkSelectorCase $(curLoc) InScopeSet
    is0 TyConMap
    tcm (Value -> Term
    valToTerm Value
    apDict) Unique
    1 Unique
    2
                        (Term, Term) -> PrimEvalMonad (Term, Term)
    forall a. a -> PrimEvalMonad a
    forall (m :: Type -> Type) a. Monad m => a -> m a
    return (Term
    fmapF',Term
    apF')
                      n'ty :: Type
    n'ty = LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    nInteger -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1))
                      Just (Type
    consCoTy : [Type]
    _) = DataCon -> [Type] -> Maybe [Type]
    dataConInstArgTys DataCon
    dc [Type
    nTy,Type
    bTy,Type
    n'ty]
                  in  Machine -> Term -> Maybe Machine
    reduceWHNF' (Machine
    mach { mSupply :: Supply
    mSupply = Supply
    ids' }) (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                      Term -> [Either Term Type] -> Term
    mkApps Term
    apF
                             [Type -> Either Term Type
    forall a b. b -> Either a b
    Right (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    n'ty,Type
    bTy])
                             ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    nTy,Type
    bTy])
                             ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps Term
    fmapF
                                           [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    bTy
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right (Type -> Type -> Type
    mkFunTy (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    n'ty,Type
    bTy])
                                                           (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    nTy,Type
    bTy]))
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    dc)
                                                         [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    nTy
                                                         ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    bTy
                                                         ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    n'ty
                                                         ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Type -> Term
    primCo Type
    consCoTy)])
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (Value -> Term
    valToTerm Value
    f)
                                                         [Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)])
                                           ])
                             ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                           [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    aTy
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    fTy
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    bTy
                                           ,Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    n'ty
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    apDict)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    f)
                                           ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                                           ])
                             ]
        where
          ([Either TyVar Type]
    tyArgs,Type
    _)         = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
          TyConApp TyConName
    vecTcNm [Type]
    _ = Type -> TypeView
    tyView ([Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights [Either TyVar Type]
    tyArgs [Type] -> Unique -> Type
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
          (Supply
    ids, InScopeSet
    is0) = (Machine -> Supply
    mSupply Machine
    mach, Machine -> InScopeSet
    mScopeNames Machine
    mach)

    -- BitPack
      Text
    "Clash.Sized.Vector.concatBitVector#"
        | Bool
    isSubj
        , Type
    nTy : Type
    mTy : [Type]
    _ <- [Type]
    tys
        , Value
    _  : Value
    km  : Value
    v : [Value]
    _ <- [Value]
    args
        , DC DataCon
    _ [Either Term Type]
    vArgs <- Value
    v
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> case Integer
    n of
             Integer
    0  -> let resTyInfo :: (Type, Type, Integer)
    resTyInfo = TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo TyConMap
    tcm Type
    ty [Type]
    tys
                   in  Term -> Maybe Machine
    reduce ((Type, Type, Integer) -> Integer -> Integer -> Term
    mkBitVectorLit' (Type, Type, Integer)
    resTyInfo Integer
    0 Integer
    0)
             Integer
    n' | Right Integer
    m <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    mTy)
                , ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    bvTcNm [Type]
    _) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
                -> Term -> Maybe Machine
    reduceWHNF (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $
                   Term -> [Either Term Type] -> Term
    mkApps (TyConName -> Term
    bvAppendPrim TyConName
    bvTcNm)
                     [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    typeNatMul [LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)),Type
    mTy])
                     , Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    mTy
                     , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral ((Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    *Integer
    m)))
                     , Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    1)
                     , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                                    [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                    , Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    mTy
                                    , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                                    , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    km)
                                    , Term -> Either Term Type
    forall a b. a -> Either a b
    Left ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    vArgs [Term] -> Unique -> Term
    forall a. HasCallStack => [a] -> Unique -> a
    !! Unique
    2)
                                    ])
                     ]
             Integer
    _ -> Maybe Machine
    forall a. Maybe a
    Nothing
      Text
    "Clash.Sized.Vector.unconcatBitVector#"
        | Bool
    isSubj
        , Type
    nTy : Type
    mTy : [Type]
    _  <- [Type]
    tys
        , Value
    _  : Value
    km  : Value
    bv : [Value]
    _ <- [Value]
    args
        , ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    vecTcNm [Type
    _,Type
    bvMTy]) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
        , TyConApp TyConName
    bvTcNm [Type]
    _ <- Type -> TypeView
    tyView Type
    bvMTy
        , Right Integer
    n <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> case Integer
    n of
             Integer
    0 ->
              let (Just TyCon
    vecTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    vecTcNm TyConMap
    tcm
                  [DataCon
    nilCon,DataCon
    _] = TyCon -> [DataCon]
    tyConDataCons TyCon
    vecTc
              in  Term -> Maybe Machine
    reduce (DataCon -> Type -> Term
    mkVecNil DataCon
    nilCon (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    bvTcNm [Type
    mTy]))
             Integer
    n' | Right Integer
    m <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    mTy) ->
              let Just TyCon
    vecTc  = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    vecTcNm TyConMap
    tcm
                  [DataCon
    _,DataCon
    consCon] = TyCon -> [DataCon]
    tyConDataCons TyCon
    vecTc
                  tupTcNm :: TyConName
    tupTcNm     = TyCon -> TyConName
    ghcTyconToTyConName (Boxity -> Unique -> TyCon
    tupleTyCon Boxity
    Boxed Unique
    2)
                  Just TyCon
    tupTc  = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
                  [DataCon
    tupDc]     = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
                  splitCall :: Term
    splitCall   =
                    Term -> [Either Term Type] -> Term
    mkApps (TyConName -> Term
    bvSplitPrim TyConName
    bvTcNm)
                           [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    typeNatMul [LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)),Type
    mTy])
                           , Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    mTy
                           , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral ((Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    *Integer
    m)))
                           , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    bv)
                           ]
                  mBVTy :: Type
    mBVTy       = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    bvTcNm [Type
    mTy]
                  n1BVTy :: Type
    n1BVTy      = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    bvTcNm
                                  [TyConName -> [Type] -> Type
    mkTyConApp TyConName
    typeNatMul
                                    [LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1))
                                    ,Type
    mTy]]
                  -- Guaranteed no capture, so okay to use unsafe name generation
                  xNm :: Name a
    xNm         = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "x" Unique
    0
                  bvNm :: Name a
    bvNm        = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "bv'" Unique
    1
                  xId :: Id
    xId         = Type -> TmName -> Id
    mkLocalId Type
    mBVTy TmName
    forall {a}. Name a
    xNm
                  bvId :: Id
    bvId        = Type -> TmName -> Id
    mkLocalId Type
    n1BVTy TmName
    forall {a}. Name a
    bvNm
                  tupPat :: Pat
    tupPat      = DataCon -> [TyVar] -> [Id] -> Pat
    DataPat DataCon
    tupDc [] [Id
    xId,Id
    bvId]
                  xAlt :: (Pat, Term)
    xAlt        = (Pat
    tupPat, (Id -> Term
    Var Id
    xId))
                  bvAlt :: (Pat, Term)
    bvAlt       = (Pat
    tupPat, (Id -> Term
    Var Id
    bvId))

              in  Term -> Maybe Machine
    reduce (Term -> Maybe Machine) -> Term -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ HasCallStack => DataCon -> Type -> Integer -> Term -> Term -> Term
    DataCon -> Type -> Integer -> Term -> Term -> Term
    mkVecCons DataCon
    consCon (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    bvTcNm [Type
    mTy]) Integer
    n'
                    (Term -> Type -> [(Pat, Term)] -> Term
    Case Term
    splitCall Type
    mBVTy [(Pat, Term)
    xAlt])
                    (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo)
                            [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                            , Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    mTy
                            , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral (Integer
    n'Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    -Integer
    1)))
                            , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Value -> Term
    valToTerm Value
    km)
                            , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Type -> [(Pat, Term)] -> Term
    Case Term
    splitCall Type
    n1BVTy [(Pat, Term)
    bvAlt])
                            ])
             Integer
    _ -> Maybe Machine
    forall a. Maybe a
    Nothing
    #if MIN_VERSION_ghc(9,4,0)
      Text
    "Data.Text.Show.$wunpackCStringAscii#"
        | [Lit (StringLiteral [Char]
    addr)] <- [Value]
    args
        , Text.Text (Text.ByteArray ByteArray#
    ba) Unique
    _off Unique
    len <- [Char] -> Text
    Text.pack [Char]
    addr
        -> let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
               (Just TyCon
    tupTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
               [DataCon
    tupDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
               ret :: Term
    ret     = Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                        [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (ByteArray -> Literal
    ByteArrayLiteral (ByteArray# -> ByteArray
    BA.ByteArray ByteArray#
    ba)))
                        , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral Integer
    0))
                        , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger Unique
    len)))])
            in Term -> Maybe Machine
    reduce Term
    ret
      Text
    "GHC.Magic.noinlineConstraint"
        | [Value
    arg] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Value -> Term
    valToTerm Value
    arg)
      Text
    "GHC.TypeNats.withSomeSNat"
        | Lit (NaturalLiteral Integer
    n) : Value
    fun : [Value]
    _ <- [Value]
    args
        , Type
    _ : Type
    funTy : [Type]
    _ <- [Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights (([Either TyVar Type], Type) -> [Either TyVar Type]
    forall a b. (a, b) -> a
    fst (Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty))
        , (Type -> TypeView
    tyView -> TyConApp TyConName
    snatTcNm [Type]
    _) : [Type]
    _ <- [Either TyVar Type] -> [Type]
    forall a b. [Either a b] -> [b]
    Either.rights (([Either TyVar Type], Type) -> [Either TyVar Type]
    forall a b. (a, b) -> a
    fst (Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    funTy))
        , Just TyCon
    snatTc <- TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    snatTcNm TyConMap
    tcm
        , [DataCon
    snatDc] <- TyCon -> [DataCon]
    tyConDataCons TyCon
    snatTc
        -> let nTy :: Type
    nTy = LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy Integer
    n)
               snat :: Term
    snat = Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    snatDc) [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    nTy, Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral Integer
    n))]
               ret :: Term
    ret = Term -> [Either Term Type] -> Term
    mkApps (Value -> Term
    valToTerm Value
    fun) [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    nTy, Term -> Either Term Type
    forall a b. a -> Either a b
    Left Term
    snat]
            in Term -> Maybe Machine
    reduce Term
    ret
      Text
    "GHC.Magic.nospec"
        | [Value
    arg] <- [Value]
    args
        -> Term -> Maybe Machine
    reduce (Value -> Term
    valToTerm Value
    arg)
      Text
    "GHC.Float.$wproperFractionDouble"
        | Value
    _ : Lit (DoubleLiteral Word64
    d) : [Value]
    _ <- [Value]
    args
        , [sty :: Type
    sty@(Type -> TypeView
    tyView -> TyConApp TyConName
    signedTcNm [nTy :: Type
    nTy@(LitTy (NumTy Integer
    kn))])] <- [Type]
    tys
        , TyConName -> Text
    forall a. Name a -> Text
    nameOcc TyConName
    signedTcNm Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    "Clash.Sized.Internal.Signed.Signed"
        , ([Either TyVar Type]
    _, Type -> TypeView
    tyView -> TyConApp TyConName
    tupTcNm [Type]
    tyArgs) <- Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
        , Just TyCon
    tupTc <- TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    tupTcNm TyConMap
    tcm
        , [DataCon
    tupDc] <- TyCon -> [DataCon]
    tyConDataCons TyCon
    tupTc
        -> let (Integer
    sn, Double
    d1) = Integer
    -> (forall (n :: Natural).
        KnownNat n =>
        Proxy n -> (Integer, Double))
    -> (Integer, Double)
    forall r.
    Integer -> (forall (n :: Natural). KnownNat n => Proxy n -> r) -> r
    reifyNat Integer
    kn (\Proxy n
    p -> (Signed n -> Integer) -> (Signed n, Double) -> (Integer, Double)
    forall a b c. (a -> b) -> (a, c) -> (b, c)
    forall (p :: Type -> Type -> Type) a b c.
    Bifunctor p =>
    (a -> b) -> p a c -> p b c
    first Signed n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Proxy n -> Double -> (Signed n, Double)
    forall (n :: Natural).
    KnownNat n =>
    Proxy n -> Double -> (Signed n, Double)
    op Proxy n
    p (Word64 -> Double
    wordToDouble Word64
    d)))
               ret :: Term
    ret = Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    tupDc) ((Type -> Either Term Type) -> [Type] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map Type -> Either Term Type
    forall a b. b -> Either a b
    Right [Type]
    tyArgs [Either Term Type] -> [Either Term Type] -> [Either Term Type]
    forall a. [a] -> [a] -> [a]
    ++
                      [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Type -> Type -> Integer -> Integer -> Term
    mkSignedLit Type
    sty Type
    nTy Integer
    kn Integer
    sn)
                      , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (TyConMap -> Word64 -> Type -> Term
    mkDoubleCLit TyConMap
    tcm (Double -> Word64
    doubleToWord Double
    d1) ([Type] -> Type
    forall a. HasCallStack => [a] -> a
    last [Type]
    tyArgs))
                      ])
            in Term -> Maybe Machine
    reduce Term
    ret
        where
          op :: KnownNat n => Proxy n -> Double -> (Signed n, Double)
          op :: forall (n :: Natural).
    KnownNat n =>
    Proxy n -> Double -> (Signed n, Double)
    op Proxy n
    _ = Double -> (Signed n, Double)
    forall b. Integral b => Double -> (b, Double)
    forall a b. (RealFrac a, Integral b) => a -> (b, a)
    properFraction
    #endif
      Text
    _ -> Maybe Machine
    forall a. Maybe a
    Nothing
      where
        ty :: Type
    ty = PrimInfo -> Type
    primType PrimInfo
    pInfo

        checkNaturalRange1 :: Type -> Integer -> (Natural -> Natural) -> Term
    checkNaturalRange1 Type
    nTy Integer
    i Natural -> Natural
    f =
          Type -> [Integer] -> ([Natural] -> Term) -> Term
    checkNaturalRange Type
    nTy [Integer
    i]
            (\[Natural
    i'] -> Natural -> Term
    naturalToNaturalLiteral (Natural -> Natural
    f Natural
    i'))

        checkNaturalRange2 :: Type
    -> Integer -> Integer -> (Natural -> Natural -> Natural) -> Term
    checkNaturalRange2 Type
    nTy Integer
    i Integer
    j Natural -> Natural -> Natural
    f =
          Type -> [Integer] -> ([Natural] -> Term) -> Term
    checkNaturalRange Type
    nTy [Integer
    i, Integer
    j]
            (\[Natural
    i', Natural
    j'] -> Natural -> Term
    naturalToNaturalLiteral (Natural -> Natural -> Natural
    f Natural
    i' Natural
    j'))

        -- Check given integer's range. If any of them are less than zero, give up
        -- and return an undefined type.
        checkNaturalRange
          :: Type
          -- Type of GHC.Natural.Natural ^
          -> [Integer]
          -> ([Natural] -> Term)
          -> Term
        checkNaturalRange :: Type -> [Integer] -> ([Natural] -> Term) -> Term
    checkNaturalRange Type
    nTy [Integer]
    natsAsInts [Natural] -> Term
    f =
          if (Integer -> Bool) -> [Integer] -> Bool
    forall (t :: Type -> Type) a.
    Foldable t =>
    (a -> Bool) -> t a -> Bool
    any (Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    <Integer
    0) [Integer]
    natsAsInts then
            Term -> Type -> Term
    TyApp (PrimInfo -> Term
    Prim PrimInfo
    NP.undefined) Type
    nTy
          else
            [Natural] -> Term
    f ((Integer -> Natural) -> [Integer] -> [Natural]
    forall a b. (a -> b) -> [a] -> [b]
    map Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger [Integer]
    natsAsInts)

        reduce :: Term -> Maybe Machine
        reduce :: Term -> Maybe Machine
    reduce Term
    e = case Term -> Either [Char] Term
    forall a. a -> Either [Char] a
    isX Term
    e of
          Left [Char]
    msg -> [Char] -> Maybe Machine -> Maybe Machine
    forall a. [Char] -> a -> a
    trace ([[Char]] -> [Char]
    unlines [[Char]
    "Warning: Not evaluating constant expression:", Text -> [Char]
    forall a. Show a => a -> [Char]
    show (PrimInfo -> Text
    primName PrimInfo
    pInfo), [Char]
    "Because doing so generates an XException:", [Char]
    msg]) Maybe Machine
    forall a. Maybe a
    Nothing
          Right Term
    e' -> Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Term -> Machine -> Machine
    setTerm Term
    e' Machine
    mach)

        reduceWHNF :: Term -> Maybe Machine
    reduceWHNF Term
    e =
          let eval :: Evaluator
    eval = Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
    Evaluator Step
    ghcStep Unwind
    ghcUnwind PrimStep
    ghcPrimStep PrimUnwind
    ghcPrimUnwind
              mach1 :: Machine
    mach1@Machine{mStack :: Machine -> Stack
    mStack=[]} = Evaluator -> TyConMap -> Bool -> Machine -> Machine
    whnf Evaluator
    eval TyConMap
    tcm Bool
    isSubj (Term -> Machine -> Machine
    setTerm Term
    e (Machine -> Machine) -> Machine -> Machine
    forall a b. (a -> b) -> a -> b
    $ Machine -> Machine
    stackClear Machine
    mach)
          in Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Machine
    mach1 { mStack :: Stack
    mStack = Machine -> Stack
    mStack Machine
    mach }

        reduceWHNF' :: Machine -> Term -> Maybe Machine
    reduceWHNF' Machine
    mach1 Term
    e =
          let eval :: Evaluator
    eval = Step -> Unwind -> PrimStep -> PrimUnwind -> Evaluator
    Evaluator Step
    ghcStep Unwind
    ghcUnwind PrimStep
    ghcPrimStep PrimUnwind
    ghcPrimUnwind
              mach2 :: Machine
    mach2@Machine{mStack :: Machine -> Stack
    mStack=[]} = Evaluator -> TyConMap -> Bool -> Machine -> Machine
    whnf Evaluator
    eval TyConMap
    tcm Bool
    isSubj (Term -> Machine -> Machine
    setTerm Term
    e Machine
    mach1)
           in Machine -> Maybe Machine
    forall a. a -> Maybe a
    Just (Machine -> Maybe Machine) -> Machine -> Maybe Machine
    forall a b. (a -> b) -> a -> b
    $ Machine
    mach2 { mStack :: Stack
    mStack = Machine -> Stack
    mStack Machine
    mach }

        makeUndefinedIf :: Exception e => (e -> Bool) -> Term -> Term
        makeUndefinedIf :: forall e. Exception e => (e -> Bool) -> Term -> Term
    makeUndefinedIf e -> Bool
    wantToHandle Term
    tm =
          case IO (Either e Term) -> Either e Term
    forall a. IO a -> a
    unsafeDupablePerformIO (IO (Either e Term) -> Either e Term)
    -> IO (Either e Term) -> Either e Term
    forall a b. (a -> b) -> a -> b
    $ (e -> Maybe e) -> IO Term -> IO (Either e Term)
    forall e b a.
    Exception e =>
    (e -> Maybe b) -> IO a -> IO (Either b a)
    tryJust e -> Maybe e
    selectException (Term -> IO Term
    forall a. a -> IO a
    evaluate (Term -> IO Term) -> Term -> IO Term
    forall a b. (a -> b) -> a -> b
    $ Term -> Term
    forall a. NFData a => a -> a
    force Term
    tm) of
            Right Term
    b -> Term
    b
            Left e
    e -> [Char] -> Term -> Term
    forall a. [Char] -> a -> a
    trace (e -> [Char]
    forall a. Show a => a -> [Char]
    msg e
    e) (Term -> Type -> Term
    TyApp (PrimInfo -> Term
    Prim PrimInfo
    NP.undefined) Type
    resTy)
          where
            resTy :: Type
    resTy = TyConMap -> Type -> [Type] -> Type
    getResultTy TyConMap
    tcm Type
    ty [Type]
    tys
            selectException :: e -> Maybe e
    selectException e
    e | e -> Bool
    wantToHandle e
    e = e -> Maybe e
    forall a. a -> Maybe a
    Just e
    e
                              | Bool
    otherwise = Maybe e
    forall a. Maybe a
    Nothing
            msg :: a -> [Char]
    msg a
    e = [[Char]] -> [Char]
    unlines [[Char]
    "Warning: caught exception: \"" [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ a -> [Char]
    forall a. Show a => a -> [Char]
    show a
    e [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "\" while trying to evaluate: "
                            , Term -> [Char]
    forall p. PrettyPrec p => p -> [Char]
    showPpr (Term -> [Either Term Type] -> Term
    mkApps (PrimInfo -> Term
    Prim PrimInfo
    pInfo) ((Value -> Either Term Type) -> [Value] -> [Either Term Type]
    forall a b. (a -> b) -> [a] -> [b]
    map (Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Term -> Either Term Type)
    -> (Value -> Term) -> Value -> Either Term Type
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Value -> Term
    valToTerm) [Value]
    args))
                            ]

        catchDivByZero :: Term -> Term
    catchDivByZero = (ArithException -> Bool) -> Term -> Term
    forall e. Exception e => (e -> Bool) -> Term -> Term
    makeUndefinedIf (ArithException -> ArithException -> Bool
    forall a. Eq a => a -> a -> Bool
    ==ArithException
    DivideByZero)

    -- Helper functions for literals

    pairOf :: (Value -> Maybe a) -> [Value] -> Maybe (a, a)
    pairOf :: forall a. (Value -> Maybe a) -> [Value] -> Maybe (a, a)
    pairOf Value -> Maybe a
    f [Value
    x, Value
    y] = (,) (a -> a -> (a, a)) -> Maybe a -> Maybe (a -> (a, a))
    forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
    <$> Value -> Maybe a
    f Value
    x Maybe (a -> (a, a)) -> Maybe a -> Maybe (a, a)
    forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
    forall (f :: Type -> Type) a b.
    Applicative f =>
    f (a -> b) -> f a -> f b
    <*> Value -> Maybe a
    f Value
    y
    pairOf Value -> Maybe a
    _ [Value]
    _ = Maybe (a, a)
    forall a. Maybe a
    Nothing

    listOf :: (Value -> Maybe a) -> [Value] -> [a]
    listOf :: forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf = (Value -> Maybe a) -> [Value] -> [a]
    forall a b. (a -> Maybe b) -> [a] -> [b]
    mapMaybe

    wrapUnsigned :: Integer -> Integer -> Integer
    wrapUnsigned :: Integer -> Integer -> Integer
    wrapUnsigned Integer
    n Integer
    i = Integer
    i Integer -> Integer -> Integer
    forall a. Integral a => a -> a -> a
    `mod` Integer
    sz
     where
      sz :: Integer
    sz = Integer
    1 Integer -> Unique -> Integer
    forall a. Bits a => a -> Unique -> a
    `shiftL` Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    n

    wrapSigned :: Integer -> Integer -> Integer
    wrapSigned :: Integer -> Integer -> Integer
    wrapSigned Integer
    n Integer
    i = if Integer
    n Integer -> Integer -> Bool
    forall a. Eq a => a -> a -> Bool
    == Integer
    0 then Integer
    0 else Integer
    res
     where
      mask :: Integer
    mask = Integer
    1 Integer -> Unique -> Integer
    forall a. Bits a => a -> Unique -> a
    `shiftL` Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger (Integer
    n Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    1)
      res :: Integer
    res  = case Integer -> Integer -> (Integer, Integer)
    forall a. Integral a => a -> a -> (a, a)
    divMod Integer
    i Integer
    mask of
               (Integer
    s,Integer
    i1) | Integer -> Bool
    forall a. Integral a => a -> Bool
    even Integer
    s    -> Integer
    i1
                      | Bool
    otherwise -> Integer
    i1 Integer -> Integer -> Integer
    forall a. Num a => a -> a -> a
    - Integer
    mask

    doubleLiterals' :: [Value] -> [Word64]
    doubleLiterals' :: [Value] -> [Word64]
    doubleLiterals' = (Value -> Maybe Word64) -> [Value] -> [Word64]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe Word64
    doubleLiteral

    doubleLiteral :: Value -> Maybe Word64
    doubleLiteral :: Value -> Maybe Word64
    doubleLiteral Value
    v = case Value
    v of
      Lit (DoubleLiteral Word64
    i) -> Word64 -> Maybe Word64
    forall a. a -> Maybe a
    Just Word64
    i
      Value
    _ -> Maybe Word64
    forall a. Maybe a
    Nothing

    floatLiterals' :: [Value] -> [Word32]
    floatLiterals' :: [Value] -> [Word32]
    floatLiterals' = (Value -> Maybe Word32) -> [Value] -> [Word32]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe Word32
    floatLiteral

    floatLiteral :: Value -> Maybe Word32
    floatLiteral :: Value -> Maybe Word32
    floatLiteral Value
    v = case Value
    v of
      Lit (FloatLiteral Word32
    i) -> Word32 -> Maybe Word32
    forall a. a -> Maybe a
    Just Word32
    i
      Value
    _ -> Maybe Word32
    forall a. Maybe a
    Nothing

    integerLiterals :: [Value] -> Maybe (Integer, Integer)
    integerLiterals :: [Value] -> Maybe (Integer, Integer)
    integerLiterals = (Value -> Maybe Integer) -> [Value] -> Maybe (Integer, Integer)
    forall a. (Value -> Maybe a) -> [Value] -> Maybe (a, a)
    pairOf Value -> Maybe Integer
    integerLiteral

    integerLiteral :: Value -> Maybe Integer
    integerLiteral :: Value -> Maybe Integer
    integerLiteral Value
    v =
      case Value
    v of
        Lit (IntegerLiteral Integer
    i) -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just Integer
    i
        DC DataCon
    dc [Left (Literal (IntLiteral Integer
    i))]
          | DataCon -> Unique
    dcTag DataCon
    dc Unique -> Unique -> Bool
    forall a. Eq a => a -> a -> Bool
    == Unique
    1
          -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just Integer
    i
        DC DataCon
    dc [Left (Literal (ByteArrayLiteral (BA.ByteArray ByteArray#
    ba)))]
          | DataCon -> Unique
    dcTag DataCon
    dc Unique -> Unique -> Bool
    forall a. Eq a => a -> a -> Bool
    == Unique
    2
    #if MIN_VERSION_base(4,15,0)
          -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just (ByteArray# -> Integer
    IP ByteArray#
    ba)
    #else
          -> Just (Jp# (BN# ba))
    #endif
          | DataCon -> Unique
    dcTag DataCon
    dc Unique -> Unique -> Bool
    forall a. Eq a => a -> a -> Bool
    == Unique
    3
    #if MIN_VERSION_base(4,15,0)
          -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just (ByteArray# -> Integer
    IN ByteArray#
    ba)
    #else
          -> Just (Jn# (BN# ba))
    #endif
        Value
    _ -> Maybe Integer
    forall a. Maybe a
    Nothing

    naturalLiterals :: [Value] -> Maybe (Integer, Integer)
    naturalLiterals :: [Value] -> Maybe (Integer, Integer)
    naturalLiterals = (Value -> Maybe Integer) -> [Value] -> Maybe (Integer, Integer)
    forall a. (Value -> Maybe a) -> [Value] -> Maybe (a, a)
    pairOf Value -> Maybe Integer
    naturalLiteral

    naturalLiteral :: Value -> Maybe Integer
    naturalLiteral :: Value -> Maybe Integer
    naturalLiteral Value
    v =
      case Value
    v of
        Lit (NaturalLiteral Integer
    i) -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just Integer
    i
        DC DataCon
    dc [Left (Literal (WordLiteral Integer
    i))]
          | DataCon -> Unique
    dcTag DataCon
    dc Unique -> Unique -> Bool
    forall a. Eq a => a -> a -> Bool
    == Unique
    1
          -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just Integer
    i
        DC DataCon
    dc [Left (Literal (ByteArrayLiteral (BA.ByteArray ByteArray#
    ba)))]
          | DataCon -> Unique
    dcTag DataCon
    dc Unique -> Unique -> Bool
    forall a. Eq a => a -> a -> Bool
    == Unique
    2
    #if MIN_VERSION_base(4,15,0)
          -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just (ByteArray# -> Integer
    IP ByteArray#
    ba)
    #else
          -> Just (Jp# (BN# ba))
    #endif
        Value
    _ -> Maybe Integer
    forall a. Maybe a
    Nothing

    integerLiterals' :: [Value] -> [Integer]
    integerLiterals' :: [Value] -> [Integer]
    integerLiterals' = (Value -> Maybe Integer) -> [Value] -> [Integer]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe Integer
    integerLiteral

    naturalLiterals' :: [Value] -> [Integer]
    naturalLiterals' :: [Value] -> [Integer]
    naturalLiterals' = (Value -> Maybe Integer) -> [Value] -> [Integer]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe Integer
    naturalLiteral

    intLiterals :: [Value] -> Maybe (Integer,Integer)
    intLiterals :: [Value] -> Maybe (Integer, Integer)
    intLiterals = (Value -> Maybe Integer) -> [Value] -> Maybe (Integer, Integer)
    forall a. (Value -> Maybe a) -> [Value] -> Maybe (a, a)
    pairOf Value -> Maybe Integer
    intLiteral

    intLiterals' :: [Value] -> [Integer]
    intLiterals' :: [Value] -> [Integer]
    intLiterals' = (Value -> Maybe Integer) -> [Value] -> [Integer]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe Integer
    intLiteral

    intCLiterals' :: [Value] -> [Integer]
    intCLiterals' :: [Value] -> [Integer]
    intCLiterals' = (Value -> Maybe Integer) -> [Value] -> [Integer]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe Integer
    intCLiteral

    intLiteral :: Value -> Maybe Integer
    intLiteral :: Value -> Maybe Integer
    intLiteral Value
    x = case Value
    x of
      Lit (IntLiteral Integer
    i) -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just Integer
    i
      Value
    _ -> Maybe Integer
    forall a. Maybe a
    Nothing

    #if MIN_VERSION_base(4,16,0)
    int8Literals' :: [Value] -> [Integer]
    int8Literals' :: [Value] -> [Integer]
    int8Literals' = (Value -> Maybe Integer) -> [Value] -> [Integer]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe Integer
    int8Literal

    int8Literal :: Value -> Maybe Integer
    int8Literal :: Value -> Maybe Integer
    int8Literal Value
    x = case Value
    x of
      Lit (Int8Literal Integer
    i) -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just Integer
    i
      Value
    _ -> Maybe Integer
    forall a. Maybe a
    Nothing

    int16Literals' :: [Value] -> [Integer]
    int16Literals' :: [Value] -> [Integer]
    int16Literals' = (Value -> Maybe Integer) -> [Value] -> [Integer]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe Integer
    int16Literal

    int16Literal :: Value -> Maybe Integer
    int16Literal :: Value -> Maybe Integer
    int16Literal Value
    x = case Value
    x of
      Lit (Int16Literal Integer
    i) -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just Integer
    i
      Value
    _ -> Maybe Integer
    forall a. Maybe a
    Nothing

    int32Literals' :: [Value] -> [Integer]
    int32Literals' :: [Value] -> [Integer]
    int32Literals' = (Value -> Maybe Integer) -> [Value] -> [Integer]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe Integer
    int32Literal

    int32Literal :: Value -> Maybe Integer
    int32Literal :: Value -> Maybe Integer
    int32Literal Value
    x = case Value
    x of
      Lit (Int32Literal Integer
    i) -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just Integer
    i
      Value
    _ -> Maybe Integer
    forall a. Maybe a
    Nothing

    #if MIN_VERSION_base(4,17,0)
    int64Literals' :: [Value] -> [Integer]
    int64Literals' :: [Value] -> [Integer]
    int64Literals' = (Value -> Maybe Integer) -> [Value] -> [Integer]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe Integer
    int64Literal

    int64Literal :: Value -> Maybe Integer
    int64Literal :: Value -> Maybe Integer
    int64Literal Value
    x = case Value
    x of
      Lit (Int64Literal Integer
    i) -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just Integer
    i
      Value
    _ -> Maybe Integer
    forall a. Maybe a
    Nothing
    #endif
    #endif

    intCLiteral :: Value -> Maybe Integer
    intCLiteral :: Value -> Maybe Integer
    intCLiteral Value
    v = case Value
    v of
      (DC DataCon
    _ [Left (Literal (IntLiteral Integer
    i))]) -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just Integer
    i
      Value
    _ -> Maybe Integer
    forall a. Maybe a
    Nothing

    intCLiterals :: [Value] -> Maybe (Integer, Integer)
    intCLiterals :: [Value] -> Maybe (Integer, Integer)
    intCLiterals = (Value -> Maybe Integer) -> [Value] -> Maybe (Integer, Integer)
    forall a. (Value -> Maybe a) -> [Value] -> Maybe (a, a)
    pairOf Value -> Maybe Integer
    intCLiteral

    wordLiterals :: [Value] -> Maybe (Integer,Integer)
    wordLiterals :: [Value] -> Maybe (Integer, Integer)
    wordLiterals = (Value -> Maybe Integer) -> [Value] -> Maybe (Integer, Integer)
    forall a. (Value -> Maybe a) -> [Value] -> Maybe (a, a)
    pairOf Value -> Maybe Integer
    wordLiteral

    wordLiterals' :: [Value] -> [Integer]
    wordLiterals' :: [Value] -> [Integer]
    wordLiterals' = (Value -> Maybe Integer) -> [Value] -> [Integer]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe Integer
    wordLiteral

    wordLiteral :: Value -> Maybe Integer
    wordLiteral :: Value -> Maybe Integer
    wordLiteral Value
    x = case Value
    x of
      Lit (WordLiteral Integer
    i) -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just Integer
    i
      Value
    _ -> Maybe Integer
    forall a. Maybe a
    Nothing

    #if MIN_VERSION_base(4,16,0)
    word8Literals' :: [Value] -> [Integer]
    word8Literals' :: [Value] -> [Integer]
    word8Literals' = (Value -> Maybe Integer) -> [Value] -> [Integer]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe Integer
    word8Literal

    word8Literal :: Value -> Maybe Integer
    word8Literal :: Value -> Maybe Integer
    word8Literal Value
    x = case Value
    x of
      Lit (Word8Literal Integer
    i) -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just Integer
    i
      Value
    _ -> Maybe Integer
    forall a. Maybe a
    Nothing

    word16Literals' :: [Value] -> [Integer]
    word16Literals' :: [Value] -> [Integer]
    word16Literals' = (Value -> Maybe Integer) -> [Value] -> [Integer]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe Integer
    word16Literal

    word16Literal :: Value -> Maybe Integer
    word16Literal :: Value -> Maybe Integer
    word16Literal Value
    x = case Value
    x of
      Lit (Word16Literal Integer
    i) -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just Integer
    i
      Value
    _ -> Maybe Integer
    forall a. Maybe a
    Nothing

    word32Literals' :: [Value] -> [Integer]
    word32Literals' :: [Value] -> [Integer]
    word32Literals' = (Value -> Maybe Integer) -> [Value] -> [Integer]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe Integer
    word32Literal

    word32Literal :: Value -> Maybe Integer
    word32Literal :: Value -> Maybe Integer
    word32Literal Value
    x = case Value
    x of
      Lit (Word32Literal Integer
    i) -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just Integer
    i
      Value
    _ -> Maybe Integer
    forall a. Maybe a
    Nothing

    #if MIN_VERSION_base(4,17,0)
    word64Literals' :: [Value] -> [Integer]
    word64Literals' :: [Value] -> [Integer]
    word64Literals' = (Value -> Maybe Integer) -> [Value] -> [Integer]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe Integer
    word64Literal

    word64Literal :: Value -> Maybe Integer
    word64Literal :: Value -> Maybe Integer
    word64Literal Value
    x = case Value
    x of
      Lit (Word64Literal Integer
    i) -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just Integer
    i
      Value
    _ -> Maybe Integer
    forall a. Maybe a
    Nothing
    #endif
    #endif

    charLiterals :: [Value] -> Maybe (Char,Char)
    charLiterals :: [Value] -> Maybe (Char, Char)
    charLiterals = (Value -> Maybe Char) -> [Value] -> Maybe (Char, Char)
    forall a. (Value -> Maybe a) -> [Value] -> Maybe (a, a)
    pairOf Value -> Maybe Char
    charLiteral

    charLiterals' :: [Value] -> [Char]
    charLiterals' :: [Value] -> [Char]
    charLiterals' = (Value -> Maybe Char) -> [Value] -> [Char]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe Char
    charLiteral

    charLiteral :: Value -> Maybe Char
    charLiteral :: Value -> Maybe Char
    charLiteral Value
    x = case Value
    x of
      Lit (CharLiteral Char
    c) -> Char -> Maybe Char
    forall a. a -> Maybe a
    Just Char
    c
      Value
    _ -> Maybe Char
    forall a. Maybe a
    Nothing

    sizedLiterals :: Text -> [Value] -> Maybe (Integer,Integer)
    sizedLiterals :: Text -> [Value] -> Maybe (Integer, Integer)
    sizedLiterals Text
    szCon = (Value -> Maybe Integer) -> [Value] -> Maybe (Integer, Integer)
    forall a. (Value -> Maybe a) -> [Value] -> Maybe (a, a)
    pairOf (Text -> Value -> Maybe Integer
    sizedLiteral Text
    szCon)

    sizedLiterals' :: Text -> [Value] -> [Integer]
    sizedLiterals' :: Text -> [Value] -> [Integer]
    sizedLiterals' Text
    szCon = (Value -> Maybe Integer) -> [Value] -> [Integer]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf (Text -> Value -> Maybe Integer
    sizedLiteral Text
    szCon)

    sizedLiteral :: Text -> Value -> Maybe Integer
    sizedLiteral :: Text -> Value -> Maybe Integer
    sizedLiteral Text
    szCon Value
    val = case Value
    val of
      PrimVal PrimInfo
    p [Type]
    _ [Value
    _, Lit (IntegerLiteral Integer
    i)]
        | PrimInfo -> Text
    primName PrimInfo
    p Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    szCon -> Integer -> Maybe Integer
    forall a. a -> Maybe a
    Just Integer
    i
      Value
    _ -> Maybe Integer
    forall a. Maybe a
    Nothing

    bitLiterals
      :: [Value]
      -> [(Integer,Integer)]
    bitLiterals :: [Value] -> [(Integer, Integer)]
    bitLiterals = ((Integer, Integer) -> (Integer, Integer))
    -> [(Integer, Integer)] -> [(Integer, Integer)]
    forall a b. (a -> b) -> [a] -> [b]
    map (Integer, Integer) -> (Integer, Integer)
    forall {a} {b}. (Bits a, Bits b, Num a, Num b) => (a, b) -> (a, b)
    normalizeBit ([(Integer, Integer)] -> [(Integer, Integer)])
    -> ([Value] -> [(Integer, Integer)])
    -> [Value]
    -> [(Integer, Integer)]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Value -> Maybe (Integer, Integer))
    -> [Value] -> [(Integer, Integer)]
    forall a b. (a -> Maybe b) -> [a] -> [b]
    mapMaybe Value -> Maybe (Integer, Integer)
    go
     where
      normalizeBit :: (a, b) -> (a, b)
    normalizeBit (a
    msk,b
    v) = (a
    msk a -> a -> a
    forall a. Bits a => a -> a -> a
    .&. a
    1, b
    v b -> b -> b
    forall a. Bits a => a -> a -> a
    .&. b
    1)
      go :: Value -> Maybe (Integer, Integer)
    go Value
    val = case Value
    val of
        PrimVal PrimInfo
    p [Type]
    _ [Lit (WordLiteral Integer
    m), Lit (IntegerLiteral Integer
    i)]
          | PrimInfo -> Text
    primName PrimInfo
    p Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    "Clash.Sized.Internal.BitVector.fromInteger##"
          -> (Integer, Integer) -> Maybe (Integer, Integer)
    forall a. a -> Maybe a
    Just (Integer
    m,Integer
    i)
        Value
    _ -> Maybe (Integer, Integer)
    forall a. Maybe a
    Nothing

    indexLiterals, signedLiterals, unsignedLiterals
      :: [Value] -> Maybe (Integer,Integer)
    indexLiterals :: [Value] -> Maybe (Integer, Integer)
    indexLiterals     = Text -> [Value] -> Maybe (Integer, Integer)
    sizedLiterals Text
    "Clash.Sized.Internal.Index.fromInteger#"
    signedLiterals :: [Value] -> Maybe (Integer, Integer)
    signedLiterals    = Text -> [Value] -> Maybe (Integer, Integer)
    sizedLiterals Text
    "Clash.Sized.Internal.Signed.fromInteger#"
    unsignedLiterals :: [Value] -> Maybe (Integer, Integer)
    unsignedLiterals  = Text -> [Value] -> Maybe (Integer, Integer)
    sizedLiterals Text
    "Clash.Sized.Internal.Unsigned.fromInteger#"

    indexLiterals', signedLiterals', unsignedLiterals'
      :: [Value] -> [Integer]
    indexLiterals' :: [Value] -> [Integer]
    indexLiterals'     = Text -> [Value] -> [Integer]
    sizedLiterals' Text
    "Clash.Sized.Internal.Index.fromInteger#"
    signedLiterals' :: [Value] -> [Integer]
    signedLiterals'    = Text -> [Value] -> [Integer]
    sizedLiterals' Text
    "Clash.Sized.Internal.Signed.fromInteger#"
    unsignedLiterals' :: [Value] -> [Integer]
    unsignedLiterals'  = Text -> [Value] -> [Integer]
    sizedLiterals' Text
    "Clash.Sized.Internal.Unsigned.fromInteger#"

    bitVectorLiterals'
      :: [Value] -> [(Integer,Integer)]
    bitVectorLiterals' :: [Value] -> [(Integer, Integer)]
    bitVectorLiterals' = (Value -> Maybe (Integer, Integer))
    -> [Value] -> [(Integer, Integer)]
    forall a. (Value -> Maybe a) -> [Value] -> [a]
    listOf Value -> Maybe (Integer, Integer)
    bitVectorLiteral

    bitVectorLiteral :: Value -> Maybe (Integer, Integer)
    bitVectorLiteral :: Value -> Maybe (Integer, Integer)
    bitVectorLiteral Value
    val = case Value
    val of
      (PrimVal PrimInfo
    p [Type]
    _ [Value
    _, Lit (NaturalLiteral Integer
    m), Lit (IntegerLiteral Integer
    i)])
        | PrimInfo -> Text
    primName PrimInfo
    p Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    "Clash.Sized.Internal.BitVector.fromInteger#" -> (Integer, Integer) -> Maybe (Integer, Integer)
    forall a. a -> Maybe a
    Just (Integer
    m, Integer
    i)
      Value
    _ -> Maybe (Integer, Integer)
    forall a. Maybe a
    Nothing

    toBV :: (Integer,Integer) -> BitVector n
    toBV :: forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer
    mask,Integer
    val) = Natural -> Natural -> BitVector n
    forall (n :: Natural). Natural -> Natural -> BitVector n
    BV (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger Integer
    mask) (Integer -> Natural
    forall a. Num a => Integer -> a
    fromInteger Integer
    val)

    splitBV :: BitVector n -> (Integer,Integer)
    splitBV :: forall (n :: Natural). BitVector n -> (Integer, Integer)
    splitBV (BV Natural
    msk Natural
    val) = (Natural -> Integer
    forall a. Integral a => a -> Integer
    toInteger Natural
    msk, Natural -> Integer
    forall a. Integral a => a -> Integer
    toInteger Natural
    val)

    toBit :: (Integer,Integer) -> Bit
    toBit :: (Integer, Integer) -> Bit
    toBit (Integer
    mask,Integer
    val) = Word -> Word -> Bit
    Bit (Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    mask) (Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger Integer
    val)

    valArgs
      :: Value
      -> Maybe [Term]
    valArgs :: Value -> Maybe [Term]
    valArgs Value
    v =
      case Value
    v of
        PrimVal PrimInfo
    _ [Type]
    _ [Value]
    vs -> [Term] -> Maybe [Term]
    forall a. a -> Maybe a
    Just ((Value -> Term) -> [Value] -> [Term]
    forall a b. (a -> b) -> [a] -> [b]
    forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
    fmap Value -> Term
    valToTerm [Value]
    vs)
        DC DataCon
    _ [Either Term Type]
    args -> [Term] -> Maybe [Term]
    forall a. a -> Maybe a
    Just ([Either Term Type] -> [Term]
    forall a b. [Either a b] -> [a]
    Either.lefts [Either Term Type]
    args)
        Value
    _ -> Maybe [Term]
    forall a. Maybe a
    Nothing

    -- Tries to match literal arguments to a function like
    --   (Unsigned.shiftL#  :: forall n. KnownNat n => Unsigned n -> Int -> Unsigned n)
    sizedLitIntLit
      :: Text -> TyConMap -> [Type] -> [Value]
      -> Maybe (Type,Integer,Integer,Integer)
    sizedLitIntLit :: Text
    -> TyConMap
    -> [Type]
    -> [Value]
    -> Maybe (Type, Integer, Integer, Integer)
    sizedLitIntLit Text
    szCon TyConMap
    tcm [Type]
    tys [Value]
    args
      | Just (Type
    nTy,Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
      , [Value
    _
        ,PrimVal PrimInfo
    p [Type]
    _ [Value
    _,Lit (IntegerLiteral Integer
    i)]
        ,Value -> Maybe [Term]
    valArgs -> Just [Literal (IntLiteral Integer
    j)]
        ] <- [Value]
    args
      , PrimInfo -> Text
    primName PrimInfo
    p Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    szCon
      = (Type, Integer, Integer, Integer)
    -> Maybe (Type, Integer, Integer, Integer)
    forall a. a -> Maybe a
    Just (Type
    nTy,Integer
    kn,Integer
    i,Integer
    j)
      | Bool
    otherwise
      = Maybe (Type, Integer, Integer, Integer)
    forall a. Maybe a
    Nothing

    signedLitIntLit, unsignedLitIntLit
      :: TyConMap -> [Type] -> [Value]
      -> Maybe (Type,Integer,Integer,Integer)
    signedLitIntLit :: TyConMap
    -> [Type] -> [Value] -> Maybe (Type, Integer, Integer, Integer)
    signedLitIntLit    = Text
    -> TyConMap
    -> [Type]
    -> [Value]
    -> Maybe (Type, Integer, Integer, Integer)
    sizedLitIntLit Text
    "Clash.Sized.Internal.Signed.fromInteger#"
    unsignedLitIntLit :: TyConMap
    -> [Type] -> [Value] -> Maybe (Type, Integer, Integer, Integer)
    unsignedLitIntLit  = Text
    -> TyConMap
    -> [Type]
    -> [Value]
    -> Maybe (Type, Integer, Integer, Integer)
    sizedLitIntLit Text
    "Clash.Sized.Internal.Unsigned.fromInteger#"

    bitVectorLitIntLit
      :: TyConMap -> [Type] -> [Value]
      -> Maybe (Type,Integer,(Integer,Integer),Integer)
    bitVectorLitIntLit :: TyConMap
    -> [Type]
    -> [Value]
    -> Maybe (Type, Integer, (Integer, Integer), Integer)
    bitVectorLitIntLit TyConMap
    tcm [Type]
    tys [Value]
    args
      | Just (Type
    nTy,Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
      , [Value
    _
        ,PrimVal PrimInfo
    p [Type]
    _ [Value
    _,Lit (NaturalLiteral Integer
    m),Lit (IntegerLiteral Integer
    i)]
        ,Value -> Maybe [Term]
    valArgs -> Just [Literal (IntLiteral Integer
    j)]
        ] <- [Value]
    args
      , PrimInfo -> Text
    primName PrimInfo
    p Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    "Clash.Sized.Internal.BitVector.fromInteger#"
      = (Type, Integer, (Integer, Integer), Integer)
    -> Maybe (Type, Integer, (Integer, Integer), Integer)
    forall a. a -> Maybe a
    Just (Type
    nTy,Integer
    kn,(Integer
    m,Integer
    i),Integer
    j)
      | Bool
    otherwise
      = Maybe (Type, Integer, (Integer, Integer), Integer)
    forall a. Maybe a
    Nothing

    mkIntCLit :: TyConMap -> Integer -> Type -> Term
    mkIntCLit :: TyConMap -> Integer -> Type -> Term
    mkIntCLit TyConMap
    tcm Integer
    lit Type
    resTy =
      Term -> Term -> Term
    App (DataCon -> Term
    Data DataCon
    intDc) (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral Integer
    lit))
     where
      ([Either TyVar Type]
    _, Type -> TypeView
    tyView -> TyConApp TyConName
    intTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    resTy
      Just TyCon
    intTc = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    intTcNm TyConMap
    tcm
      [DataCon
    intDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    intTc

    mkFloatCLit :: TyConMap -> Word32 -> Type -> Term
    mkFloatCLit :: TyConMap -> Word32 -> Type -> Term
    mkFloatCLit TyConMap
    tcm Word32
    lit Type
    resTy =
      Term -> Term -> Term
    App (DataCon -> Term
    Data DataCon
    floatDc) (Literal -> Term
    Literal (Word32 -> Literal
    FloatLiteral Word32
    lit))
     where
      ([Either TyVar Type]
    _, Type -> TypeView
    tyView -> TyConApp TyConName
    floatTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    resTy
      (Just TyCon
    floatTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    floatTcNm TyConMap
    tcm
      [DataCon
    floatDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    floatTc

    mkDoubleCLit :: TyConMap -> Word64 -> Type -> Term
    mkDoubleCLit :: TyConMap -> Word64 -> Type -> Term
    mkDoubleCLit TyConMap
    tcm Word64
    lit Type
    resTy =
      Term -> Term -> Term
    App (DataCon -> Term
    Data DataCon
    doubleDc) (Literal -> Term
    Literal (Word64 -> Literal
    DoubleLiteral Word64
    lit))
     where
      ([Either TyVar Type]
    _, Type -> TypeView
    tyView -> TyConApp TyConName
    doubleTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    resTy
      (Just TyCon
    doubleTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    doubleTcNm TyConMap
    tcm
      [DataCon
    doubleDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    doubleTc

    mkSomeNat :: TyConMap -> Integer -> Type -> Term
    mkSomeNat :: TyConMap -> Integer -> Type -> Term
    mkSomeNat TyConMap
    tcm Integer
    lit Type
    resTy =
      Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    someNatDc)
             [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy Integer
    lit))
             , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral Integer
    lit))
             , Term -> Either Term Type
    forall a b. a -> Either a b
    Left Term
    proxy
             ]
     where
      -- Get the SomeNat data constructor
      TyConApp TyConName
    someNatTcNm [] = Type -> TypeView
    tyView Type
    resTy
      (Just TyCon
    someNatTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    someNatTcNm TyConMap
    tcm
      [DataCon
    someNatDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    someNatTc

      -- Get the Proxy data constructor
      (Either TyVar Type
    _:Either TyVar Type
    _:Right (Type -> TypeView
    tyView -> TyConApp TyConName
    proxyTcNm [Type
    natTy,Type
    _]):[Either TyVar Type]
    _,Type
    _) =
        Type -> ([Either TyVar Type], Type)
    splitFunForallTy (DataCon -> Type
    dcType DataCon
    someNatDc)
      (Just TyCon
    proxyTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    proxyTcNm TyConMap
    tcm
      [DataCon
    proxyDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    proxyTc

      -- Build the Proxy argument
      proxy :: Term
    proxy = Term -> [Either Term Type] -> Term
    mkApps (DataCon -> Term
    Data DataCon
    proxyDc)
                     [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    natTy
                     , Type -> Either Term Type
    forall a b. b -> Either a b
    Right (LitTy -> Type
    LitTy (Integer -> LitTy
    NumTy Integer
    lit))
                     ]

    -- From an argument list to function of type
    --   forall n. KnownNat n => ...
    -- extract (nTy,nInt)
    -- where nTy is the Type of n
    -- and   nInt is its value as an Integer
    extractKnownNat :: TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat :: TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys = case [Type]
    tys of
      Type
    nTy : [Type]
    _ | Right Integer
    nInt <- Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    nTy)
        -> (Type, Integer) -> Maybe (Type, Integer)
    forall a. a -> Maybe a
    Just (Type
    nTy, Integer
    nInt)
      [Type]
    _ -> Maybe (Type, Integer)
    forall a. Maybe a
    Nothing

    -- From an argument list to function of type
    --   forall n m o .. . (KnownNat n, KnownNat m, KnownNat o, ..) => ...
    -- extract [(nTy,nInt), (mTy,mInt), (oTy,oInt)]
    -- where nTy is the Type of n
    -- and   nInt is its value as an Integer
    extractKnownNats :: TyConMap -> [Type] -> [(Type, Integer)]
    extractKnownNats :: TyConMap -> [Type] -> [(Type, Integer)]
    extractKnownNats TyConMap
    tcm =
      (Type -> Maybe (Type, Integer)) -> [Type] -> [(Type, Integer)]
    forall a b. (a -> Maybe b) -> [a] -> [b]
    mapMaybe (TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm ([Type] -> Maybe (Type, Integer))
    -> (Type -> [Type]) -> Type -> Maybe (Type, Integer)
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Type -> [Type]
    forall a. a -> [a]
    forall (f :: Type -> Type) a. Applicative f => a -> f a
    pure)

    -- Construct a constant term of a sized type
    mkSizedLit
      :: (Type -> Term)
      -- ^ Type constructor?
      -> Type
      -- ^ Result type
      -> Type
      -- ^ forall n.
      -> Integer
      -- ^ KnownNat n
      -> Integer
      -- ^ Value to construct
      -> Term
    mkSizedLit :: (Type -> Term) -> Type -> Type -> Integer -> Integer -> Term
    mkSizedLit Type -> Term
    conPrim Type
    ty Type
    nTy Integer
    kn Integer
    val =
      Term -> [Either Term Type] -> Term
    mkApps
        (Type -> Term
    conPrim Type
    sTy)
        [ Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    nTy
        , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral Integer
    kn))
        , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral Integer
    val)) ]
     where
        ([Either TyVar Type]
    _,Type
    sTy) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty

    mkBitLit
      :: Type
      -- ^ Result type
      -> Integer
      -- ^ Mask
      -> Integer
      -- ^ Value
      -> Term
    mkBitLit :: Type -> Integer -> Integer -> Term
    mkBitLit Type
    ty Integer
    msk Integer
    val =
      Term -> [Either Term Type] -> Term
    mkApps (Type -> Term
    bConPrim Type
    sTy) [ Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    WordLiteral (Integer
    msk Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .&. Integer
    1)))
                            , Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral (Integer
    val Integer -> Integer -> Integer
    forall a. Bits a => a -> a -> a
    .&. Integer
    1)))]
      where
        ([Either TyVar Type]
    _,Type
    sTy) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty

    mkSignedLit, mkUnsignedLit
      :: Type
      -- Result type
      -> Type
      -- forall n.
      -> Integer
      -- KnownNat n
      -> Integer
      -- Value
      -> Term
    mkSignedLit :: Type -> Type -> Integer -> Integer -> Term
    mkSignedLit    = (Type -> Term) -> Type -> Type -> Integer -> Integer -> Term
    mkSizedLit Type -> Term
    signedConPrim
    mkUnsignedLit :: Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit  = (Type -> Term) -> Type -> Type -> Integer -> Integer -> Term
    mkSizedLit Type -> Term
    unsignedConPrim

    mkBitVectorLit
      :: Type
      -- ^ Result type
      -> Type
      -- ^ forall n.
      -> Integer
      -- ^ KnownNat n
      -> Integer
      -- ^ mask
      -> Integer
      -- ^ Value to construct
      -> Term
    mkBitVectorLit :: Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    ty Type
    nTy Integer
    kn Integer
    mask Integer
    val
      = Term -> [Either Term Type] -> Term
    mkApps (Type -> Term
    bvConPrim Type
    sTy)
               [Type -> Either Term Type
    forall a b. b -> Either a b
    Right Type
    nTy
               ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral Integer
    kn))
               ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    NaturalLiteral Integer
    mask))
               ,Term -> Either Term Type
    forall a b. a -> Either a b
    Left (Literal -> Term
    Literal (Integer -> Literal
    IntegerLiteral Integer
    val))]
      where
        ([Either TyVar Type]
    _,Type
    sTy) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty

    mkIndexLitE
      :: Type
      -- ^ Result type
      -> Type
      -- ^ forall n.
      -> Integer
      -- ^ KnownNat n
      -> Integer
      -- ^ Value to construct
      -> Either Term Term
      -- ^ Either undefined (if given value is out of bounds of given type) or term
      -- representing literal
    mkIndexLitE :: Type -> Type -> Integer -> Integer -> Either Term Term
    mkIndexLitE Type
    rTy Type
    nTy Integer
    kn Integer
    val
      | Integer
    val Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    >= Integer
    0
      , Integer
    val Integer -> Integer -> Bool
    forall a. Ord a => a -> a -> Bool
    < Integer
    kn
      = Term -> Either Term Term
    forall a b. b -> Either a b
    Right ((Type -> Term) -> Type -> Type -> Integer -> Integer -> Term
    mkSizedLit Type -> Term
    indexConPrim Type
    rTy Type
    nTy Integer
    kn Integer
    val)
      | Bool
    otherwise
      = Term -> Either Term Term
    forall a b. a -> Either a b
    Left (Term -> Type -> Term
    TyApp (PrimInfo -> Term
    Prim PrimInfo
    NP.undefined) (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    indexTcNm [Type
    nTy]))
      where
        TyConApp TyConName
    indexTcNm [Type]
    _ = Type -> TypeView
    tyView (([Either TyVar Type], Type) -> Type
    forall a b. (a, b) -> b
    snd (Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    rTy))

    mkIndexLit
      :: Type
      -- ^ Result type
      -> Type
      -- ^ forall n.
      -> Integer
      -- ^ KnownNat n
      -> Integer
      -- ^ Value to construct
      -> Term
    mkIndexLit :: Type -> Type -> Integer -> Integer -> Term
    mkIndexLit Type
    rTy Type
    nTy Integer
    kn Integer
    val =
      (Term -> Term) -> (Term -> Term) -> Either Term Term -> Term
    forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
    either Term -> Term
    forall a. a -> a
    id Term -> Term
    forall a. a -> a
    id (Type -> Type -> Integer -> Integer -> Either Term Term
    mkIndexLitE Type
    rTy Type
    nTy Integer
    kn Integer
    val)

    mkBitVectorLit'
      :: (Type, Type, Integer)
      -- ^ (result type, forall n., KnownNat n)
      -> Integer
      -- ^ Mask
      -> Integer
      -- ^ Value
      -> Term
    mkBitVectorLit' :: (Type, Type, Integer) -> Integer -> Integer -> Term
    mkBitVectorLit' (Type
    ty,Type
    nTy,Integer
    kn) = Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    ty Type
    nTy Integer
    kn

    mkIndexLit'
      :: (Type, Type, Integer)
      -- ^ (result type, forall n., KnownNat n)
      -> Integer
      -- ^ value
      -> Term
    mkIndexLit' :: (Type, Type, Integer) -> Integer -> Term
    mkIndexLit' (Type
    rTy,Type
    nTy,Integer
    kn) = Type -> Type -> Integer -> Integer -> Term
    mkIndexLit Type
    rTy Type
    nTy Integer
    kn

    boolToIntLiteral :: Bool -> Term
    boolToIntLiteral :: Bool -> Term
    boolToIntLiteral Bool
    b = if Bool
    b then Literal -> Term
    Literal (Integer -> Literal
    IntLiteral Integer
    1) else Literal -> Term
    Literal (Integer -> Literal
    IntLiteral Integer
    0)

    boolToBoolLiteral :: TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral :: TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty Bool
    b =
     let ([Either TyVar Type]
    _,Type -> TypeView
    tyView -> TyConApp TyConName
    boolTcNm []) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty
         (Just TyCon
    boolTc) = TyConName -> TyConMap -> Maybe TyCon
    forall a b. Uniquable a => a -> UniqMap b -> Maybe b
    UniqMap.lookup TyConName
    boolTcNm TyConMap
    tcm
         [DataCon
    falseDc,DataCon
    trueDc] = TyCon -> [DataCon]
    tyConDataCons TyCon
    boolTc
         retDc :: DataCon
    retDc = if Bool
    b then DataCon
    trueDc else DataCon
    falseDc
     in  DataCon -> Term
    Data DataCon
    retDc

    charToCharLiteral :: Char -> Term
    charToCharLiteral :: Char -> Term
    charToCharLiteral = Literal -> Term
    Literal (Literal -> Term) -> (Char -> Literal) -> Char -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Char -> Literal
    CharLiteral

    integerToIntLiteral :: Integer -> Term
    integerToIntLiteral :: Integer -> Term
    integerToIntLiteral = Literal -> Term
    Literal (Literal -> Term) -> (Integer -> Literal) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral (Integer -> Literal) -> (Integer -> Integer) -> Integer -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Integer) -> (Integer -> Unique) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Int) -- for overflow behavior

    integerToWordLiteral :: Integer -> Term
    integerToWordLiteral :: Integer -> Term
    integerToWordLiteral = Literal -> Term
    Literal (Literal -> Term) -> (Integer -> Literal) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    WordLiteral (Integer -> Literal) -> (Integer -> Integer) -> Integer -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word -> Integer) -> (Integer -> Word) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word) -- for overflow behavior

    integerToInt64Literal :: Integer -> Term
    integerToInt64Literal :: Integer -> Term
    integerToInt64Literal = Literal -> Term
    Literal (Literal -> Term) -> (Integer -> Literal) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    Int64Literal (Integer -> Literal) -> (Integer -> Integer) -> Integer -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int64 -> Integer) -> (Integer -> Int64) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Int64
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Int64) -- for overflow behavior

    integerToWord64Literal :: Integer -> Term
    integerToWord64Literal :: Integer -> Term
    integerToWord64Literal = Literal -> Term
    Literal (Literal -> Term) -> (Integer -> Literal) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    Word64Literal (Integer -> Literal) -> (Integer -> Integer) -> Integer -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word64 -> Integer) -> (Integer -> Word64) -> Integer -> Integer
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger :: Integer -> Word64) -- for overflow behavior

    integerToIntegerLiteral :: Integer -> Term
    integerToIntegerLiteral :: Integer -> Term
    integerToIntegerLiteral = Literal -> Term
    Literal (Literal -> Term) -> (Integer -> Literal) -> Integer -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntegerLiteral

    naturalToNaturalLiteral :: Natural -> Term
    naturalToNaturalLiteral :: Natural -> Term
    naturalToNaturalLiteral = Literal -> Term
    Literal (Literal -> Term) -> (Natural -> Literal) -> Natural -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    NaturalLiteral (Integer -> Literal) -> (Natural -> Integer) -> Natural -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Natural -> Integer
    forall a. Integral a => a -> Integer
    toInteger

    bConPrim :: Type -> Term
    bConPrim :: Type -> Term
    bConPrim (Type -> TypeView
    tyView -> TyConApp TyConName
    bTcNm [Type]
    _)
      = PrimInfo -> Term
    Prim (Text
    -> Type -> WorkInfo -> IsMultiPrim -> PrimUnfolding -> PrimInfo
    PrimInfo Text
    "Clash.Sized.Internal.BitVector.fromInteger##" Type
    funTy WorkInfo
    WorkNever IsMultiPrim
    SingleResult PrimUnfolding
    NoUnfolding)
      where
        funTy :: Type
    funTy      = (Type -> Type -> Type) -> [Type] -> Type
    forall a. (a -> a -> a) -> [a] -> a
    forall (t :: Type -> Type) a.
    Foldable t =>
    (a -> a -> a) -> t a -> a
    foldr1 Type -> Type -> Type
    mkFunTy [Type
    wordPrimTy,Type
    integerPrimTy,TyConName -> [Type] -> Type
    mkTyConApp TyConName
    bTcNm []]
    bConPrim Type
    _ = [Char] -> Term
    forall a. HasCallStack => [Char] -> a
    error ([Char] -> Term) -> [Char] -> Term
    forall a b. (a -> b) -> a -> b
    $ $(curLoc) [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "called with incorrect type"

    bvConPrim :: Type -> Term
    bvConPrim :: Type -> Term
    bvConPrim (Type -> TypeView
    tyView -> TyConApp TyConName
    bvTcNm [Type]
    _)
      = PrimInfo -> Term
    Prim (Text
    -> Type -> WorkInfo -> IsMultiPrim -> PrimUnfolding -> PrimInfo
    PrimInfo Text
    "Clash.Sized.Internal.BitVector.fromInteger#" (TyVar -> Type -> Type
    ForAllTy TyVar
    nTV Type
    funTy) WorkInfo
    WorkNever IsMultiPrim
    SingleResult PrimUnfolding
    NoUnfolding)
      where
        funTy :: Type
    funTy = (Type -> Type -> Type) -> [Type] -> Type
    forall a. (a -> a -> a) -> [a] -> a
    forall (t :: Type -> Type) a.
    Foldable t =>
    (a -> a -> a) -> t a -> a
    foldr1 Type -> Type -> Type
    mkFunTy [Type
    naturalPrimTy,Type
    naturalPrimTy,Type
    integerPrimTy,TyConName -> [Type] -> Type
    mkTyConApp TyConName
    bvTcNm [Type
    nVar]]
        nName :: Name a
    nName = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "n" Unique
    0
        nVar :: Type
    nVar  = TyVar -> Type
    VarTy TyVar
    nTV
        nTV :: TyVar
    nTV   = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind TyName
    forall {a}. Name a
    nName
    bvConPrim Type
    _ = [Char] -> Term
    forall a. HasCallStack => [Char] -> a
    error ([Char] -> Term) -> [Char] -> Term
    forall a b. (a -> b) -> a -> b
    $ $(curLoc) [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "called with incorrect type"

    indexConPrim :: Type -> Term
    indexConPrim :: Type -> Term
    indexConPrim (Type -> TypeView
    tyView -> TyConApp TyConName
    indexTcNm [Type]
    _)
      = PrimInfo -> Term
    Prim (Text
    -> Type -> WorkInfo -> IsMultiPrim -> PrimUnfolding -> PrimInfo
    PrimInfo Text
    "Clash.Sized.Internal.Index.fromInteger#" (TyVar -> Type -> Type
    ForAllTy TyVar
    nTV Type
    funTy) WorkInfo
    WorkNever IsMultiPrim
    SingleResult PrimUnfolding
    NoUnfolding)
      where
        funTy :: Type
    funTy        = (Type -> Type -> Type) -> [Type] -> Type
    forall a. (a -> a -> a) -> [a] -> a
    forall (t :: Type -> Type) a.
    Foldable t =>
    (a -> a -> a) -> t a -> a
    foldr1 Type -> Type -> Type
    mkFunTy [Type
    naturalPrimTy,Type
    integerPrimTy,TyConName -> [Type] -> Type
    mkTyConApp TyConName
    indexTcNm [Type
    nVar]]
        nName :: Name a
    nName      = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "n" Unique
    0
        nVar :: Type
    nVar       = TyVar -> Type
    VarTy TyVar
    nTV
        nTV :: TyVar
    nTV        = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind TyName
    forall {a}. Name a
    nName
    indexConPrim Type
    _ = [Char] -> Term
    forall a. HasCallStack => [Char] -> a
    error ([Char] -> Term) -> [Char] -> Term
    forall a b. (a -> b) -> a -> b
    $ $(curLoc) [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "called with incorrect type"

    signedConPrim :: Type -> Term
    signedConPrim :: Type -> Term
    signedConPrim (Type -> TypeView
    tyView -> TyConApp TyConName
    signedTcNm [Type]
    _)
      = PrimInfo -> Term
    Prim (Text
    -> Type -> WorkInfo -> IsMultiPrim -> PrimUnfolding -> PrimInfo
    PrimInfo Text
    "Clash.Sized.Internal.Signed.fromInteger#" (TyVar -> Type -> Type
    ForAllTy TyVar
    nTV Type
    funTy) WorkInfo
    WorkNever IsMultiPrim
    SingleResult PrimUnfolding
    NoUnfolding)
      where
        funTy :: Type
    funTy        = (Type -> Type -> Type) -> [Type] -> Type
    forall a. (a -> a -> a) -> [a] -> a
    forall (t :: Type -> Type) a.
    Foldable t =>
    (a -> a -> a) -> t a -> a
    foldr1 Type -> Type -> Type
    mkFunTy [Type
    naturalPrimTy,Type
    integerPrimTy,TyConName -> [Type] -> Type
    mkTyConApp TyConName
    signedTcNm [Type
    nVar]]
        nName :: Name a
    nName      = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "n" Unique
    0
        nVar :: Type
    nVar       = TyVar -> Type
    VarTy TyVar
    nTV
        nTV :: TyVar
    nTV        = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind TyName
    forall {a}. Name a
    nName
    signedConPrim Type
    _ = [Char] -> Term
    forall a. HasCallStack => [Char] -> a
    error ([Char] -> Term) -> [Char] -> Term
    forall a b. (a -> b) -> a -> b
    $ $(curLoc) [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "called with incorrect type"

    unsignedConPrim :: Type -> Term
    unsignedConPrim :: Type -> Term
    unsignedConPrim (Type -> TypeView
    tyView -> TyConApp TyConName
    unsignedTcNm [Type]
    _)
      = PrimInfo -> Term
    Prim (Text
    -> Type -> WorkInfo -> IsMultiPrim -> PrimUnfolding -> PrimInfo
    PrimInfo Text
    "Clash.Sized.Internal.Unsigned.fromInteger#" (TyVar -> Type -> Type
    ForAllTy TyVar
    nTV Type
    funTy) WorkInfo
    WorkNever IsMultiPrim
    SingleResult PrimUnfolding
    NoUnfolding)
      where
        funTy :: Type
    funTy        = (Type -> Type -> Type) -> [Type] -> Type
    forall a. (a -> a -> a) -> [a] -> a
    forall (t :: Type -> Type) a.
    Foldable t =>
    (a -> a -> a) -> t a -> a
    foldr1 Type -> Type -> Type
    mkFunTy [Type
    naturalPrimTy,Type
    integerPrimTy,TyConName -> [Type] -> Type
    mkTyConApp TyConName
    unsignedTcNm [Type
    nVar]]
        nName :: Name a
    nName        = Text -> Unique -> Name a
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "n" Unique
    0
        nVar :: Type
    nVar         = TyVar -> Type
    VarTy TyVar
    nTV
        nTV :: TyVar
    nTV          = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind TyName
    forall {a}. Name a
    nName
    unsignedConPrim Type
    _ = [Char] -> Term
    forall a. HasCallStack => [Char] -> a
    error ([Char] -> Term) -> [Char] -> Term
    forall a b. (a -> b) -> a -> b
    $ $(curLoc) [Char] -> [Char] -> [Char]
    forall a. [a] -> [a] -> [a]
    ++ [Char]
    "called with incorrect type"

    -- |  Lift a binary function over 'Unsigned' values to be used as literal Evaluator
    --
    --
    liftUnsigned2 :: KnownNat n
                  => (Unsigned n -> Unsigned n -> Unsigned n)
                  -> Type
                  -> TyConMap
                  -> [Type]
                  -> [Value]
                  -> (Proxy n -> Maybe Term)
    liftUnsigned2 :: forall (n :: Natural).
    KnownNat n =>
    (Unsigned n -> Unsigned n -> Unsigned n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftUnsigned2 = ([Value] -> [Integer])
    -> (Type -> Type -> Integer -> Integer -> Term)
    -> (Unsigned n -> Unsigned n -> Unsigned n)
    -> Type
    -> TyConMap
    -> [Type]
    -> [Value]
    -> Proxy n
    -> Maybe Term
    forall (n :: Natural) (sized :: Natural -> Type).
    (KnownNat n, Integral (sized n)) =>
    ([Value] -> [Integer])
    -> (Type -> Type -> Integer -> Integer -> Term)
    -> (sized n -> sized n -> sized n)
    -> Type
    -> TyConMap
    -> [Type]
    -> [Value]
    -> Proxy n
    -> Maybe Term
    liftSized2 [Value] -> [Integer]
    unsignedLiterals' Type -> Type -> Integer -> Integer -> Term
    mkUnsignedLit

    liftSigned2 :: KnownNat n
                  => (Signed n -> Signed n -> Signed n)
                  -> Type
                  -> TyConMap
                  -> [Type]
                  -> [Value]
                  -> (Proxy n -> Maybe Term)
    liftSigned2 :: forall (n :: Natural).
    KnownNat n =>
    (Signed n -> Signed n -> Signed n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftSigned2 = ([Value] -> [Integer])
    -> (Type -> Type -> Integer -> Integer -> Term)
    -> (Signed n -> Signed n -> Signed n)
    -> Type
    -> TyConMap
    -> [Type]
    -> [Value]
    -> Proxy n
    -> Maybe Term
    forall (n :: Natural) (sized :: Natural -> Type).
    (KnownNat n, Integral (sized n)) =>
    ([Value] -> [Integer])
    -> (Type -> Type -> Integer -> Integer -> Term)
    -> (sized n -> sized n -> sized n)
    -> Type
    -> TyConMap
    -> [Type]
    -> [Value]
    -> Proxy n
    -> Maybe Term
    liftSized2 [Value] -> [Integer]
    signedLiterals' Type -> Type -> Integer -> Integer -> Term
    mkSignedLit

    liftBitVector2 :: KnownNat n
                  => (BitVector n -> BitVector n -> BitVector n)
                  -> Type
                  -> TyConMap
                  -> [Type]
                  -> [Value]
                  -> (Proxy n -> Maybe Term)
    liftBitVector2 :: forall (n :: Natural).
    KnownNat n =>
    (BitVector n -> BitVector n -> BitVector n)
    -> Type -> TyConMap -> [Type] -> [Value] -> Proxy n -> Maybe Term
    liftBitVector2  BitVector n -> BitVector n -> BitVector n
    f Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args Proxy n
    _p
      | Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
      , [(Integer, Integer)
    i,(Integer, Integer)
    j] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
      = let BV Natural
    mask Natural
    val = BitVector n -> BitVector n -> BitVector n
    f ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i) ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    j)
        in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Term -> Maybe Term) -> Term -> Maybe Term
    forall a b. (a -> b) -> a -> b
    $ Type -> Type -> Integer -> Integer -> Integer -> Term
    mkBitVectorLit Type
    ty Type
    nTy Integer
    kn (Natural -> Integer
    forall a. Integral a => a -> Integer
    toInteger Natural
    mask) (Natural -> Integer
    forall a. Integral a => a -> Integer
    toInteger Natural
    val)
      | Bool
    otherwise = Maybe Term
    forall a. Maybe a
    Nothing

    liftBitVector2Bool :: KnownNat n
                  => (BitVector n -> BitVector n -> Bool)
                  -> Type
                  -> TyConMap
                  -> [Value]
                  -> (Proxy n -> Maybe Term)
    liftBitVector2Bool :: forall (n :: Natural).
    KnownNat n =>
    (BitVector n -> BitVector n -> Bool)
    -> Type -> TyConMap -> [Value] -> Proxy n -> Maybe Term
    liftBitVector2Bool  BitVector n -> BitVector n -> Bool
    f Type
    ty TyConMap
    tcm [Value]
    args Proxy n
    _p
      | [(Integer, Integer)
    i,(Integer, Integer)
    j] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
      = let val :: Bool
    val = BitVector n -> BitVector n -> Bool
    f ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i) ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    j)
        in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Term -> Maybe Term) -> Term -> Maybe Term
    forall a b. (a -> b) -> a -> b
    $ TyConMap -> Type -> Bool -> Term
    boolToBoolLiteral TyConMap
    tcm Type
    ty Bool
    val
      | Bool
    otherwise = Maybe Term
    forall a. Maybe a
    Nothing

    liftInteger2BitVector
      :: KnownNat n
      => (Integer -> BitVector n)
      -> (Type, Type, Integer)
      -> [Value]
      -> (Proxy n -> Maybe Term)
    liftInteger2BitVector :: forall (n :: Natural).
    KnownNat n =>
    (Integer -> BitVector n)
    -> (Type, Type, Integer) -> [Value] -> Proxy n -> Maybe Term
    liftInteger2BitVector Integer -> BitVector n
    f (Type, Type, Integer)
    resTyInfo [Value]
    args Proxy n
    _p
      | [Integer
    i] <- [Value] -> [Integer]
    intCLiterals' [Value]
    args
      = let BV Natural
    msk Natural
    val = Integer -> BitVector n
    f Integer
    i
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just ((Type, Type, Integer) -> Integer -> Integer -> Term
    mkBitVectorLit' (Type, Type, Integer)
    resTyInfo (Natural -> Integer
    forall a. Integral a => a -> Integer
    toInteger Natural
    msk) (Natural -> Integer
    forall a. Integral a => a -> Integer
    toInteger Natural
    val))

      | Bool
    otherwise
      = Maybe Term
    forall a. Maybe a
    Nothing

    liftBitVector2CInt
      :: KnownNat n
      => TyConMap
      -> Type
      -> (BitVector n -> Integer)
      -> [Value]
      -> (Proxy n -> Maybe Term)
    liftBitVector2CInt :: forall (n :: Natural).
    KnownNat n =>
    TyConMap
    -> Type
    -> (BitVector n -> Integer)
    -> [Value]
    -> Proxy n
    -> Maybe Term
    liftBitVector2CInt TyConMap
    tcm Type
    resTy BitVector n -> Integer
    f [Value]
    args Proxy n
    _p
      | [(Integer, Integer)
    i] <- [Value] -> [(Integer, Integer)]
    bitVectorLiterals' [Value]
    args
      = let val :: Integer
    val = BitVector n -> Integer
    f ((Integer, Integer) -> BitVector n
    forall (n :: Natural). (Integer, Integer) -> BitVector n
    toBV (Integer, Integer)
    i)
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Term -> Maybe Term) -> Term -> Maybe Term
    forall a b. (a -> b) -> a -> b
    $ TyConMap -> Integer -> Type -> Term
    mkIntCLit TyConMap
    tcm Integer
    val Type
    resTy
      | Bool
    otherwise
      = Maybe Term
    forall a. Maybe a
    Nothing

    liftSized2 :: (KnownNat n, Integral (sized n))
               => ([Value] -> [Integer])
                  -- ^ literal argument extraction function
               -> (Type -> Type -> Integer -> Integer -> Term)
                  -- ^ literal contruction function
               -> (sized n -> sized n -> sized n)
               -> Type
               -> TyConMap
               -> [Type]
               -> [Value]
               -> (Proxy n -> Maybe Term)
    liftSized2 :: forall (n :: Natural) (sized :: Natural -> Type).
    (KnownNat n, Integral (sized n)) =>
    ([Value] -> [Integer])
    -> (Type -> Type -> Integer -> Integer -> Term)
    -> (sized n -> sized n -> sized n)
    -> Type
    -> TyConMap
    -> [Type]
    -> [Value]
    -> Proxy n
    -> Maybe Term
    liftSized2 [Value] -> [Integer]
    extractLitArgs Type -> Type -> Integer -> Integer -> Term
    mkLit sized n -> sized n -> sized n
    f Type
    ty TyConMap
    tcm [Type]
    tys [Value]
    args Proxy n
    p
      | Just (Type
    nTy, Integer
    kn) <- TyConMap -> [Type] -> Maybe (Type, Integer)
    extractKnownNat TyConMap
    tcm [Type]
    tys
      , [Integer
    i,Integer
    j] <- [Value] -> [Integer]
    extractLitArgs [Value]
    args
      = let val :: Integer
    val = (sized n -> sized n -> sized n)
    -> Integer -> Integer -> Proxy n -> Integer
    forall (n :: Natural) (sized :: Natural -> Type).
    (KnownNat n, Integral (sized n)) =>
    (sized n -> sized n -> sized n)
    -> Integer -> Integer -> Proxy n -> Integer
    runSizedF sized n -> sized n -> sized n
    f Integer
    i Integer
    j Proxy n
    p
        in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Term -> Maybe Term) -> Term -> Maybe Term
    forall a b. (a -> b) -> a -> b
    $ Type -> Type -> Integer -> Integer -> Term
    mkLit Type
    ty Type
    nTy Integer
    kn Integer
    val
      | Bool
    otherwise = Maybe Term
    forall a. Maybe a
    Nothing

    -- | Helper to run a function over sized types on integers
    --
    -- This only works on function of type (sized n -> sized n -> sized n)
    -- The resulting function must be executed with reifyNat
    runSizedF
      :: (KnownNat n, Integral (sized n))
      => (sized n -> sized n -> sized n)
      -- ^ function to run
      -> Integer
      -- ^ first  argument
      -> Integer
      -- ^ second argument
      -> (Proxy n -> Integer)
    runSizedF :: forall (n :: Natural) (sized :: Natural -> Type).
    (KnownNat n, Integral (sized n)) =>
    (sized n -> sized n -> sized n)
    -> Integer -> Integer -> Proxy n -> Integer
    runSizedF sized n -> sized n -> sized n
    f Integer
    i Integer
    j Proxy n
    _ = sized n -> Integer
    forall a. Integral a => a -> Integer
    toInteger (sized n -> Integer) -> sized n -> Integer
    forall a b. (a -> b) -> a -> b
    $ sized n -> sized n -> sized n
    f (Integer -> sized n
    forall a. Num a => Integer -> a
    fromInteger Integer
    i) (Integer -> sized n
    forall a. Num a => Integer -> a
    fromInteger Integer
    j)

    extractTySizeInfo :: TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo :: TyConMap -> Type -> [Type] -> (Type, Type, Integer)
    extractTySizeInfo TyConMap
    tcm Type
    ty [Type]
    tys = (Type
    resTy,Type
    resSizeTy,Integer
    resSize)
      where
        ty' :: Type
    ty' = HasCallStack => TyConMap -> Type -> [Type] -> Type
    TyConMap -> Type -> [Type] -> Type
    piResultTys TyConMap
    tcm Type
    ty [Type]
    tys
        ([Either TyVar Type]
    _,Type
    resTy) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty'
        TyConApp TyConName
    _ [Type
    resSizeTy] = Type -> TypeView
    tyView Type
    resTy
        Right Integer
    resSize = Except [Char] Integer -> Either [Char] Integer
    forall e a. Except e a -> Either e a
    runExcept (TyConMap -> Type -> Except [Char] Integer
    tyNatSize TyConMap
    tcm Type
    resSizeTy)

    getResultTy
      :: TyConMap
      -> Type
      -> [Type]
      -> Type
    getResultTy :: TyConMap -> Type -> [Type] -> Type
    getResultTy TyConMap
    tcm Type
    ty [Type]
    tys = Type
    resTy
     where
      ty' :: Type
    ty' = HasCallStack => TyConMap -> Type -> [Type] -> Type
    TyConMap -> Type -> [Type] -> Type
    piResultTys TyConMap
    tcm Type
    ty [Type]
    tys
      ([Either TyVar Type]
    _,Type
    resTy) = Type -> ([Either TyVar Type], Type)
    splitFunForallTy Type
    ty'

    liftDDI :: (Double# -> Double# -> Int#) -> [Value] -> Maybe Term
    liftDDI :: (Double# -> Double# -> Int#) -> [Value] -> Maybe Term
    liftDDI Double# -> Double# -> Int#
    f [Value]
    args = case [Value] -> [Word64]
    doubleLiterals' [Value]
    args of
      [Word64
    i,Word64
    j] -> Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Term -> Maybe Term) -> Term -> Maybe Term
    forall a b. (a -> b) -> a -> b
    $ (Double# -> Double# -> Int#) -> Word64 -> Word64 -> Term
    runDDI Double# -> Double# -> Int#
    f Word64
    i Word64
    j
      [Word64]
    _     -> Maybe Term
    forall a. Maybe a
    Nothing
    liftDDD :: (Double# -> Double# -> Double#) -> [Value] -> Maybe Term
    liftDDD :: (Double# -> Double# -> Double#) -> [Value] -> Maybe Term
    liftDDD Double# -> Double# -> Double#
    f [Value]
    args = case [Value] -> [Word64]
    doubleLiterals' [Value]
    args of
      [Word64
    i,Word64
    j] -> Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Term -> Maybe Term) -> Term -> Maybe Term
    forall a b. (a -> b) -> a -> b
    $ (Double# -> Double# -> Double#) -> Word64 -> Word64 -> Term
    runDDD Double# -> Double# -> Double#
    f Word64
    i Word64
    j
      [Word64]
    _     -> Maybe Term
    forall a. Maybe a
    Nothing
    liftDD  :: (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD :: (Double# -> Double#) -> [Value] -> Maybe Term
    liftDD  Double# -> Double#
    f [Value]
    args = case [Value] -> [Word64]
    doubleLiterals' [Value]
    args of
      [Word64
    i]   -> Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Term -> Maybe Term) -> Term -> Maybe Term
    forall a b. (a -> b) -> a -> b
    $ (Double# -> Double#) -> Word64 -> Term
    runDD Double# -> Double#
    f Word64
    i
      [Word64]
    _     -> Maybe Term
    forall a. Maybe a
    Nothing
    runDDI :: (Double# -> Double# -> Int#) -> Word64 -> Word64 -> Term
    runDDI :: (Double# -> Double# -> Int#) -> Word64 -> Word64 -> Term
    runDDI Double# -> Double# -> Int#
    f Word64
    i Word64
    j
      = let !(D# Double#
    a) = Word64 -> Double
    wordToDouble Word64
    i
            !(D# Double#
    b) = Word64 -> Double
    wordToDouble Word64
    j
            r :: Int#
    r = Double# -> Double# -> Int#
    f Double#
    a Double#
    b
        in  Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Term) -> Unique -> Term
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    r
    runDDD :: (Double# -> Double# -> Double#) -> Word64 -> Word64 -> Term
    runDDD :: (Double# -> Double# -> Double#) -> Word64 -> Word64 -> Term
    runDDD Double# -> Double# -> Double#
    f Word64
    i Word64
    j
      = let !(D# Double#
    a) = Word64 -> Double
    wordToDouble Word64
    i
            !(D# Double#
    b) = Word64 -> Double
    wordToDouble Word64
    j
            r :: Double#
    r = Double# -> Double# -> Double#
    f Double#
    a Double#
    b
        in  Literal -> Term
    Literal (Literal -> Term) -> (Double -> Literal) -> Double -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Literal
    DoubleLiteral (Word64 -> Literal) -> (Double -> Word64) -> Double -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Double -> Word64
    doubleToWord (Double -> Term) -> Double -> Term
    forall a b. (a -> b) -> a -> b
    $ Double# -> Double
    D# Double#
    r
    runDD :: (Double# -> Double#) -> Word64 -> Term
    runDD :: (Double# -> Double#) -> Word64 -> Term
    runDD Double# -> Double#
    f Word64
    i
      = let !(D# Double#
    a) = Word64 -> Double
    wordToDouble Word64
    i
            r :: Double#
    r = Double# -> Double#
    f Double#
    a
        in  Literal -> Term
    Literal (Literal -> Term) -> (Double -> Literal) -> Double -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word64 -> Literal
    DoubleLiteral (Word64 -> Literal) -> (Double -> Word64) -> Double -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Double -> Word64
    doubleToWord (Double -> Term) -> Double -> Term
    forall a b. (a -> b) -> a -> b
    $ Double# -> Double
    D# Double#
    r

    liftFFI :: (Float# -> Float# -> Int#) -> [Value] -> Maybe Term
    liftFFI :: (Float# -> Float# -> Int#) -> [Value] -> Maybe Term
    liftFFI Float# -> Float# -> Int#
    f [Value]
    args = case [Value] -> [Word32]
    floatLiterals' [Value]
    args of
      [Word32
    i,Word32
    j] -> Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Term -> Maybe Term) -> Term -> Maybe Term
    forall a b. (a -> b) -> a -> b
    $ (Float# -> Float# -> Int#) -> Word32 -> Word32 -> Term
    runFFI Float# -> Float# -> Int#
    f Word32
    i Word32
    j
      [Word32]
    _     -> Maybe Term
    forall a. Maybe a
    Nothing
    liftFFF :: (Float# -> Float# -> Float#) -> [Value] -> Maybe Term
    liftFFF :: (Float# -> Float# -> Float#) -> [Value] -> Maybe Term
    liftFFF Float# -> Float# -> Float#
    f [Value]
    args = case [Value] -> [Word32]
    floatLiterals' [Value]
    args of
      [Word32
    i,Word32
    j] -> Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Term -> Maybe Term) -> Term -> Maybe Term
    forall a b. (a -> b) -> a -> b
    $ (Float# -> Float# -> Float#) -> Word32 -> Word32 -> Term
    runFFF Float# -> Float# -> Float#
    f Word32
    i Word32
    j
      [Word32]
    _     -> Maybe Term
    forall a. Maybe a
    Nothing
    liftFF  :: (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF :: (Float# -> Float#) -> [Value] -> Maybe Term
    liftFF  Float# -> Float#
    f [Value]
    args = case [Value] -> [Word32]
    floatLiterals' [Value]
    args of
      [Word32
    i]   -> Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Term -> Maybe Term) -> Term -> Maybe Term
    forall a b. (a -> b) -> a -> b
    $ (Float# -> Float#) -> Word32 -> Term
    runFF Float# -> Float#
    f Word32
    i
      [Word32]
    _     -> Maybe Term
    forall a. Maybe a
    Nothing
    runFFI :: (Float# -> Float# -> Int#) -> Word32 -> Word32 -> Term
    runFFI :: (Float# -> Float# -> Int#) -> Word32 -> Word32 -> Term
    runFFI Float# -> Float# -> Int#
    f Word32
    i Word32
    j
      = let !(F# Float#
    a) = Word32 -> Float
    wordToFloat Word32
    i
            !(F# Float#
    b) = Word32 -> Float
    wordToFloat Word32
    j
            r :: Int#
    r = Float# -> Float# -> Int#
    f Float#
    a Float#
    b
        in  Literal -> Term
    Literal (Literal -> Term) -> (Unique -> Literal) -> Unique -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Integer -> Literal
    IntLiteral (Integer -> Literal) -> (Unique -> Integer) -> Unique -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Unique -> Term) -> Unique -> Term
    forall a b. (a -> b) -> a -> b
    $ Int# -> Unique
    I# Int#
    r
    runFFF :: (Float# -> Float# -> Float#) -> Word32 -> Word32 -> Term
    runFFF :: (Float# -> Float# -> Float#) -> Word32 -> Word32 -> Term
    runFFF Float# -> Float# -> Float#
    f Word32
    i Word32
    j
      = let !(F# Float#
    a) = Word32 -> Float
    wordToFloat Word32
    i
            !(F# Float#
    b) = Word32 -> Float
    wordToFloat Word32
    j
            r :: Float#
    r = Float# -> Float# -> Float#
    f Float#
    a Float#
    b
        in  Literal -> Term
    Literal (Literal -> Term) -> (Float -> Literal) -> Float -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word32 -> Literal
    FloatLiteral (Word32 -> Literal) -> (Float -> Word32) -> Float -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Float -> Word32
    floatToWord (Float -> Term) -> Float -> Term
    forall a b. (a -> b) -> a -> b
    $ Float# -> Float
    F# Float#
    r
    runFF :: (Float# -> Float#) -> Word32 -> Term
    runFF :: (Float# -> Float#) -> Word32 -> Term
    runFF Float# -> Float#
    f Word32
    i
      = let !(F# Float#
    a) = Word32 -> Float
    wordToFloat Word32
    i
            r :: Float#
    r = Float# -> Float#
    f Float#
    a
        in  Literal -> Term
    Literal (Literal -> Term) -> (Float -> Literal) -> Float -> Term
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word32 -> Literal
    FloatLiteral (Word32 -> Literal) -> (Float -> Word32) -> Float -> Literal
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Float -> Word32
    floatToWord (Float -> Term) -> Float -> Term
    forall a b. (a -> b) -> a -> b
    $ Float# -> Float
    F# Float#
    r

    #if MIN_VERSION_base(4,16,0)
    liftI8 :: (Int8# -> Int8# -> Int8#) -> [Value] -> Maybe Term
    liftI8 :: (Int8# -> Int8# -> Int8#) -> [Value] -> Maybe Term
    liftI8 Int8# -> Int8# -> Int8#
    f [Value]
    args = case [Value] -> [Integer]
    int8Literals' [Value]
    args of
      [Integer
    i,Integer
    j] ->
        let !(I8# Int8#
    a) = Integer -> Int8
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(I8# Int8#
    b) = Integer -> Int8
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    Int8Literal (Int8 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int8# -> Int8
    I8# (Int8# -> Int8# -> Int8#
    f Int8#
    a Int8#
    b)))))
      [Integer]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftI8I :: (Int8# -> Int# -> Int8#) -> [Value] -> Maybe Term
    liftI8I :: (Int8# -> Int# -> Int8#) -> [Value] -> Maybe Term
    liftI8I Int8# -> Int# -> Int8#
    f [Value]
    args = case [Value]
    args of
      [Lit (Int8Literal Integer
    i),Lit (IntLiteral Integer
    j)] ->
        let !(I8# Int8#
    a) = Integer -> Int8
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(I# Int#
    b) = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    Int8Literal (Int8 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int8# -> Int8
    I8# (Int8# -> Int# -> Int8#
    f Int8#
    a Int#
    b)))))
      [Value]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftI8RI :: (Int8# -> Int8# -> Int#) -> [Value] -> Maybe Term
    liftI8RI :: (Int8# -> Int8# -> Int#) -> [Value] -> Maybe Term
    liftI8RI Int8# -> Int8# -> Int#
    f [Value]
    args = case [Value] -> [Integer]
    int8Literals' [Value]
    args of
      [Integer
    i,Integer
    j] ->
        let !(I8# Int8#
    a) = Integer -> Int8
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(I8# Int8#
    b) = Integer -> Int8
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int# -> Unique
    I# (Int8# -> Int8# -> Int#
    f Int8#
    a Int8#
    b)))))
      [Integer]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftI16 :: (Int16# -> Int16# -> Int16#) -> [Value] -> Maybe Term
    liftI16 :: (Int16# -> Int16# -> Int16#) -> [Value] -> Maybe Term
    liftI16 Int16# -> Int16# -> Int16#
    f [Value]
    args = case [Value] -> [Integer]
    int16Literals' [Value]
    args of
      [Integer
    i,Integer
    j] ->
        let !(I16# Int16#
    a) = Integer -> Int16
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(I16# Int16#
    b) = Integer -> Int16
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    Int16Literal (Int16 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int16# -> Int16
    I16# (Int16# -> Int16# -> Int16#
    f Int16#
    a Int16#
    b)))))
      [Integer]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftI16I :: (Int16# -> Int# -> Int16#) -> [Value] -> Maybe Term
    liftI16I :: (Int16# -> Int# -> Int16#) -> [Value] -> Maybe Term
    liftI16I Int16# -> Int# -> Int16#
    f [Value]
    args = case [Value]
    args of
      [Lit (Int16Literal Integer
    i),Lit (IntLiteral Integer
    j)] ->
        let !(I16# Int16#
    a) = Integer -> Int16
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(I# Int#
    b) = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    Int16Literal (Int16 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int16# -> Int16
    I16# (Int16# -> Int# -> Int16#
    f Int16#
    a Int#
    b)))))
      [Value]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftI16RI :: (Int16# -> Int16# -> Int#) -> [Value] -> Maybe Term
    liftI16RI :: (Int16# -> Int16# -> Int#) -> [Value] -> Maybe Term
    liftI16RI Int16# -> Int16# -> Int#
    f [Value]
    args = case [Value] -> [Integer]
    int16Literals' [Value]
    args of
      [Integer
    i,Integer
    j] ->
        let !(I16# Int16#
    a) = Integer -> Int16
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(I16# Int16#
    b) = Integer -> Int16
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int# -> Unique
    I# (Int16# -> Int16# -> Int#
    f Int16#
    a Int16#
    b)))))
      [Integer]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftI32 :: (Int32# -> Int32# -> Int32#) -> [Value] -> Maybe Term
    liftI32 :: (Int32# -> Int32# -> Int32#) -> [Value] -> Maybe Term
    liftI32 Int32# -> Int32# -> Int32#
    f [Value]
    args = case [Value] -> [Integer]
    int32Literals' [Value]
    args of
      [Integer
    i,Integer
    j] ->
        let !(I32# Int32#
    a) = Integer -> Int32
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(I32# Int32#
    b) = Integer -> Int32
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    Int32Literal (Int32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int32# -> Int32
    I32# (Int32# -> Int32# -> Int32#
    f Int32#
    a Int32#
    b)))))
      [Integer]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftI32I :: (Int32# -> Int# -> Int32#) -> [Value] -> Maybe Term
    liftI32I :: (Int32# -> Int# -> Int32#) -> [Value] -> Maybe Term
    liftI32I Int32# -> Int# -> Int32#
    f [Value]
    args = case [Value]
    args of
      [Lit (Int32Literal Integer
    i),Lit (IntLiteral Integer
    j)] ->
        let !(I32# Int32#
    a) = Integer -> Int32
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(I# Int#
    b) = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    Int32Literal (Int32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int32# -> Int32
    I32# (Int32# -> Int# -> Int32#
    f Int32#
    a Int#
    b)))))
      [Value]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftI32RI :: (Int32# -> Int32# -> Int#) -> [Value] -> Maybe Term
    liftI32RI :: (Int32# -> Int32# -> Int#) -> [Value] -> Maybe Term
    liftI32RI Int32# -> Int32# -> Int#
    f [Value]
    args = case [Value] -> [Integer]
    int32Literals' [Value]
    args of
      [Integer
    i,Integer
    j] ->
        let !(I32# Int32#
    a) = Integer -> Int32
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(I32# Int32#
    b) = Integer -> Int32
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int# -> Unique
    I# (Int32# -> Int32# -> Int#
    f Int32#
    a Int32#
    b)))))
      [Integer]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    #if MIN_VERSION_base(4,17,0)
    liftI64 :: (Int64# -> Int64# -> Int64#) -> [Value] -> Maybe Term
    liftI64 :: (Int64# -> Int64# -> Int64#) -> [Value] -> Maybe Term
    liftI64 Int64# -> Int64# -> Int64#
    f [Value]
    args = case [Value] -> [Integer]
    int64Literals' [Value]
    args of
      [Integer
    i,Integer
    j] ->
        let !(I64# Int64#
    a) = Integer -> Int64
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(I64# Int64#
    b) = Integer -> Int64
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    Int64Literal (Int64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int64# -> Int64
    I64# (Int64# -> Int64# -> Int64#
    f Int64#
    a Int64#
    b)))))
      [Integer]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftI64I :: (Int64# -> Int# -> Int64#) -> [Value] -> Maybe Term
    liftI64I :: (Int64# -> Int# -> Int64#) -> [Value] -> Maybe Term
    liftI64I Int64# -> Int# -> Int64#
    f [Value]
    args = case [Value]
    args of
      [Lit (Int64Literal Integer
    i),Lit (IntLiteral Integer
    j)] ->
        let !(I64# Int64#
    a) = Integer -> Int64
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(I# Int#
    b) = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    Int64Literal (Int64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int64# -> Int64
    I64# (Int64# -> Int# -> Int64#
    f Int64#
    a Int#
    b)))))
      [Value]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftI64RI :: (Int64# -> Int64# -> Int#) -> [Value] -> Maybe Term
    liftI64RI :: (Int64# -> Int64# -> Int#) -> [Value] -> Maybe Term
    liftI64RI Int64# -> Int64# -> Int#
    f [Value]
    args = case [Value] -> [Integer]
    int64Literals' [Value]
    args of
      [Integer
    i,Integer
    j] ->
        let !(I64# Int64#
    a) = Integer -> Int64
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(I64# Int64#
    b) = Integer -> Int64
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int# -> Unique
    I# (Int64# -> Int64# -> Int#
    f Int64#
    a Int64#
    b)))))
      [Integer]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing
    #endif

    liftW8 :: (Word8# -> Word8# -> Word8#) -> [Value] -> Maybe Term
    liftW8 :: (Word8# -> Word8# -> Word8#) -> [Value] -> Maybe Term
    liftW8 Word8# -> Word8# -> Word8#
    f [Value]
    args = case [Value] -> [Integer]
    word8Literals' [Value]
    args of
      [Integer
    i,Integer
    j] ->
        let !(W8# Word8#
    a) = Integer -> Word8
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(W8# Word8#
    b) = Integer -> Word8
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    Word8Literal (Word8 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word8# -> Word8
    W8# (Word8# -> Word8# -> Word8#
    f Word8#
    a Word8#
    b)))))
      [Integer]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftW8I :: (Word8# -> Int# -> Word8#) -> [Value] -> Maybe Term
    liftW8I :: (Word8# -> Int# -> Word8#) -> [Value] -> Maybe Term
    liftW8I Word8# -> Int# -> Word8#
    f [Value]
    args = case [Value]
    args of
      [Lit (Word8Literal Integer
    i),Lit (IntLiteral Integer
    j)] ->
        let !(W8# Word8#
    a) = Integer -> Word8
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(I# Int#
    b) = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    Word8Literal (Word8 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word8# -> Word8
    W8# (Word8# -> Int# -> Word8#
    f Word8#
    a Int#
    b)))))
      [Value]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftW8RI :: (Word8# -> Word8# -> Int#) -> [Value] -> Maybe Term
    liftW8RI :: (Word8# -> Word8# -> Int#) -> [Value] -> Maybe Term
    liftW8RI Word8# -> Word8# -> Int#
    f [Value]
    args = case [Value] -> [Integer]
    word8Literals' [Value]
    args of
      [Integer
    i,Integer
    j] ->
        let !(W8# Word8#
    a) = Integer -> Word8
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(W8# Word8#
    b) = Integer -> Word8
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int# -> Unique
    I# (Word8# -> Word8# -> Int#
    f Word8#
    a Word8#
    b)))))
      [Integer]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftW16 :: (Word16# -> Word16# -> Word16#) -> [Value] -> Maybe Term
    liftW16 :: (Word16# -> Word16# -> Word16#) -> [Value] -> Maybe Term
    liftW16 Word16# -> Word16# -> Word16#
    f [Value]
    args = case [Value] -> [Integer]
    word16Literals' [Value]
    args of
      [Integer
    i,Integer
    j] -> let !(W16# Word16#
    a) = Integer -> Word16
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
                   !(W16# Word16#
    b) = Integer -> Word16
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
                in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    Word16Literal (Word16 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word16# -> Word16
    W16# (Word16# -> Word16# -> Word16#
    f Word16#
    a Word16#
    b)))))
      [Integer]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftW16I :: (Word16# -> Int# -> Word16#) -> [Value] -> Maybe Term
    liftW16I :: (Word16# -> Int# -> Word16#) -> [Value] -> Maybe Term
    liftW16I Word16# -> Int# -> Word16#
    f [Value]
    args = case [Value]
    args of
      [Lit (Word16Literal Integer
    i),Lit (IntLiteral Integer
    j)] ->
        let !(W16# Word16#
    a) = Integer -> Word16
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(I# Int#
    b) = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    Word16Literal (Word16 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word16# -> Word16
    W16# (Word16# -> Int# -> Word16#
    f Word16#
    a Int#
    b)))))
      [Value]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftW16RI :: (Word16# -> Word16# -> Int#) -> [Value] -> Maybe Term
    liftW16RI :: (Word16# -> Word16# -> Int#) -> [Value] -> Maybe Term
    liftW16RI Word16# -> Word16# -> Int#
    f [Value]
    args = case [Value] -> [Integer]
    word16Literals' [Value]
    args of
      [Integer
    i,Integer
    j] ->
        let !(W16# Word16#
    a) = Integer -> Word16
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(W16# Word16#
    b) = Integer -> Word16
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int# -> Unique
    I# (Word16# -> Word16# -> Int#
    f Word16#
    a Word16#
    b)))))
      [Integer]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftW32 :: (Word32# -> Word32# -> Word32#) -> [Value] -> Maybe Term
    liftW32 :: (Word32# -> Word32# -> Word32#) -> [Value] -> Maybe Term
    liftW32 Word32# -> Word32# -> Word32#
    f [Value]
    args = case [Value] -> [Integer]
    word32Literals' [Value]
    args of
      [Integer
    i,Integer
    j] -> let !(W32# Word32#
    a) = Integer -> Word32
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
                   !(W32# Word32#
    b) = Integer -> Word32
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
                in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    Word32Literal (Word32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word32# -> Word32
    W32# (Word32# -> Word32# -> Word32#
    f Word32#
    a Word32#
    b)))))
      [Integer]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftW32I :: (Word32# -> Int# -> Word32#) -> [Value] -> Maybe Term
    liftW32I :: (Word32# -> Int# -> Word32#) -> [Value] -> Maybe Term
    liftW32I Word32# -> Int# -> Word32#
    f [Value]
    args = case [Value]
    args of
      [Lit (Word32Literal Integer
    i),Lit (IntLiteral Integer
    j)] ->
        let !(W32# Word32#
    a) = Integer -> Word32
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(I# Int#
    b) = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    Word32Literal (Word32 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word32# -> Word32
    W32# (Word32# -> Int# -> Word32#
    f Word32#
    a Int#
    b)))))
      [Value]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftW32RI :: (Word32# -> Word32# -> Int#) -> [Value] -> Maybe Term
    liftW32RI :: (Word32# -> Word32# -> Int#) -> [Value] -> Maybe Term
    liftW32RI Word32# -> Word32# -> Int#
    f [Value]
    args = case [Value] -> [Integer]
    word32Literals' [Value]
    args of
      [Integer
    i,Integer
    j] ->
        let !(W32# Word32#
    a) = Integer -> Word32
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(W32# Word32#
    b) = Integer -> Word32
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int# -> Unique
    I# (Word32# -> Word32# -> Int#
    f Word32#
    a Word32#
    b)))))
      [Integer]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    #if MIN_VERSION_base(4,17,0)
    liftW64 :: (Word64# -> Word64# -> Word64#) -> [Value] -> Maybe Term
    liftW64 :: (Word64# -> Word64# -> Word64#) -> [Value] -> Maybe Term
    liftW64 Word64# -> Word64# -> Word64#
    f [Value]
    args = case [Value] -> [Integer]
    word64Literals' [Value]
    args of
      [Integer
    i,Integer
    j] -> let !(W64# Word64#
    a) = Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
                   !(W64# Word64#
    b) = Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
                in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    Word64Literal (Word64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word64# -> Word64
    W64# (Word64# -> Word64# -> Word64#
    f Word64#
    a Word64#
    b)))))
      [Integer]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftW64I :: (Word64# -> Int# -> Word64#) -> [Value] -> Maybe Term
    liftW64I :: (Word64# -> Int# -> Word64#) -> [Value] -> Maybe Term
    liftW64I Word64# -> Int# -> Word64#
    f [Value]
    args = case [Value]
    args of
      [Lit (Word64Literal Integer
    i),Lit (IntLiteral Integer
    j)] ->
        let !(W64# Word64#
    a) = Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(I# Int#
    b) = Integer -> Unique
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    Word64Literal (Word64 -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Word64# -> Word64
    W64# (Word64# -> Int# -> Word64#
    f Word64#
    a Int#
    b)))))
      [Value]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing

    liftW64RI :: (Word64# -> Word64# -> Int#) -> [Value] -> Maybe Term
    liftW64RI :: (Word64# -> Word64# -> Int#) -> [Value] -> Maybe Term
    liftW64RI Word64# -> Word64# -> Int#
    f [Value]
    args = case [Value] -> [Integer]
    word64Literals' [Value]
    args of
      [Integer
    i,Integer
    j] ->
        let !(W64# Word64#
    a) = Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger Integer
    i
            !(W64# Word64#
    b) = Integer -> Word64
    forall a. Num a => Integer -> a
    fromInteger Integer
    j
         in Term -> Maybe Term
    forall a. a -> Maybe a
    Just (Literal -> Term
    Literal (Integer -> Literal
    IntLiteral (Unique -> Integer
    forall a. Integral a => a -> Integer
    toInteger (Int# -> Unique
    I# (Word64# -> Word64# -> Int#
    f Word64#
    a Word64#
    b)))))
      [Integer]
    _ -> Maybe Term
    forall a. Maybe a
    Nothing
    #endif
    #endif

    splitAtPrim
      :: TyConName
      -- ^ SNat TyCon name
      -> TyConName
      -- ^ Vec TyCon name
      -> Term
    splitAtPrim :: TyConName -> TyConName -> Term
    splitAtPrim TyConName
    snatTcNm TyConName
    vecTcNm =
      PrimInfo -> Term
    Prim (Text
    -> Type -> WorkInfo -> IsMultiPrim -> PrimUnfolding -> PrimInfo
    PrimInfo Text
    "Clash.Sized.Vector.splitAt" (TyConName -> TyConName -> Type
    splitAtTy TyConName
    snatTcNm TyConName
    vecTcNm) WorkInfo
    WorkNever IsMultiPrim
    SingleResult PrimUnfolding
    NoUnfolding)

    splitAtTy
      :: TyConName
      -- ^ SNat TyCon name
      -> TyConName
      -- ^ Vec TyCon name
      -> Type
    splitAtTy :: TyConName -> TyConName -> Type
    splitAtTy TyConName
    snatNm TyConName
    vecNm =
      TyVar -> Type -> Type
    ForAllTy TyVar
    mTV (
      TyVar -> Type -> Type
    ForAllTy TyVar
    nTV (
      TyVar -> Type -> Type
    ForAllTy TyVar
    aTV (
      Type -> Type -> Type
    mkFunTy
        (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    snatNm [TyVar -> Type
    VarTy TyVar
    mTV])
        (Type -> Type -> Type
    mkFunTy
          (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecNm
                      [TyConName -> [Type] -> Type
    mkTyConApp TyConName
    typeNatAdd
                        [TyVar -> Type
    VarTy TyVar
    mTV
                        ,TyVar -> Type
    VarTy TyVar
    nTV]
                      ,TyVar -> Type
    VarTy TyVar
    aTV])
          (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    tupNm
                      [TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecNm
                                  [TyVar -> Type
    VarTy TyVar
    mTV
                                  ,TyVar -> Type
    VarTy TyVar
    aTV]
                      ,TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecNm
                                  [TyVar -> Type
    VarTy TyVar
    nTV
                                  ,TyVar -> Type
    VarTy TyVar
    aTV]])))))
      where
        mTV :: TyVar
    mTV   = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "m" Unique
    0)
        nTV :: TyVar
    nTV   = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "n" Unique
    1)
        aTV :: TyVar
    aTV   = Type -> TyName -> TyVar
    mkTyVar Type
    liftedTypeKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "a" Unique
    2)
        tupNm :: TyConName
    tupNm = TyCon -> TyConName
    ghcTyconToTyConName (Boxity -> Unique -> TyCon
    tupleTyCon Boxity
    Boxed Unique
    2)

    foldSplitAtTy
      :: TyConName
      -- ^ Vec TyCon name
      -> Type
    foldSplitAtTy :: TyConName -> Type
    foldSplitAtTy TyConName
    vecNm =
      TyVar -> Type -> Type
    ForAllTy TyVar
    mTV (
      TyVar -> Type -> Type
    ForAllTy TyVar
    nTV (
      TyVar -> Type -> Type
    ForAllTy TyVar
    aTV (
      Type -> Type -> Type
    mkFunTy
        Type
    naturalPrimTy
        (Type -> Type -> Type
    mkFunTy
          (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecNm
                      [TyConName -> [Type] -> Type
    mkTyConApp TyConName
    typeNatAdd
                        [TyVar -> Type
    VarTy TyVar
    mTV
                        ,TyVar -> Type
    VarTy TyVar
    nTV]
                      ,TyVar -> Type
    VarTy TyVar
    aTV])
          (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    tupNm
                      [TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecNm
                                  [TyVar -> Type
    VarTy TyVar
    mTV
                                  ,TyVar -> Type
    VarTy TyVar
    aTV]
                      ,TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecNm
                                  [TyVar -> Type
    VarTy TyVar
    nTV
                                  ,TyVar -> Type
    VarTy TyVar
    aTV]])))))
      where
        mTV :: TyVar
    mTV   = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "m" Unique
    0)
        nTV :: TyVar
    nTV   = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "n" Unique
    1)
        aTV :: TyVar
    aTV   = Type -> TyName -> TyVar
    mkTyVar Type
    liftedTypeKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "a" Unique
    2)
        tupNm :: TyConName
    tupNm = TyCon -> TyConName
    ghcTyconToTyConName (Boxity -> Unique -> TyCon
    tupleTyCon Boxity
    Boxed Unique
    2)

    vecAppendPrim
      :: TyConName
      -- ^ Vec TyCon name
      -> Term
    vecAppendPrim :: TyConName -> Term
    vecAppendPrim TyConName
    vecNm =
      PrimInfo -> Term
    Prim (Text
    -> Type -> WorkInfo -> IsMultiPrim -> PrimUnfolding -> PrimInfo
    PrimInfo Text
    "Clash.Sized.Vector.++" (TyConName -> Type
    vecAppendTy TyConName
    vecNm) WorkInfo
    WorkNever IsMultiPrim
    SingleResult PrimUnfolding
    NoUnfolding)

    vecAppendTy
      :: TyConName
      -- ^ Vec TyCon name
      -> Type
    vecAppendTy :: TyConName -> Type
    vecAppendTy TyConName
    vecNm =
        TyVar -> Type -> Type
    ForAllTy TyVar
    nTV (
        TyVar -> Type -> Type
    ForAllTy TyVar
    aTV (
        TyVar -> Type -> Type
    ForAllTy TyVar
    mTV (
        Type -> Type -> Type
    mkFunTy
          (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecNm [TyVar -> Type
    VarTy TyVar
    nTV
                            ,TyVar -> Type
    VarTy TyVar
    aTV
                            ])
          (Type -> Type -> Type
    mkFunTy
             (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecNm [TyVar -> Type
    VarTy TyVar
    mTV
                               ,TyVar -> Type
    VarTy TyVar
    aTV
                               ])
             (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecNm [TyConName -> [Type] -> Type
    mkTyConApp TyConName
    typeNatAdd
                                  [TyVar -> Type
    VarTy TyVar
    nTV
                                  ,TyVar -> Type
    VarTy TyVar
    mTV]
                               ,TyVar -> Type
    VarTy TyVar
    aTV
                               ])))))
      where
        nTV :: TyVar
    nTV = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "n" Unique
    0)
        aTV :: TyVar
    aTV = Type -> TyName -> TyVar
    mkTyVar Type
    liftedTypeKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "a" Unique
    1)
        mTV :: TyVar
    mTV = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "m" Unique
    2)

    vecZipWithPrim
      :: TyConName
      -- ^ Vec TyCon name
      -> Term
    vecZipWithPrim :: TyConName -> Term
    vecZipWithPrim TyConName
    vecNm =
      PrimInfo -> Term
    Prim (Text
    -> Type -> WorkInfo -> IsMultiPrim -> PrimUnfolding -> PrimInfo
    PrimInfo Text
    "Clash.Sized.Vector.zipWith" (TyConName -> Type
    vecZipWithTy TyConName
    vecNm) WorkInfo
    WorkNever IsMultiPrim
    SingleResult PrimUnfolding
    NoUnfolding)

    vecZipWithTy
      :: TyConName
      -- ^ Vec TyCon name
      -> Type
    vecZipWithTy :: TyConName -> Type
    vecZipWithTy TyConName
    vecNm =
      TyVar -> Type -> Type
    ForAllTy TyVar
    aTV (
      TyVar -> Type -> Type
    ForAllTy TyVar
    bTV (
      TyVar -> Type -> Type
    ForAllTy TyVar
    cTV (
      TyVar -> Type -> Type
    ForAllTy TyVar
    nTV (
      Type -> Type -> Type
    mkFunTy
        (Type -> Type -> Type
    mkFunTy Type
    aTy (Type -> Type -> Type
    mkFunTy Type
    bTy Type
    cTy))
        (Type -> Type -> Type
    mkFunTy
          (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecNm [Type
    nTy,Type
    aTy])
          (Type -> Type -> Type
    mkFunTy
            (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecNm [Type
    nTy,Type
    bTy])
            (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecNm [Type
    nTy,Type
    cTy])))))))
      where
        aTV :: TyVar
    aTV = Type -> TyName -> TyVar
    mkTyVar Type
    liftedTypeKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "a" Unique
    0)
        bTV :: TyVar
    bTV = Type -> TyName -> TyVar
    mkTyVar Type
    liftedTypeKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "b" Unique
    1)
        cTV :: TyVar
    cTV = Type -> TyName -> TyVar
    mkTyVar Type
    liftedTypeKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "c" Unique
    2)
        nTV :: TyVar
    nTV = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "n" Unique
    3)
        aTy :: Type
    aTy = TyVar -> Type
    VarTy TyVar
    aTV
        bTy :: Type
    bTy = TyVar -> Type
    VarTy TyVar
    bTV
        cTy :: Type
    cTy = TyVar -> Type
    VarTy TyVar
    cTV
        nTy :: Type
    nTy = TyVar -> Type
    VarTy TyVar
    nTV

    vecImapGoTy
      :: TyConName
      -- ^ Vec TyCon name
      -> TyConName
      -- ^ Index TyCon name
      -> Type
    vecImapGoTy :: TyConName -> TyConName -> Type
    vecImapGoTy TyConName
    vecTcNm TyConName
    indexTcNm =
      TyVar -> Type -> Type
    ForAllTy TyVar
    nTV (
      TyVar -> Type -> Type
    ForAllTy TyVar
    mTV (
      TyVar -> Type -> Type
    ForAllTy TyVar
    aTV (
      TyVar -> Type -> Type
    ForAllTy TyVar
    bTV (
      Type -> Type -> Type
    mkFunTy Type
    fTy
           (Type -> Type -> Type
    mkFunTy Type
    vecATy (Type -> Type -> Type
    mkFunTy Type
    indexTy Type
    vecBTy))))))
      where
        nTV :: TyVar
    nTV = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "n" Unique
    0)
        mTV :: TyVar
    mTV = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "m" Unique
    1)
        aTV :: TyVar
    aTV = Type -> TyName -> TyVar
    mkTyVar Type
    liftedTypeKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "a" Unique
    2)
        bTV :: TyVar
    bTV = Type -> TyName -> TyVar
    mkTyVar Type
    liftedTypeKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "b" Unique
    3)
        indexTy :: Type
    indexTy = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    indexTcNm [Type
    nTy]
        nTy :: Type
    nTy = TyVar -> Type
    VarTy TyVar
    nTV
        mTy :: Type
    mTy = TyVar -> Type
    VarTy TyVar
    mTV
        fTy :: Type
    fTy = Type -> Type -> Type
    mkFunTy Type
    indexTy (Type -> Type -> Type
    mkFunTy Type
    aTy Type
    bTy)
        aTy :: Type
    aTy = TyVar -> Type
    VarTy TyVar
    aTV
        bTy :: Type
    bTy = TyVar -> Type
    VarTy TyVar
    bTV
        vecATy :: Type
    vecATy = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    mTy,Type
    aTy]
        vecBTy :: Type
    vecBTy = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    vecTcNm [Type
    mTy,Type
    bTy]

    indexAddTy
      :: TyConName
      -- ^ Index TyCon name
      -> Type
    indexAddTy :: TyConName -> Type
    indexAddTy TyConName
    indexTcNm =
      TyVar -> Type -> Type
    ForAllTy TyVar
    nTV (
      Type -> Type -> Type
    mkFunTy Type
    naturalPrimTy (Type -> Type -> Type
    mkFunTy Type
    indexTy (Type -> Type -> Type
    mkFunTy Type
    indexTy Type
    indexTy)))
      where
        nTV :: TyVar
    nTV     = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "n" Unique
    0)
        indexTy :: Type
    indexTy = TyConName -> [Type] -> Type
    mkTyConApp TyConName
    indexTcNm [TyVar -> Type
    VarTy TyVar
    nTV]

    bvAppendPrim
      :: TyConName
      -- ^ BitVector TyCon Name
      -> Term
    bvAppendPrim :: TyConName -> Term
    bvAppendPrim TyConName
    bvTcNm =
      PrimInfo -> Term
    Prim (Text
    -> Type -> WorkInfo -> IsMultiPrim -> PrimUnfolding -> PrimInfo
    PrimInfo Text
    "Clash.Sized.Internal.BitVector.++#" (TyConName -> Type
    bvAppendTy TyConName
    bvTcNm) WorkInfo
    WorkNever IsMultiPrim
    SingleResult PrimUnfolding
    NoUnfolding)

    bvAppendTy
      :: TyConName
      -- ^ BitVector TyCon Name
      -> Type
    bvAppendTy :: TyConName -> Type
    bvAppendTy TyConName
    bvNm =
      TyVar -> Type -> Type
    ForAllTy TyVar
    mTV (
      TyVar -> Type -> Type
    ForAllTy TyVar
    nTV (
      Type -> Type -> Type
    mkFunTy Type
    naturalPrimTy (Type -> Type -> Type
    mkFunTy
        (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    bvNm [TyVar -> Type
    VarTy TyVar
    nTV])
        (Type -> Type -> Type
    mkFunTy
          (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    bvNm [TyVar -> Type
    VarTy TyVar
    mTV])
          (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    bvNm [TyConName -> [Type] -> Type
    mkTyConApp TyConName
    typeNatAdd
                              [TyVar -> Type
    VarTy TyVar
    nTV
                              ,TyVar -> Type
    VarTy TyVar
    mTV]])))))
      where
        mTV :: TyVar
    mTV = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "m" Unique
    0)
        nTV :: TyVar
    nTV = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "n" Unique
    1)

    bvSplitPrim
      :: TyConName
      -- ^ BitVector TyCon Name
      -> Term
    bvSplitPrim :: TyConName -> Term
    bvSplitPrim TyConName
    bvTcNm =
      PrimInfo -> Term
    Prim (Text
    -> Type -> WorkInfo -> IsMultiPrim -> PrimUnfolding -> PrimInfo
    PrimInfo Text
    "Clash.Sized.Internal.BitVector.split#" (TyConName -> Type
    bvSplitTy TyConName
    bvTcNm) WorkInfo
    WorkNever IsMultiPrim
    SingleResult PrimUnfolding
    NoUnfolding)

    bvSplitTy
      :: TyConName
      -- ^ BitVector TyCon Name
      -> Type
    bvSplitTy :: TyConName -> Type
    bvSplitTy TyConName
    bvNm =
      TyVar -> Type -> Type
    ForAllTy TyVar
    nTV (
      TyVar -> Type -> Type
    ForAllTy TyVar
    mTV (
      Type -> Type -> Type
    mkFunTy Type
    naturalPrimTy (Type -> Type -> Type
    mkFunTy
        (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    bvNm [TyConName -> [Type] -> Type
    mkTyConApp TyConName
    typeNatAdd
                                     [TyVar -> Type
    VarTy TyVar
    mTV
                                     ,TyVar -> Type
    VarTy TyVar
    nTV]])
        (TyConName -> [Type] -> Type
    mkTyConApp TyConName
    tupNm [TyConName -> [Type] -> Type
    mkTyConApp TyConName
    bvNm [TyVar -> Type
    VarTy TyVar
    mTV]
                          ,TyConName -> [Type] -> Type
    mkTyConApp TyConName
    bvNm [TyVar -> Type
    VarTy TyVar
    nTV]]))))
      where
        nTV :: TyVar
    nTV   = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "n" Unique
    0)
        mTV :: TyVar
    mTV   = Type -> TyName -> TyVar
    mkTyVar Type
    typeNatKind (Text -> Unique -> TyName
    forall a. Text -> Unique -> Name a
    mkUnsafeSystemName Text
    "m" Unique
    1)
        tupNm :: TyConName
    tupNm = TyCon -> TyConName
    ghcTyconToTyConName (Boxity -> Unique -> TyCon
    tupleTyCon Boxity
    Boxed Unique
    2)

    ghcTyconToTyConName
      :: TyCon.TyCon
      -> TyConName
    ghcTyconToTyConName :: TyCon -> TyConName
    ghcTyconToTyConName TyCon
    tc =
        NameSort -> Text -> Unique -> SrcSpan -> TyConName
    forall a. NameSort -> Text -> Unique -> SrcSpan -> Name a
    Name NameSort
    User Text
    n' (Unique -> Unique
    getKey (TyCon -> Unique
    TyCon.tyConUnique TyCon
    tc)) (Name -> SrcSpan
    forall a. NamedThing a => a -> SrcSpan
    getSrcSpan Name
    n)
      where
        n' :: Text
    n'      = Text -> Maybe Text -> Text
    forall a. a -> Maybe a -> a
    fromMaybe Text
    "_INTERNAL_" (Name -> Maybe Text
    modNameM Name
    n) Text -> Text -> Text
    `Text.append`
                  (Char
    '.' Char -> Text -> Text
    `Text.cons` [Char] -> Text
    Text.pack [Char]
    occName)
        occName :: [Char]
    occName = OccName -> [Char]
    occNameString (OccName -> [Char]) -> OccName -> [Char]
    forall a b. (a -> b) -> a -> b
    $ Name -> OccName
    nameOccName Name
    n
        n :: Name
    n       = TyCon -> Name
    TyCon.tyConName TyCon
    tc

    svoid :: (State# RealWorld -> State# RealWorld) -> IO ()
    svoid :: (State# RealWorld -> State# RealWorld) -> IO ()
    svoid State# RealWorld -> State# RealWorld
    m0 = (State# RealWorld -> (# State# RealWorld, () #)) -> IO ()
    forall a. (State# RealWorld -> (# State# RealWorld, a #)) -> IO a
    IO (\State# RealWorld
    s -> case State# RealWorld -> State# RealWorld
    m0 State# RealWorld
    s of State# RealWorld
    s' -> (# State# RealWorld
    s', () #))

    isTrueDC,isFalseDC :: DataCon -> Bool
    isTrueDC :: DataCon -> Bool
    isTrueDC DataCon
    dc  = DataCon -> Unique
    dcUniq DataCon
    dc Unique -> Unique -> Bool
    forall a. Eq a => a -> a -> Bool
    == Unique -> Unique
    getKey Unique
    trueDataConKey
    isFalseDC :: DataCon -> Bool
    isFalseDC DataCon
    dc = DataCon -> Unique
    dcUniq DataCon
    dc Unique -> Unique -> Bool
    forall a. Eq a => a -> a -> Bool
    == Unique -> Unique
    getKey Unique
    falseDataConKey