[Haskell-cafe] constraint inference

Dmitry Olshansky olshanskydr at gmail.com
Fri Jul 7 05:50:29 UTC 2017


Hello, cafe!

If we have many constraints then compiling is sometimes too slow.
Especially if there are some type calculations.
And I don't know how to divide this time among different source files
because all constraints are checked only when we call a function.

I tried to add constraint info into argument definition instead of the
function signature but this trick is not working (see below).

Is it (at least theoretically) possible to infer the constraint inside a
function from the type of function's argument?

------------------------------------
$ stack ghci
 ---- GHCi, version 8.0.2:
Prelude> import Data.Proxy
Prelude Data.Proxy> import GHC.TypeLits
Prelude Data.Proxy GHC.TypeLits> :set -XRankNTypes
Prelude Data.Proxy GHC.TypeLits> let { f :: (KnownSymbol n => Proxy n) ->
String; f = symbolVal }

<interactive>:4:54: error:
    • No instance for (KnownSymbol n) arising from a use of ‘symbolVal’
      Possible fix:
        add (KnownSymbol n) to the context of
          the type signature for:
            f :: (KnownSymbol n => Proxy n) -> String
    • In the expression: symbolVal
      In an equation for ‘f’: f = symbolVal
------------------------------------

Best regards,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20170707/a92f3c04/attachment.html>


More information about the Haskell-Cafe mailing list