
#12363: Type application for infix -------------------------------------+------------------------------------- Reporter: Iceland_jack | Owner: Type: feature request | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 8.0.1 (Parser) | Keywords: Resolution: | TypeApplications Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): Fits well with `catch`, `catchIO`, `catchSTM` idiom {{{#!hs -- do print (a ! 5) `catch` \e -> print (e :: SomeException) -- print (b ! (0,5)) `catch` \e -> print (e :: SomeException) do print (a ! 5) `catch` @SomeException print print (b ! (0,5)) `catch` @SomeException print }}} In that case you could write `print @SomeException` but that will not work if the handler doesn't mention the exception at all {{{#!hs -- rmDir :: FilePath -> IO () -- rmDir dir = removeDirectoryRecursive dir `catch` (const $ return () :: IOException -> IO ()) rmDir :: FilePath -> IO () rmDir dir = removeDirectoryRecursive dir `catch` @IOException const (return ()) }}} (granted `const @_ @IOException` works here, but having a singular place for the type application is nice) and from [http://hsyl20.fr/home/posts/2016-12-12-control-flow-in-haskell- part-3.html Control Flow in Haskell (3) - Flow with Variant] {{{#!hs -- test = f 5 >%~=> (\(a :: A) -> putStrLn "An A has been returned") -- >%~=> (\(b :: B) -> putStrLn "A B has been returned") -- >%~=> (\(c :: C) -> putStrLn "A C has been returned") test = f 5 >%~=> @A \_ -> putStrLn "An A has been returned" >%~=> @B \_ -> putStrLn "A B has been returned" >%~=> @C \_ -> putStrLn "A C has been returned" }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12363#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler