From d7f9a9e729c3e7cd71705c1114cbbe4782173410 Mon Sep 17 00:00:00 2001 From: Alex Mason Date: Tue, 7 May 2024 22:47:56 +1000 Subject: [PATCH 1/3] Add COMPLETE pragma for Vec: Nil, (:>) I was banging my head against some type errors for hours until I decided to use the `Cons` constructor instead of the `:>` pattern - hopefully this will save someone else the same pain. --- clash-prelude/src/Clash/Sized/Vector.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clash-prelude/src/Clash/Sized/Vector.hs b/clash-prelude/src/Clash/Sized/Vector.hs index 0b818e5648..93ac9cad30 100644 --- a/clash-prelude/src/Clash/Sized/Vector.hs +++ b/clash-prelude/src/Clash/Sized/Vector.hs @@ -180,6 +180,8 @@ data Vec :: Nat -> Type -> Type where Nil :: Vec 0 a Cons :: a -> Vec n a -> Vec (n + 1) a +{-# COMPLETE Nil, (:>) #-} + -- | In many cases, this Generic instance only allows generic -- functions/instances over vectors of at least size 1, due to the -- /n-1/ in the /Rep (Vec n a)/ definition. From e601eb425da042d34326e8db92f90972b926c5fb Mon Sep 17 00:00:00 2001 From: Alex Mason Date: Tue, 7 May 2024 22:50:00 +1000 Subject: [PATCH 2/3] Add copyright notice to Vector.hs --- clash-prelude/src/Clash/Sized/Vector.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/clash-prelude/src/Clash/Sized/Vector.hs b/clash-prelude/src/Clash/Sized/Vector.hs index 93ac9cad30..3db9be62fc 100644 --- a/clash-prelude/src/Clash/Sized/Vector.hs +++ b/clash-prelude/src/Clash/Sized/Vector.hs @@ -2,6 +2,7 @@ Copyright : (C) 2013-2016, University of Twente, 2017 , Myrtle Software Ltd 2022-2023, QBayLogic B.V. + 2024, Alex Mason License : BSD2 (see the file LICENSE) Maintainer : QBayLogic B.V. -} From 3f4f65ab7af5a84aea9d09b73823ca1679aabf33 Mon Sep 17 00:00:00 2001 From: Alex Mason Date: Tue, 7 May 2024 22:58:22 +1000 Subject: [PATCH 3/3] Add changelog entry --- changelog/2024-05-07T22_51_59+10_00_add_vec_complete_pragma | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/2024-05-07T22_51_59+10_00_add_vec_complete_pragma diff --git a/changelog/2024-05-07T22_51_59+10_00_add_vec_complete_pragma b/changelog/2024-05-07T22_51_59+10_00_add_vec_complete_pragma new file mode 100644 index 0000000000..faba694a49 --- /dev/null +++ b/changelog/2024-05-07T22_51_59+10_00_add_vec_complete_pragma @@ -0,0 +1 @@ +ADDED: The Vec type now has a [COMPLETE pragma](https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/pragmas.html#complete-pragma) to avoid incomplete pattern matches when using the `(:>)` pattern.