Commit ee5dcdf9 authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot

testsuite: Add test for #18346

This was fixed by 4291bdda.
parent 9648d680
{-# LANGUAGE RankNTypes #-}
module MiniLens ((^.), Getting, Lens', lens, view) where
import Data.Functor.Const (Const(..))
type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t
type Lens' s a = Lens s s a a
lens :: (s -> a) -> (s -> b -> t) -> Lens s t a b
lens sa sbt afb s = sbt s <$> afb (sa s)
{-# INLINE lens #-}
type Getting r s a = (a -> Const r a) -> s -> Const r s
view :: Getting a s a -> s -> a
view l = getConst . l Const
{-# INLINE view #-}
(^.) :: s -> Getting a s a -> a
s ^. l = getConst (l Const s)
{-# INLINE (^.) #-}
{-# LANGUAGE RankNTypes #-}
module GHCBug (field) where
import MiniLens ((^.), Getting, Lens', lens, view)
t' :: Getting () () ()
t' = lens id const
{-# NOINLINE t' #-}
mlift :: Functor f => Getting b a b -> Lens' (f a) (f b)
mlift l = lens (fmap (^. l)) const
{-# INLINE mlift #-}
newtype Field = F (Maybe () -> Maybe ())
field :: Field
field = F (view (mlift t'))
test('T18346', [extra_files(['MiniLens.hs'])], multimod_compile, ['T18346.hs', '-v0'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment