Copyright | (C) 2024 Google LLC |
---|---|
License | BSD2 (see the file LICENSE) |
Maintainer | QBayLogic B.V. <devops@qbaylogic.com> |
Safe Haskell | None |
Language | Haskell2010 |
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 #
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
VecToTuple (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
|
VecToTuple (Vec 3 a) Source # | |