[GHC] #10794: Extension request: "where" clauses in type signatures

GHC ghc-devs at haskell.org
Tue Aug 25 20:29:16 UTC 2015


#10794: Extension request: "where" clauses in type signatures
-------------------------------------+-------------------------------------
              Reporter:  danso       |             Owner:
                  Type:  feature     |            Status:  new
  request                            |
              Priority:  lowest      |         Milestone:
             Component:  Compiler    |           Version:  7.10.2
  (Type checker)                     |
              Keywords:              |  Operating System:  Unknown/Multiple
          Architecture:              |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
             Test Case:              |        Blocked By:
              Blocking:              |   Related Tickets:
Differential Revisions:              |
-------------------------------------+-------------------------------------
 Some type signatures could be simplified by separating certain elements,
 either because they are lengthy and can be expressed simpler, to better
 express intention, or because they  are repetitive. A "WhereSignatures"
 extension would allow for type signatures like the following:

 {{{#!hs
 fold :: f -> [a] -> a
         where f :: a -> a -> a

 -- expresses intention more clearly than:
 fold :: (a -> a -> a) -> [a] -> a

 union :: a -> a -> a
          where a :: Map.Map k v

 -- much shorter/more readable than:
 union :: Map.Map k v -> Map.Map k v -> Map.Map k v
 }}}

 Or maybe even:

 {{{#!hs
 fmap :: (a -> b) -> f a -> f b
         where (Functor f)

 -- arguably prettier than:
 fmap :: (Functor f) => (a -> b) -> f a -> f b
 }}}

 This minor syntactic sugar is essentially equivalent to local "type"
 definitions, which provides an advantage of making the type's purpose more
 clear. This seems like a natural development on what the type checker can
 do.

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


More information about the ghc-tickets mailing list