clash-prelude-1.8.1: Clash: a functional hardware description language - Prelude library
Copyright(C) 2024 Google LLC
LicenseBSD2 (see the file LICENSE)
MaintainerQBayLogic B.V. <devops@qbaylogic.com>
Safe HaskellNone
LanguageHaskell2010

Clash.Sized.Vector.ToTuple

Description

Tooling to safely work around incomplete-uni-patterns and incomplete-patterns warnings. See vecToTuple for more information and examples.

Note: This module has been added to make upgrading to GHC 9.2 easier. As of GHC 9.2, the incomplete-uni-patterns has been added to the -Wall, making previously warning-free code now produce warnings.

Documentation

class VecToTuple a where Source #

Associated Types

type TupType a = r | r -> a Source #

Methods

vecToTuple :: a -> TupType a Source #

Given a vector with three elements:

>>> myVec = (1 :> 2 :> 3 :> Nil) :: Vec 3 Int

The following would produce a warning even though we can be sure no other pattern can ever apply:

>>> (a :> b :> c :> Nil) = myVec

vecToTuple can be used to work around the warning:

>>> (a, b, c) = vecToTuple myVec

Of course, you will still get an error if you try to match a vector of the wrong length:

>>> (a, b, c, d) = vecToTuple myVec
...
    • Couldn't match type: (Int, Int, Int)
                            ^
                     with: (a, b, c, d)
...

Instances

Instances details
VecToTuple (Vec 0 a) Source # 
Instance details

Defined in Clash.Sized.Vector.ToTuple

Associated Types

type TupType (Vec 0 a) = (r :: Type) Source #

Methods

vecToTuple :: Vec 0 a -> TupType (Vec 0 a) Source #

VecToTuple (Vec 2 a) Source #

NB: The documentation only shows instances up to 3-tuples. By default, instances up to and including 12-tuples will exist. If the flag large-tuples is set instances up to the GHC imposed limit will exist. The GHC imposed limit is either 62 or 64 depending on the GHC version.

Instance details

Defined in Clash.Sized.Vector.ToTuple

Associated Types

type TupType (Vec 2 a) = (r :: Type) Source #

Methods

vecToTuple :: Vec 2 a -> TupType (Vec 2 a) Source #

VecToTuple (Vec 3 a) Source # 
Instance details

Defined in Clash.Sized.Vector.ToTuple

Associated Types

type TupType (Vec 3 a) = (r :: Type) Source #

Methods

vecToTuple :: Vec 3 a -> TupType (Vec 3 a) Source #