Skip to content

Allow view patterns inside record patterns

I think it would be nice if I could directly write a view pattern inside a record pattern. Currently the following program causes a parse error.

{-# LANGUAGE ViewPatterns #-}
newtype Foo = Foo{ fooA :: Int }

main = case Foo 4 of
    Foo{ fooA = show -> s } -> print s
    --Foo{ fooA = (show -> s) } -> print s -- This version is ok.
Trac metadata
Trac field Value
Version 7.4.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information