Skip to content

Instantly share code, notes, and snippets.

@yurrriq
Last active November 24, 2025 05:22
Show Gist options
  • Select an option

  • Save yurrriq/cb4f870d42057a10201a5c92b1c6a3fc to your computer and use it in GitHub Desktop.

Select an option

Save yurrriq/cb4f870d42057a10201a5c92b1c6a3fc to your computer and use it in GitHub Desktop.
AllEq.hs
same :: (Functor f, Foldable f, Eq a) => Lens' s a -> f s -> Bool
same l xs = allEq (view l <$> xs)
allEq :: (Foldable t, Eq a) => t a -> Bool
allEq xs =
maybe True (\x -> getAll (foldMap (All . (== x)) xs))
$ getFirst (foldMap (First . Just) xs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment