[Issue 12461] Typedef and opOpAssign
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Apr 23 14:21:11 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12461
bearophile_hugs at eml.cc changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bearophile_hugs at eml.cc
--- Comment #2 from bearophile_hugs at eml.cc ---
(In reply to Andrej Mitrovic from comment #1)
> But I'm not sure if this is the appropriate fix.
> Do you have a better idea?
In Haskell this doesn't compile (newtype is a built-in that is similar to
Typedef):
newtype T = T Int
main = do
let a = 10 :: T
let b = 20 :: T
let c = a + b :: T
print c
You have to ask the compiler to activate the arithmetic operations between two
newtypes:
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
newtype T = T Int deriving (Num, Show)
main = do
let a = 10 :: T
let b = 20 :: T
let c = a + b :: T
print c
And now it prints:
T 30
--
More information about the Digitalmars-d-bugs
mailing list