haskell - Type inference interferes with referential transparency -


what precise promise/guarantee haskell language provides respect referential transparency? @ least haskell report not mention notion.

consider expression

(7^7^7`mod`5`mod`2) 

and want know whether or not expression 1. safety, perform twice:

( (7^7^7`mod`5`mod`2)==1, [false,true]!!(7^7^7`mod`5`mod`2) ) 

which gives (true,false) ghci 7.4.1.

evidently, expression referentially opaque. how can tell whether or not program subject such behavior? can inundate program :: on not make readable. there other class of haskell programs in between miss? between annotated , unannotated one?

(apart related question found on there must else on this)

the problem overloading, indeed sort of violate referential transparency. have no idea (+) in haskell; depends on type.

when numeric type unconstrained in haskell program compiler uses type defaulting pick suitable type. convenience, , doesn't lead surprises. in case did lead surprise. in ghc can use -fwarn-type-defaults see when compiler has used defaulting pick type you. can add line default () module stop defaulting.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

How do you convert a timestamp into a datetime in python with the correct timezone? -