Let’s say I have the following type: import Test.QuickCheck import GHC.TypeLits import Data.Kind data Vect :: Nat -> Type -> Type where VNil :: Vect 0 a VCons :: a -> Vect n a -> Vect (n + 1) a I want to be able to write some QuickChecks about my values, so I want to write an Arbitrary instance. sizedVect :: Int -> Gen a -> Gen (Vect n a) sizedVect 0 _ = pure VNil sizedVect n g = VCons <$> g <*> sizedVect (n - 1) g instance Arbitrary (Vect n a) where arbitrary :: Gen (Vect n a) arbi...| Haskell Community
Welcome back to our journey through the singleton design pattern and the great singletons library! This post is a direct continuation of Part 1, so be sure to check that out first if you haven’t already! If you hare just jumping in now, I suggest taking some time to to through the exercises if you haven’t already! Again, code is built on GHC 8.6.1 with the nightly-2018-09-29 snapshot (so, singletons-2.5). However, unless noted, all of the code should still work with GHC 8.4 and singletons...| in Code
A place for all discussions related to Haskell| Haskell Community
A place for all discussions related to Haskell| Haskell Community