# How to create quickcheck tests for dependently typed matrix addition without specifying each dimension statically?

**URL:** <https://discourse.haskell.org/t/how-to-create-quickcheck-tests-for-dependently-typed-matrix-addition-without-specifying-each-dimension-statically/9993>\
**Category:** Learn\
**Created:** [July 21, 2024, 3:11am UTC](https://discourse.haskell.org/t/how-to-create-quickcheck-tests-for-dependently-typed-matrix-addition-without-specifying-each-dimension-statically/9993 "2024-07-21T03:11:40Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![tomjaguarpaw](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/tomjaguarpaw/32/1230_2.png) [@tomjaguarpaw](https://discourse.haskell.org/u/tomjaguarpaw)\
**Post date:** [July 21, 2024, 12:07pm UTC](https://discourse.haskell.org/t/how-to-create-quickcheck-tests-for-dependently-typed-matrix-addition-without-specifying-each-dimension-statically/9993/3 "2024-07-21T12:07:24Z")

</div>

I suggest to avoid “`Some`” wrappers and instead keep the size variables in scope.

```haskell
test2 = generate $ do
  SomeNat @x _ <- arbitraryKnownNat
  SomeNat @y _ <- arbitraryKnownNat
  SomeNat @z _ <- arbitraryKnownNat
  m1 <- exampleThree @x @y @L2 @Diff
  m2 <- exampleThree @y @z @L2 @Diff
  pure $ (mult m1 m2) == (mult m1 m2)

```

Fulll code at: [Generate matrices that can be added and multiplied · uvm-plaid/SensCheck@8312227 · GitHub](https://github.com/uvm-plaid/SensCheck/commit/8312227de7724d537c10568e60f2bd71c6402f8d)

> [@psilospore](#):
>
> My attempted solutions can be found here: [SensCheck/src/SensStaticHMatrix.hs at f89c98c40c3d7851a04cf5f44a9abf3d256261e2 · uvm-plaid/SensCheck · GitHub](https://github.com/uvm-plaid/SensCheck/blob/f89c98c40c3d7851a04cf5f44a9abf3d256261e2/src/SensStaticHMatrix.hs#L186)

By the way, I appreciate you providing full source code. It made it much easier for me to know what to suggest. However, I couldn’t get the project to build with `cabal` because `grenade`’s dependencies on Hacakge are severely outdated. I’ve reported that at [Adjust bounds by sorki · Pull Request #107 · HuwCampbell/grenade · GitHub](https://github.com/HuwCampbell/grenade/pull/107#issuecomment-2241588909)

---

_[View the full topic](https://discourse.haskell.org/t/how-to-create-quickcheck-tests-for-dependently-typed-matrix-addition-without-specifying-each-dimension-statically/9993)._
