Skip to content

Instantly share code, notes, and snippets.

@noinia
noinia / quickcheck.hs
Last active February 16, 2020 15:04
QuickCheck Weirdness?
import qualified Data.Set as Set
import Test.QuickCheck
import Debug.Trace
setOf :: (Ord a, Show a) => Int -> Gen a -> Gen (Set.Set a)
setOf n g = buildSet mempty <$> infiniteListOf g
where
buildSet s xs | traceShow (take 10 xs) False = undefined
buildSet s (x:xs) | length s == n = s
@noinia
noinia / foldr.hs
Created May 8, 2020 18:26
foldr1 with basecase function?
foldr1With :: Foldable1 f => (a -> b -> b) -> (a -> b) -> f a -> b
foldr1With f b = go . toNonEmpty
where
go (x :| xs) = case NonEmpty.nonEmpty xs of
Nothing -> b x
Just xs' -> x `f` (go xs')
@noinia
noinia / dummy.hs
Created September 17, 2020 11:20
static compilation ghc
module Main where
main = print "woei"