Re: Haskell is our first choice for building production soft...
by zvrba on Monday January 11, 2021 @01:42PM
(#25733848)
But is _just reading_ from a database a "side-effect"? It is non-deterministic, but it has no side-effects. So IO jumbles together the two notions.
[ Parent
| on HN ]
Re: Haskell is our first choice for building production soft...
by uryga on Monday January 11, 2021 @03:10PM
(#25735742)
pedantically, talking to the database will involve sending a request or some kind of IPC, all of which are usually considered side effects.
[handwavy analogy alert]
people often call it "side-effects" as a shorthand. in reality an expression being of type `IO Foo` mostly just tells the compiler that order of execution matters (which isn't the case with pure functions):
do print "a"
print "b"
-- obviously not the same as
do print "b"
print "a"
and also that it can't eliminate common expressions: do a <- readBytes file 100
b <- readBytes file 100
doStuff a b
-- obviously not the same as
do x <- readBytes file 100
doStuff x x
it's a way of enforcing ordering in a lazy language where evaluation order isn't really defined.