
Thanks for the thoughts. This is funny, so the constructor has the same name but is for different types. I think this is specially bad for security. I'm going to be paranoid about it now. Dimitri On 17/06/15 00:42, Karl Voelker wrote:
On Tue, Jun 16, 2015, at 05:43 PM, Dimitri DeFigueiredo wrote:
I am a little suprised that this program compiles in GHC:
---- data ReqTime = ReqTime data AckTime = AckTime
data Order a = Order { price ::Double, volume ::Int, timestamp ::Int }
convertToReq :: Order AckTime -> Order ReqTime convertToReq o = o{price = 1}
main = putStrLn "Hi!" ---- I found it surprising, too. But, if you look in the Haskell report (https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-540003.1...), record update is defined by a "desugaring" translation. So your convertToReq desugars (roughly) to:
convertToReq o = case o of Order v1 v2 v3 -> Order 1 v2 v3
Unfortunately, the report does not have any commentary on why it is the way it is.
-Karl _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners