[GHC] #11385: Unify named wildcards in different type applications

GHC ghc-devs at haskell.org
Tue Jul 5 16:48:05 UTC 2016


#11385: Unify named wildcards in different type applications
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.1
  checker)                           |             Keywords:
      Resolution:                    |  NamedWildCards 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):

 I disliked the lack of binders in my idea. That would be fixed by

 Replying to [comment:2 goldfire]:
 > {{{
 > asTypeOf = \ @a -> const @a @a
 > }}}

 like comment:4:ticket:11350 and comment:1:ticket:11638. Let me see if I
 understand:

 {{{#!hs
 add4 :: (Enum a, Enum b) => a -> b -> Int
 add4 a b = (fromEnum a + fromEnum b) `mod` 4
 }}}

 if you want `add4 :: Enum a => a -> a -> Int` you write

 {{{#!hs
 -- add4 @_a @_a`

 \ @a -> add4 @a @a
   :: Enum a => a -> a -> Int
 }}}

 {{{#!hs
 -- Sub @(Ord _a) @(Eq _a)

 \ @a -> Sub @(Ord a) @(Eq a)
   :: (Ord a => Dict (Eq a)) -> Ord a :- Eq a
 }}}

 {{{#!hs
 -- map @_a @_a

 \ @a -> map @a @a
   :: (a -> a) -> [a] -> [a]
 }}}

 LGTM.

 ----

 It may be worth allowing

 {{{#!hs
 (\ @a -> map @a @a) @Int
   :: (Int -> Int) -> [Int] -> [Int]
 }}}

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


More information about the ghc-tickets mailing list