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.
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.
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:
> 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.
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
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:
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?
Matthew
On 18 January 2012 23:41, Raoul Duke <raould [at] gmail [dot] com> wrote:
--
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?
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: