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.Style

Description

Everything needed to add different styles to the waveform viewer.

Waveforms can be styled in a number of ways. Various standard styles are provided in WaveStyle. It is also possible to use custom colors using WSColor. These values can be provided in 3 typical ways:

  • Directly from an RGB Word8 value, using the WSColor constructor: WSColor (RGB 128 128 0).
  • From a Colour Double value, using the function wsColor. Many such values are provided in Clash.Shockwaves.Style.Colors.
  • Using a string literal: if OverloadedStrings is enabled, the WaveStyle value can be represented using a color name or hex color string literal. See readColourName.

Finally, there are a few special styles.

  • WSError is propagated throughout the signal hierarchy.
  • WSDefault is the only style to be replaced by the TStyled translator, and gets turned into WSNormal.
  • 'WSInherit n' inherits the style of the _n_'th subsignal.
  • WSVar makes it possible to define style variables in config files - this can also be created by using a string literal starting with $, which uses WSDefault as the fallback value.
  • WSHidden makes the signal appear as if it has not been assigned a value at all. This still allows the hidden text to be used in the construction of the value of a supersignal.

Some examples:

import Shockwaves.Style
import Shockwaves.Style.Colors as C

data Col = Red | Green | Blue | Yellow | Cyan | Magenta deriving ...

instance Waveform Col where
  constructorStyles = [ WSColor (RGB 255 0 0) -- RGB value
                      , wsColor C.lime        -- Colour value
                      , "blue"                -- color name
                      , "#ffff00"             -- hexadecimal color
                      , "$cyan"               -- style variable "cyan"; defaults to WSDefault
                      , WSVar "magenta"       -- style variable "magenta", defaults to #ff00ff
                      ]

and in a translation:

Translation (Just ("(p,q)",Inherit 1,11))           -- appears as blue
  [ ("a",Translation (Just ("p",WSHidden,11)) [])   -- no value is shown
  , ("b",Translation (Just ("q","blue"  ,11)) []) ] -- appears as blue

Translation (Just ("(p,q)","blue",11))               -- appears as WSError
  [ ("a",Translation (Just ("p",WSDefault,11)) [])   -- appears as WSNormal
  , ("b",Translation (Just ("q",WSError  ,11)) []) ] -- appears as WSError
Synopsis

Documentation

data WaveStyle Source #

The style in which a signal should be displayed.

Constructors

WSDefault

The default waveform style. It is rendered as WSNormal. This is the only style overwritten by TStyled.

WSError

An error value. Errors are propagated by translators.

WSHidden

Do not display any value, even if it exists.

WSInherit Natural

Copy the style of the nth subsignal.

WSNormal

A normal value.

WSWarn

A warning value.

WSUndef

An undefined value.

WSHighImp

A high impedance value.

WSDontCare

A value that does not matter.

WSWeak

A weakly defined value.

WSColor Color

A custom color. See Clash.Shockwaves.Style for more information.

WSVar String WaveStyle

A variable in a style configuration file, with a default.

Instances

Instances details
ToJSON WaveStyle Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

NFData WaveStyle Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

Methods

rnf :: WaveStyle -> () #

IsString WaveStyle Source #

A WaveStyle may be constructed from a value in various ways. Values starting with $ are treated as WSVar with WSDefault as fallback value. Hexadecimals and color names are used to create WSColor (see readColourName).

Instance details

Defined in Clash.Shockwaves.Internal.Types

Generic WaveStyle Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

Associated Types

type Rep WaveStyle 
Instance details

Defined in Clash.Shockwaves.Internal.Types

type Rep WaveStyle = D1 ('MetaData "WaveStyle" "Clash.Shockwaves.Internal.Types" "clash-shockwaves-1.1.0-inplace" 'False) (((C1 ('MetaCons "WSDefault" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "WSError" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WSHidden" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "WSInherit" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Natural)) :+: (C1 ('MetaCons "WSNormal" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WSWarn" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "WSUndef" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "WSHighImp" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WSDontCare" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "WSWeak" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "WSColor" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)) :+: C1 ('MetaCons "WSVar" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 WaveStyle))))))
Show WaveStyle Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

Eq WaveStyle Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

type Rep WaveStyle Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Types

type Rep WaveStyle = D1 ('MetaData "WaveStyle" "Clash.Shockwaves.Internal.Types" "clash-shockwaves-1.1.0-inplace" 'False) (((C1 ('MetaCons "WSDefault" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "WSError" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WSHidden" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "WSInherit" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Natural)) :+: (C1 ('MetaCons "WSNormal" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WSWarn" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "WSUndef" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "WSHighImp" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WSDontCare" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "WSWeak" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "WSColor" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Color)) :+: C1 ('MetaCons "WSVar" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 WaveStyle))))))

type Color = RGB Word8 Source #

The color type used in WaveStyle.

data RGB a #

An RGB triple for an unspecified colour space.

Constructors

RGB 

Fields

Instances

Instances details
Applicative RGB 
Instance details

Defined in Data.Colour.RGB

Methods

pure :: a -> RGB a #

(<*>) :: RGB (a -> b) -> RGB a -> RGB b #

liftA2 :: (a -> b -> c) -> RGB a -> RGB b -> RGB c #

(*>) :: RGB a -> RGB b -> RGB b #

(<*) :: RGB a -> RGB b -> RGB a #

Functor RGB 
Instance details

Defined in Data.Colour.RGB

Methods

fmap :: (a -> b) -> RGB a -> RGB b #

(<$) :: a -> RGB b -> RGB a #

Read a => Read (RGB a) 
Instance details

Defined in Data.Colour.RGB

Show a => Show (RGB a) 
Instance details

Defined in Data.Colour.RGB

Methods

showsPrec :: Int -> RGB a -> ShowS #

show :: RGB a -> String #

showList :: [RGB a] -> ShowS #

Eq a => Eq (RGB a) 
Instance details

Defined in Data.Colour.RGB

Methods

(==) :: RGB a -> RGB a -> Bool #

(/=) :: RGB a -> RGB a -> Bool #

wsColor :: Colour Double -> WaveStyle Source #

Create a colored WaveStyle from a color value defined in Doubles. This is the type of the predefined default colors in Data.Colour.

data Word8 #

8-bit unsigned integer type

Instances

Instances details
Structured Word8 
Instance details

Defined in Distribution.Utils.Structured

ToJSON Word8 
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Word8 
Instance details

Defined in Data.Aeson.Types.ToJSON

PrintfArg Word8

Since: base-2.1

Instance details

Defined in Text.Printf

Binary Word8 
Instance details

Defined in Data.Binary.Class

Methods

put :: Word8 -> Put #

get :: Get Word8 #

putList :: [Word8] -> Put #

AutoReg Word8 
Instance details

Defined in Clash.Class.AutoReg.Internal

Methods

autoReg :: forall (dom :: Domain). (HasCallStack, KnownDomain dom) => Clock dom -> Reset dom -> Enable dom -> Word8 -> Signal dom Word8 -> Signal dom Word8 #

BitPack Word8 
Instance details

Defined in Clash.Class.BitPack.Internal

Associated Types

type BitSize Word8 
Instance details

Defined in Clash.Class.BitPack.Internal

type BitSize Word8 = 8
Counter Word8

Since: clash-prelude-1.8.2

Instance details

Defined in Clash.Class.Counter.Internal

Parity Word8 
Instance details

Defined in Clash.Class.Parity

Methods

even :: Word8 -> Bool #

odd :: Word8 -> Bool #

NFDataX Word8 
Instance details

Defined in Clash.XException

ShowX Word8 
Instance details

Defined in Clash.XException

Waveform Word8 Source # 
Instance details

Defined in Clash.Shockwaves.Internal.Waveform

Default Word8 
Instance details

Defined in Data.Default.Internal

Methods

def :: Word8 #

NFData Word8 
Instance details

Defined in Control.DeepSeq

Methods

rnf :: Word8 -> () #

Bits Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

FiniteBits Word8

Since: base-4.6.0.0

Instance details

Defined in GHC.Internal.Word

Bounded Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Enum Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Ix Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Num Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Integral Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Real Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

toRational :: Word8 -> Rational #

Show Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

showsPrec :: Int -> Word8 -> ShowS #

show :: Word8 -> String #

showList :: [Word8] -> ShowS #

Eq Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

(==) :: Word8 -> Word8 -> Bool #

(/=) :: Word8 -> Word8 -> Bool #

Ord Word8

Since: base-2.1

Instance details

Defined in GHC.Internal.Word

Methods

compare :: Word8 -> Word8 -> Ordering #

(<) :: Word8 -> Word8 -> Bool #

(<=) :: Word8 -> Word8 -> Bool #

(>) :: Word8 -> Word8 -> Bool #

(>=) :: Word8 -> Word8 -> Bool #

max :: Word8 -> Word8 -> Word8 #

min :: Word8 -> Word8 -> Word8 #

Hashable Word8 
Instance details

Defined in Data.Hashable.Class

Methods

hashWithSalt :: Int -> Word8 -> Int #

hash :: Word8 -> Int #

Uniform Word8 
Instance details

Defined in System.Random.Internal

Methods

uniformM :: StatefulGen g m => g -> m Word8 #

UniformRange Word8 
Instance details

Defined in System.Random.Internal

Methods

uniformRM :: StatefulGen g m => (Word8, Word8) -> g -> m Word8 #

isInRange :: (Word8, Word8) -> Word8 -> Bool #

ByteSource Word8 
Instance details

Defined in Data.UUID.Types.Internal.Builder

Methods

(/-/) :: ByteSink Word8 g -> Word8 -> g

Unbox Word8 
Instance details

Defined in Data.Vector.Unboxed.Base

Lift Word8 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

lift :: Quote m => Word8 -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => Word8 -> Code m Word8 #

Vector Vector Word8 
Instance details

Defined in Data.Vector.Unboxed.Base

MVector MVector Word8 
Instance details

Defined in Data.Vector.Unboxed.Base

NumConvertCanonical Word8 (Unsigned 8) 
Instance details

Defined in Clash.Class.NumConvert.Internal.NumConvert

NumConvertCanonical (Unsigned 8) Word8 
Instance details

Defined in Clash.Class.NumConvert.Internal.NumConvert

type BitSize Word8 
Instance details

Defined in Clash.Class.BitPack.Internal

type BitSize Word8 = 8
type Canonical Word8 
Instance details

Defined in Clash.Class.NumConvert.Internal.Canonical

newtype Vector Word8 
Instance details

Defined in Data.Vector.Unboxed.Base

type ByteSink Word8 g 
Instance details

Defined in Data.UUID.Types.Internal.Builder

type ByteSink Word8 g = Takes1Byte g
newtype MVector s Word8 
Instance details

Defined in Data.Vector.Unboxed.Base