whither newtype?

anything newlyoflate succinctly like haskell-newtype? thanks.

Re: whither newtype?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/19/2012 05:35 AM, Raoul Duke wrote:
> anything newlyoflate succinctly like haskell-newtype? thanks.

What does newtype on its own provide? Not much, but a compiler
optimisation removing a pointer indirection.

However, newtype along with deriving (keyword) is a powerful beast --
one that scala could certainly benefit from. This would be a significant
language change, but it would also solve a lot of problems that pass
here on the mailing list.

Maybe you mean newtype with deriving?

Re: whither newtype?

On Wed, Jan 18, 2012 at 12:51 PM, Tony Morris wrote:
> Maybe you mean newtype with deriving?

indeed maybe.

what i want is to be able to take something that already exists e.g.
Int (or is it Integer, i can never remember) and makes a new type e.g.
Inches that is basically an Int but they are not assignable w/out
explicit casts. a typedef but that is more strictly partitioning the
new type than typedef is in c.

Re: whither newtype?



On 19 January 2012 06:35, Raoul Duke <raould [at] gmail [dot] com> wrote:
anything newlyoflate succinctly like haskell-newtype? thanks.

I think the usual idiom is to just do something like case class Name(name: String), maybe adding implicit conversions to taste.  Also, Scalaz has a class explicitly for this purpose: http://scalaz.github.com/scalaz/scalaz-2.9.1-6.0.2/doc/scalaz/NewType.html

Ken

Re: whither newtype?

On Wed, Jan 18, 2012 at 3:09 PM, Ken Scambler wrote:
> http://scalaz.github.com/scalaz/scalaz-2.9.1-6.0.2/doc/scalaz/NewType.html

w00t, thanks.

Re: whither newtype?

The point of newtype in haskell is that you get type-dependent dispatch without the overhead of run-time indirection. All the approaches I've found in scala result in a new object being generated that points to the thing you want to newtype. Perhaps there's a way.
Matthew

On 18 January 2012 23:41, Raoul Duke <raould [at] gmail [dot] com> wrote:
On Wed, Jan 18, 2012 at 3:09 PM, Ken Scambler <ken [dot] scambler [at] gmail [dot] com> wrote:
> http://scalaz.github.com/scalaz/scalaz-2.9.1-6.0.2/doc/scalaz/NewType.html

w00t, thanks.



--
Dr Matthew PocockIntegrative Bioinformatics Group, School of Computing Science, Newcastle Universitymailto: turingatemyhamster [at] gmail [dot] com gchat: turingatemyhamster [at] gmail [dot] commsn: matthew_pocock [at] yahoo [dot] co [dot] uk irc.freenode.net: drdozerskype: matthew.pococktel: (0191) 2566550mob: +447535664143

Re: whither newtype?

> The point of newtype in haskell is that you get type-dependent dispatch
> without the overhead of run-time indirection. All the approaches I've found
> in scala result in a new object being generated that points to the thing
> you want to newtype. Perhaps there's a way.

See unboxed tagged types.

Re: whither newtype?

body p { margin-bottom: 0cm; margin-top: 0pt; }

Hmmm, I think Miles' unboxed newtype is what you're looking for: https://gist.github.com/89c9b47a91017973a35f

See here for usage: https://github.com/retronym/scalaz7-experimental/blob/master/core/src/main/scala/scalaz/std/AnyVal.scala

Ittay


Matthew Pocock wrote:
X0t4kA [at] mail [dot] gmail [dot] com" type="cite">The point of newtype in haskell is that you get type-dependent dispatch without the overhead of run-time indirection. All the approaches I've found in scala result in a new object being generated that points to the thing you want to newtype. Perhaps there's a way.
Matthew

On 18 January 2012 23:41, Raoul Duke <raould [at] gmail [dot] com" rel="nofollow">raould [at] gmail [dot] com> wrote:
On Wed, Jan 18, 2012 at 3:09 PM, Ken Scambler <ken [dot] scambler [at] gmail [dot] com" rel="nofollow">ken [dot] scambler [at] gmail [dot] com> wrote:
> http://scalaz.github.com/scalaz/scalaz-2.9.1-6.0.2/doc/scalaz/NewType.html

w00t, thanks.



--
Dr Matthew Pocock Integrative Bioinformatics Group, School of Computing Science, Newcastle University mailto: turingatemyhamster [at] gmail [dot] com" target="_blank" rel="nofollow">turingatemyhamster [at] gmail [dot] com gchat: turingatemyhamster [at] gmail [dot] com" target="_blank" rel="nofollow">turingatemyhamster [at] gmail [dot] com msn: matthew_pocock [at] yahoo [dot] co [dot] uk" target="_blank" rel="nofollow">matthew_pocock [at] yahoo [dot] co [dot] uk irc.freenode.net: drdozer skype: matthew.pocock tel: (0191) 2566550 mob: +447535664143

Copyright © 2013 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland