[Haskell-cafe] {-# SPECIALIZE foo @Bar #-} ?

Johannes Waldmann johannes.waldmann at htwk-leipzig.de
Mon Jul 8 09:50:33 UTC 2019


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.html#specialize-pragma

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.


More information about the Haskell-Cafe mailing list