{-# SPECIALIZE foo @Bar #-} ?

Dear Cafe, with pragma SPECIALIZE, I find it tedious to repeat the type declaration. (It's a burden for maintenance and readability.) Could we use type-application syntax instead? E.g., the example from here https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts... hammeredLookup :: Ord key => [(key, value)] -> key -> value {-# SPECIALIZE hammeredLookup :: [(Widget, value)] -> Widget -> value #-} would become hammeredLookup :: forall key value . Ord key => [(key, value)] -> key -> value {-# SPECIALIZE hammeredLookup @Widget #-} or {-# SPECIALIZE hammeredLookup @Widget @value #-} Cf. SPECIALIZE instance, where we already write the instantiation for the type variable(s). - J.W.

On 08/07/2019 10:50, Johannes Waldmann wrote:
with pragma SPECIALIZE, I find it tedious to repeat the type declaration. (It's a burden for maintenance and readability.)
Could we use type-application syntax instead?
There's an inactive GHC proposal for this: https://github.com/ghc-proposals/ghc-proposals/pull/15 Also a bit of discussion on this StackOverflow question: https://stackoverflow.com/questions/39379531/how-do-i-specialise-with-an-exp... Cheers, Ganesh
participants (2)
-
Ganesh Sittampalam
-
Johannes Waldmann