clash-prelude-1.8.4: Clash: a functional hardware description language - Prelude library

Copyright | (C) 2024 Google LLC
License | BSD2 (see the file LICENSE)
Maintainer | QBayLogic B.V. <devops@qbaylogic.com>
Safe Haskell | None
Language | Haskell2010

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 :: Type) | 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
    ...

#### Instances

Instances details

VecToTuple (Vec 0 a) Source # |

Instance details

Defined in Clash.Sized.Vector.ToTuple

Associated Types

type TupType (Vec 0 a) |
Instance details Defined in Clash.Sized.Vector.ToTuple type TupType (Vec 0 a) = Tagged a ()

Methods

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

VecToTuple (Vec 1 a) Source # | Instead of using `vecToTuple` for `Vec 1 _`, you could also consider using `head`

Instance details

Defined in Clash.Sized.Vector.ToTuple

Associated Types

type TupType (Vec 1 a) |
Instance details Defined in Clash.Sized.Vector.ToTuple type TupType (Vec 1 a) = Solo a

Methods

vecToTuple :: Vec 1 a -> TupType (Vec 1 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) |
Instance details Defined in Clash.Sized.Vector.ToTuple type TupType (Vec 2 a) = (a, a)

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) |
Instance details Defined in Clash.Sized.Vector.ToTuple type TupType (Vec 3 a) = (a, a, a)

Methods

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

VecToTuple (Vec 4 a) Source # |

Instance details

Defined in Clash.Sized.Vector.ToTuple

Associated Types

type TupType (Vec 4 a) |
Instance details Defined in Clash.Sized.Vector.ToTuple type TupType (Vec 4 a) = (a, a, a, a)

Methods

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

VecToTuple (Vec 5 a) Source # |

Instance details

Defined in Clash.Sized.Vector.ToTuple

Associated Types

type TupType (Vec 5 a) |
Instance details Defined in Clash.Sized.Vector.ToTuple type TupType (Vec 5 a) = (a, a, a, a, a)

Methods

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

VecToTuple (Vec 6 a) Source # |

Instance details

Defined in Clash.Sized.Vector.ToTuple

Associated Types

type TupType (Vec 6 a) |
Instance details Defined in Clash.Sized.Vector.ToTuple type TupType (Vec 6 a) = (a, a, a, a, a, a)

Methods

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

VecToTuple (Vec 7 a) Source # |

Instance details

Defined in Clash.Sized.Vector.ToTuple

Associated Types

type TupType (Vec 7 a) |
Instance details Defined in Clash.Sized.Vector.ToTuple type TupType (Vec 7 a) = (a, a, a, a, a, a, a)

Methods

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

VecToTuple (Vec 8 a) Source # |

Instance details

Defined in Clash.Sized.Vector.ToTuple

Associated Types

type TupType (Vec 8 a) |
Instance details Defined in Clash.Sized.Vector.ToTuple type TupType (Vec 8 a) = (a, a, a, a, a, a, a, a)

Methods

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

VecToTuple (Vec 9 a) Source # |

Instance details

Defined in Clash.Sized.Vector.ToTuple

Associated Types

type TupType (Vec 9 a) |
Instance details Defined in Clash.Sized.Vector.ToTuple type TupType (Vec 9 a) = (a, a, a, a, a, a, a, a, a)

Methods

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

VecToTuple (Vec 10 a) Source # |

Instance details

Defined in Clash.Sized.Vector.ToTuple

Associated Types

type TupType (Vec 10 a) |
Instance details Defined in Clash.Sized.Vector.ToTuple type TupType (Vec 10 a) = (a, a, a, a, a, a, a, a, a, a)

Methods

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

VecToTuple (Vec 11 a) Source # |

Instance details

Defined in Clash.Sized.Vector.ToTuple

Associated Types

type TupType (Vec 11 a) |
Instance details Defined in Clash.Sized.Vector.ToTuple type TupType (Vec 11 a) = (a, a, a, a, a, a, a, a, a, a, a)

Methods

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

VecToTuple (Vec 12 a) Source # |

Instance details

Defined in Clash.Sized.Vector.ToTuple

Associated Types

type TupType (Vec 12 a) |
Instance details Defined in Clash.Sized.Vector.ToTuple type TupType (Vec 12 a) = (a, a, a, a, a, a, a, a, a, a, a, a)

Methods

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