[GHC] #12363: Type application for infix

GHC ghc-devs at haskell.org
Thu Aug 18 13:20:29 UTC 2016


#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):

 {{{#!hs
 a `asTypeIn` f = a where _ = f a
 }}}

 Checking the type of fails due to ambiguous `Functor`, `Applicative`
 constraints

 {{{#!hs
 flip id `asTypeIn` \x -> x <$> undefined <*> undefined <*> undefined
 }}}

 The user must either possess some prior knowledge and rewrite the
 expression

 {{{#!hs
 -- fixity of <$>, <*>
 flip id `asTypeIn` \x -> (<$>) @[] x undefined <*> undefined <*> undefined
   :: a -> (a -> b -> c) -> b -> c

 -- liftA3 f a b c = f <$> a <*> b <*> c
 flip id `asTypeIn` \x -> liftA3 @[] x undefined undefined undefined
   :: a -> (a -> b -> c) -> b -> c

 -- the return type of `_ <$> _ <*> _ <*> _` is some Applicative `f _`
 flip id `asTypeIn` \x -> (x <$> undefined <*> undefined <*> undefined ::
 [_])
   :: a -> (a -> b -> c) -> b -> c
 }}}

 With infix type application they can directly write

 {{{#!hs
 flip id `asTypeIn` \x -> x <$> @[] undefined <*> undefined <*> undefined

 flip id `asTypeIn` \x -> x <$> @[] undefined <*> @[] undefined <*> @[]
 undefined
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12363#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list