clash-shockwaves
Copyright(C) 2025-2026 QBayLogic B.V.
LicenseBSD2 (see the file LICENSE)
MaintainerQBayLogic B.V. <devops@qbaylogic.com>
Safe HaskellNone
LanguageHaskell2010

Clash.Shockwaves.Internal.Util

Description

Some small helper functions.

Synopsis

Documentation

carryFoldl :: (a -> b -> (a, c)) -> a -> [b] -> [c] Source #

A folding function like scan that has separate output and continue values. The dataflow looks like:

   [ b,    b',   b'' ]
     v     v     v
a > [f] > [f] > [f] > _
     v     v     v
   [ c,    c',   c'' ]

insertIfMissing :: Ord k => k -> v -> Map k v -> Map k v Source #

Insert value into dictionary if the key was not yet present.

writeFileJSON :: ToJSON a => FilePath -> a -> IO () Source #

Re-export of encodeFile for cleaner naming in tracing functions.

bitSize :: BitPack a => Int Source #

Returns the BitSize of a type as a runtime Int.

parenthesize :: Value -> Value Source #

Wrap parentheses around a value.

safeName :: Value -> Value Source #

Add parentheses around an identifier if it is an operator.

joinWith :: Value -> [Value] -> Value Source #

Join a list of values with a separator. If the list is empty, an empty value is returned.

defaultTypeName :: forall {k} (a :: k). Typeable a => TypeName Source #

Obtain the default name of a type. The name consists of a unique fingerprint (which is safe to use) and a human readable representation of the type (which may not be unique if multiple sources define the same types).

sym :: forall (s :: Symbol). KnownSymbol s => String Source #

Shorthand function for obtaining the runtime String of a type level Symbol.

safeNFErr :: NFData a => a -> Either (Maybe Value) a Source #

Check if a value is completely defined. If not, optionally return an error message.

safeNF :: NFData a => a -> Maybe a Source #

Check if a value is completely defined.

safeNFOr :: NFData a => a -> a -> a Source #

Check if a value is completely defined. If not, return the default value provided.

safeWHNF :: a -> Maybe a Source #

Evaluate to WHNF. If this fails, return a default value.

applySpacer :: NumberSpacer -> Value -> Value Source #

Insert spacers in a number value

enumLabel :: [(SubSignal, a)] -> [(SubSignal, a)] Source #

Replace subsignal labels with numbers

errorR :: Value -> Render Source #

Render some error message. The precedence is set to 11 (i.e. an atomic).

errorT :: Value -> Translation Source #

Create a translation from an error message using errorR.

addType :: String -> Translator -> TypeMap -> TypeMap Source #

Add a translator by name to the type map.

erroringZipWith :: String -> (a -> b -> c) -> [a] -> [b] -> [c] Source #

zipWith variant that errors on lists of different length

unsafeHead :: [a] -> a Source #

head but without complaints

pprintT :: Translator -> String Source #

Debug function for pretty printing Translators. The output of this function may change. It is merely intended as a debug tool when creating and modifying translators.