Skip to content

Commit

Permalink
Add COMPLETE pragma for Vec: Nil, :> (#2716)
Browse files Browse the repository at this point in the history
  • Loading branch information
axman6 authored Jun 30, 2024
1 parent 84990b3 commit b0f166b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 3 additions & 0 deletions clash-prelude/src/Clash/Sized/Vector.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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. <[email protected]>
-}
Expand Down Expand Up @@ -180,6 +181,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.
Expand Down

0 comments on commit b0f166b

Please sign in to comment.