ghc-lib-parser-9.14.1.20251220: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Data.Unboxed

Synopsis

- data MaybeUB a :: TYPE ('SumRep '[ZeroBitRep, LiftedRep]) where
  - pattern JustUB :: a -> MaybeUB a
  - pattern NothingUB :: MaybeUB a
- fmapMaybeUB :: (a -> b) -> MaybeUB a -> MaybeUB b
- fromMaybeUB :: a -> MaybeUB a -> a
- apMaybeUB :: MaybeUB (a -> b) -> MaybeUB a -> MaybeUB b
- maybeUB :: b -> (a -> b) -> MaybeUB a -> b

# Documentation

data MaybeUB a :: TYPE ('SumRep '[ZeroBitRep, LiftedRep]) where #

Like Maybe, but using unboxed sums.

Use with care. Using a unboxed maybe is not always a win in execution *time* even when allocations go down. So make sure to benchmark for execution time as well. If the difference in *runtime* for the compiler is too small to measure it's likely better to use a regular Maybe instead.

This is since it causes more function arguments to be passed, and potentially more variables to be captured by closures increasing closure size.

Bundled Patterns

pattern JustUB :: a -> MaybeUB a |
pattern NothingUB :: MaybeUB a |

fmapMaybeUB :: (a -> b) -> MaybeUB a -> MaybeUB b #

fromMaybeUB :: a -> MaybeUB a -> a #

apMaybeUB :: MaybeUB (a -> b) -> MaybeUB a -> MaybeUB b #

maybeUB :: b -> (a -> b) -> MaybeUB a -> b #