HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleuuid-types-1.0.6Haskell2010

Data.UUID.Types.Internal.Builder

This module provides a system that can call a function that takes a sequence of some number of Word8 arguments.

The twist is that the Word8 arguments can be supplied directly from Word8s, or from other sources that may provide more than one Word8 apiece. Examples are Word16 and Word32 that supply two and four Word8s respectively. Other ByteSource instances can be defined.

This module is admittedly overkill. There are only three places in the uuid package that need to call buildFromBytes with 16 Word8 values, but each place uses Words of different lengths: version 1 uuids: 32-16-16-16-8-8-8-8-8-8 version 4 uuids: 24-24-32-24-24 version 5 uuids: 32-32-32-32 Originally, these three constructions were hand coded but the code was ungainly. Using this module makes the code very concise, and turns out to optimize to just as fast, or faster!

  • 4 types
  • 1 class
  • Packageuuid-types-1.0.6
  • Exports6
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceBuilder.hs
classclass ByteSource w where
#

Class of types that can add Word8s to a Builder. Instances for Word8, Word16, Word32 and Int provide 1, 2, 4 and 4 bytes, respectively, into a ByteSink

Methods

  • (/-/) :: ByteSink w g -> w -> ginfixl 6

    Apply the source's bytes to the sink

Instances6ByteSource
  • ByteSource Word16Defined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
  • ByteSource Word32Defined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
  • ByteSource Word64Defined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
  • ByteSource Word8Defined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
  • ByteSource IntDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
  • ByteSource ThreeByteDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal
familytype family ByteSink w g
#

Type of function that a given ByteSource needs. This function must take as many Word8 arguments as the ByteSource provides

Instances6ByteSink
  • type ByteSink Word16 g = Takes2Bytes gDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
  • type ByteSink Word32 g = Takes4Bytes gDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
  • type ByteSink Word64 g = Takes8Bytes gDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
  • type ByteSink Word8 g = Takes1Byte gDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
  • type ByteSink Int g = Takes4Bytes gDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal.Builder
  • type ByteSink ThreeByte g = Takes3Bytes gDefined in uuid-types-1.0.6 · Data.UUID.Types.Internal

    A ByteSource to extract only three bytes from an Int, since next on StdGet only returns 31 bits of randomness.

typetype Takes1Byte g = Word8 -> g
#