[GHC] #12465: Evil idea: Allow empty record field update syntax for types.
GHC
ghc-devs at haskell.org
Fri Aug 5 21:09:05 UTC 2016
#12465: Evil idea: Allow empty record field update syntax for types.
-------------------------------------+-------------------------------------
Reporter: Iceland_jack | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
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: |
-------------------------------------+-------------------------------------
Description changed by Iceland_jack:
@@ -3,2 +3,2 @@
- I often work with constructors with many arguments, then I want to
- instantiate type variables with them:
+ I often work with constructors with many arguments that I want to
+ instantiate type variables with:
New description:
Use case: Visible type application.
I often work with constructors with many arguments that I want to
instantiate type variables with:
{{{#!hs
show @(Vector _ _)
:: Show a => Vector n a -> String
-- Type arguments reversed, see
https://github.com/ekmett/distributive/pull/18
cotraverse @_ @(Vector _)
:: (NATTY n, Functor f) => (f a -> b) -> (f (Vector n a) -> Vector n a')
fmap @(Bazaar _ _ _)
:: (t -> t') -> (Bazaar p a b t -> Bazaar p a b t')
show @(Magma _ _ _ _)
:: (Show a, Show i) => Magma i t b a -> String
}}}
This makes no sense since types have nothing to do with record or updates
thereof but that syntax is often used to avoid parentheses and unneeded
wildcard arguments:
{{{#!hs
isBar (Bar _ _ _ _ _) = True
-- ===>
isBar Bar{} = True
}}}
This also means you don't need to worry about the kind of your constructor
wrt the type (class) variable it instantiates.
----
Thus the proposal is to allow:
{{{#!hs
show @Vector{}
:: Show a => Vector n a -> String
cotraverse @_ @Vector{}
:: (NATTY n, Functor f) => (f a -> b) -> (f (Vector n a) -> Vector n a')
fmap @Bazaar{}
:: (t -> t') -> (Bazaar p a b t -> Bazaar p a b t')
show @Magma{}
:: (Show a, Show i) => Magma i t b a -> String
}}}
----
This would save quite a few keystrokes in my daily coding but more
importantly it saves cognitive load but I expect skepticism, especially
since GHC would have to determine whether to interpret `show @Vector{}` to
`show @Vector`, `show @(Vector _n)` or `show @(Vector _n _a)`.
--
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12465#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list