Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
damn
If you were writing a complete stack including
NonEmptyT
, the implementation could probably be made to not need an outerListGen
, right?I've been playing with it for several hours. It's a lovely piece of work! :]
Writing a custom monolithic
newtype
probably often ( I think ) allows optimisations that a stack doesn't. And looking atASCIIStringT NonEmptyList
, thatASCIIStringT
had bettermap
to ASCII instead offilter
to it, or it's not guaranteed to maintain the non-empty invariant. Interactions may do unexpected things ..If I'm extending QuickCheck, I'd go whole hog, write a
NonEmptyT
as well, and throw in an innermostIdentity
. If it's worth doing at all, it's worth taking it all the way toIdentity
, and possibly beyond.Go check out my other fork. I wasn't sure if I could keep everything as a
newtype
soDerivingVia
would still work, but I found a solution.Turns out you can keep everything as
newtype
s after all!You could extend QuickCheck by taking each list wrapper and
Unwrap
instanceUnwrap
andArbitrary
Then, you can add invariants to your heart's content!
I'm not sure how useful this would be in practice if your invariant isn't some combination of the pre-defined variants, as you wouldn't really be saving much effort compared to writing a non-transformer
newtype
with the appropriateArbitrary
instance.If you wanted
SortedList (NonEmptyList Int)
, this wouldn't work; you'd still have to define your ownSorted
likeDistinct
here.If
Sorted
andNonEmpty
were defined ( somewhat, not exactly ) likeDistinct
here, you could useSortedT (DistinctT (NonEmptyT (Identity Int))
. That's where I was going with "transformer-like"newtype
s ( which would then have to bedata
s, defeating the purpose ).How would
Sorted (Distinct (NonEmptyList Int))
look? What's here, and thennewtype Sorted
,instance Wraps (Distinct (NonEmptyList))
? It doesn't look very scalable, the boilerplate explodes. It's already quite a bit more than the originalforAll
. That has no shrinking, but that can be added withforAllShrink
and ashrink
that's no larger than it is here. All the rest basically expands onnub <$> listOf1 arbitrary
.What in tarnation is happening here?
Was about to comment the same thing!
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
For anyone wondering why you can use bool as 1 and 0 https://github.com/python/cpython/blob/main/Doc/c-api/bool.rst#id3
This comment is hidden because it contains spoiler information about the solution
way more faster than my two for loop dumb solution
genius
It's not a bug. In that case the runner's name is Second Runner.
Loading more items...