| Copyright | (C) 2025-2026 QBayLogic B.V. |
|---|---|
| License | BSD2 (see the file LICENSE) |
| Maintainer | QBayLogic B.V. <devops@qbaylogic.com> |
| Safe Haskell | None |
| Language | Haskell2010 |
Clash.Shockwaves.Internal.Util
Description
Some small helper functions.
Synopsis
- carryFoldl :: (a -> b -> (a, c)) -> a -> [b] -> [c]
- insertIfMissing :: Ord k => k -> v -> Map k v -> Map k v
- writeFileJSON :: ToJSON a => FilePath -> a -> IO ()
- bitSize :: BitPack a => Int
- parenthesize :: Value -> Value
- safeName :: Value -> Value
- joinWith :: Value -> [Value] -> Value
- defaultTypeName :: forall {k} (a :: k). Typeable a => TypeName
- sym :: forall (s :: Symbol). KnownSymbol s => String
- safeNFErr :: NFData a => a -> Either (Maybe Value) a
- safeNF :: NFData a => a -> Maybe a
- safeNFOr :: NFData a => a -> a -> a
- safeWHNF :: a -> Maybe a
- applySpacer :: NumberSpacer -> Value -> Value
- enumLabel :: [(SubSignal, a)] -> [(SubSignal, a)]
- errorR :: Value -> Render
- errorT :: Value -> Translation
- addType :: String -> Translator -> TypeMap -> TypeMap
- erroringZipWith :: String -> (a -> b -> c) -> [a] -> [b] -> [c]
- unsafeHead :: [a] -> a
- pprintT :: Translator -> String
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.
parenthesize :: Value -> Value Source #
Wrap parentheses around a value.
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.
safeNFOr :: NFData a => a -> a -> a Source #
Check if a value is completely defined. If not, return the default value provided.
applySpacer :: NumberSpacer -> Value -> Value Source #
Insert spacers in a number value
errorR :: Value -> Render Source #
Render some error message. The precedence is set to 11 (i.e. an atomic).
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.