Skip to content

Instantly share code, notes, and snippets.

@frasertweedale
Created April 22, 2017 00:08
Show Gist options
  • Save frasertweedale/7893c64355938d02b0b303382c258203 to your computer and use it in GitHub Desktop.
Save frasertweedale/7893c64355938d02b0b303382c258203 to your computer and use it in GitHub Desktop.
f :: Fold s a -> Fold (a -> Bool, s) a
{-# LANGUAGE RankNTypes #-}
import Data.Functor.Contravariant (phantom)
import Control.Lens
main = print $ toListOf (f folded) (even, [1,2,3,4])
f :: Fold s a -> Fold (a -> Bool, s) a
f l agb (f, s) = phantom $ traverseOf_ (l . filtered f) agb s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment