[Haskell-cafe] Re: What I wish someone had told me...

Daryoush Mehrtash dmehrtash at gmail.com
Wed Oct 15 14:56:39 EDT 2008


>
> The equivalent won't compile in Haskell, because the actual return
> type does matter, and *is determined by the calling code*.  Our
> fictional GetListOfData can't return a List or a Mylist depending on
> some conditional, in fact it can't explicitly return either one at
> all, because the actual type of the result, as determined by the
> caller, could be either one, or something else entirely (ignoring the
> IO bit for the time being).
>


I have had an  unresolved issue on my stack of Haskell vs Java that I wonder
if your observation explains.

If you notice  java generics has all sort of gotchas (e.g.
http://www.ibm.com/developerworks/java/library/j-jtp01255.html).  I somehow
don't see this discussion in Haskell.   I wonder if haskell's model of
letting the caller determine the result type has advantage in that you don't
have all the complexity you would have if you let the API determine their
types.

daryoush

On Wed, Oct 15, 2008 at 11:45 AM, Stefan Monnier
<monnier at iro.umontreal.ca>wrote:

> > The instance selection for an interface is done at run-time and this is
> > inherently necessary.  The instance (in a different sense) selection for
> > type classes is almost always resolvable statically.  In Haskell 98
>
> In both cases, the dispatch is inherently dynamic, and in both cases,
> most dispatches can be resolved at compile-time with sufficient effort.
> The actual percentage may be quite different, tho.
> Implementation techniques are also fairly different, and the resulting
> coding style is also very different, but the two concepts are
> fundamentally very close to each other.
>
>
>        Stefan
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081015/d891784d/attachment.htm


More information about the Haskell-Cafe mailing list