How to fix DatatypeContexts?
Daniel Wagner
wagnerdm at seas.upenn.edu
Thu Jul 18 19:47:21 CEST 2013
On 2013-07-18 10:46, harry wrote:
> Why not let all types carry the dictionary automatically, or at least
> every
> time that it's used, if that would incur a memory/performance penalty?
> GHC
> tells me which context to add when it's missing, so it clearly knows.
I'm not sure the claim in your second sentence is true. For example,
foo :: a -> a -> Bool
foo = (==)
bar :: a -> a -> Bool
bar = foo
GHC (rightly) complains about foo, but makes no complaint about bar.
That is, if a thing only works in the presence of a constraint, you need
to have that constraint visible in the type, every time, or else
downstream dependencies can reasonably make wrong assumptions.
~d
More information about the Glasgow-haskell-users
mailing list