On 22 February 2014 03:11, Cédric Beust ♔ <ced...@beust.com> wrote:

> On Fri, Feb 21, 2014 at 5:47 PM, Ricky Clarkson 
> <ricky.clark...@gmail.com>wrote:
>
>> To me, List(1, "a") should be a type error as it is in Haskell ([1, "a"])
>>
>
> I sympathize with this view. I can't remember last time I needed a
> heterogeneous list and if I came upon such a need, I would probably try to
> capture some commonality of all the elements in a trait and parameterize my
> list on that.
>
>
Absolutely!  There's a strong movement in the Scala community to ban the
`Any`, `AnyRef` and `AnyVal` from ever being inferred for this exact reason.
I'd also like a means in the standard library to context bound the entire
list, and enforce that all members belong to some type class - even if
there's no common superclass involved.

As for HLists, they can fit in anywhere you'd use a Tuple, and give you
extra flexibility over the number of members (amongst other things).  So
you could imagine them being used as an argument list to a function, for
serialisation/deserialisation scenarios, as a representation of values in a
case class, etc.

Note that shapeless also has the Record type, which extends the same sort
of logic into a hetrogenous map.  It retains the exact type of all the
members just as an HList does, but additionally allows lookup using
singleton keys.



> But the discussion is still worth having even if it's a bit theoretical
> because there are still a lot of unsolved questions surrounding the
> interaction of variance and parametric polymorphism and I'd really like to
> go down that rabbit hole to find out if a solution is workable or if ad hoc
> polymorphism is the only reasonable way out.
>

You *definitely* want to be keeping an eye on Dotty then :)

-- 
You received this message because you are subscribed to the Google Groups "Java 
Posse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to javaposse+unsubscr...@googlegroups.com.
To post to this group, send email to javaposse@googlegroups.com.
Visit this group at http://groups.google.com/group/javaposse.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to