[Haskell-cafe] Class-like features for explicit arguments

Ertugrul Söylemez ertesx at gmx.de
Sat Apr 25 18:12:22 UTC 2015

> Likewise, to what extent aside from syntactic nicety does implicit
> parameters and the punning extensions not suffice?

At the definition and instantiation sites I mostly miss defaults.  At
the application sites I would love to have specialisation for certain
arguments.  For example I would like to be able to tell GHC that I would
like to have a version of my function `f` with a certain argument
inlined.  Note that I don't want to inline `f` itself.  Rather I'd like
to preapply certain arguments:

    f :: X -> Y -> Z

    {-# SPECIALISE f SomeX #-}
    {-# SPECIALISE f SomeOtherX #-}

This would generate two specialised versions of `f` with exactly the
given arguments inlined.  That way I can get a very efficient `f`
without having to inline it at the application sites.  And as long as
`f` is INLINABLE I can put those pragmas pretty much everywhere.  I
believe this is exactly what happens for type class dictionaries.

This can (and probably should) be a separate feature though.  For some
of my applications I need to inline a huge chunk of code multiple times
to compensate for the lack of this feature.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150425/e6177599/attachment.sig>

More information about the Haskell-Cafe mailing list