[GHC] #11765: Allow documentary type signatures

#11765: Allow documentary type signatures -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: feature | Status: new request | Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.3 (Type checker) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- In some cases (e.g., `lens`) it's useful to document a binding with a more specific type signature than the true one, to show a useful special case. Unfortunately, this documentation can potentially be wrong or go out of date. I'd like to propose a pragma for this: {{{#!hs {-# Documentary #-} f :: T -> U }}} would ask the type checker to verify that `f :: T -> U`. Specifically, it would have the effect of creating and type checking, but then discarding, a hidden binding {{{#!hs f_doc :: T -> U f_doc t = f t }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11765 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11765: Allow documentary type signatures -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 7.10.3 checker) | Resolution: | Keywords: 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 simonpj): Not a bad idea; and easy to implement given syntax that everyone is happy with. In SPECIALISE pragmas the type is inside the pragma, and this is a variant of `SPECIALISE`. Indeed, maybe it ''is'' `SPECIALISE`, except that GHC might notice that there was nothing to be gained from specialising and so discard the code and rule. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11765#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

Not a bad idea; and easy to implement given syntax that everyone is happy with. In SPECIALISE pragmas the type is inside the pragma, and this is a variant of `SPECIALISE`.
Indeed, maybe it ''is'' `SPECIALISE`, except that GHC might notice that
#11765: Allow documentary type signatures -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 7.10.3 checker) | Resolution: | Keywords: 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 dfeuer): Replying to [comment:1 simonpj]: there was nothing to be gained from specialising and so discard the code and rule. It's certainly quite similar! It sometimes declines to generate code/rules (insufficient specialization, too complicated), and here we'd probably prefer to skip generation rather than generate and discard. But it seems likely that machinery could be shared. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11765#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11765: Allow documentary type signatures -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: Type: feature request | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 7.10.3 checker) | Resolution: | Keywords: 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): See #11439 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11765#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11765: Allow documentary type signatures -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 7.10.3 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.6.1 => Comment: It seems like this is something that would be best handled through the [[https://github.com/ghc-proposals/ghc-proposals|proposal process]]. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11765#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC