
17 Jun
2015
17 Jun
'15
2:42 a.m.
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