3 ms·
what do you mean by that? all functions in haskell are pure unless you explicitly use unsafePreformIO or similar (which is rare to ever have to do)
by ChadNauseam 2y ago
what do you mean by that? all functions in haskell are pure unless you explicitly use unsafePreformIO or similar (which is rare to ever have to do)
- agnishom 2y agoIt doesn't have great support for Dependent Types
- eru 2y agoThey can still have side-effects like non-termination. But I didn't mean purity in that formal sense. I meant that Haskell is plenty pragmatic in its design.
- kreetx 2y agoTo me, "pure" means referential transparency: same input, same output. So an `Int -> Int` function will return same result on same argument. So, similar to `Int -> IO Int`, the function (action) will return an Int after interacting with outside world, `IO` tracking the fact that this is the case.
- tromp 2y agoLambda calculus is as pure as can be, and also has terms that don't normalize. That is not considered a side effect. A better example of impurity in Haskell for pragmatic's sake is the trace function, that can be used to print debugging information from pure functions.
- eru 2y ago> Lambda calculus is as pure as can be, and also has terms that don't normalize. That is not considered a side effect. Many typed lambda calculi do normalise. You can also have a look https://dhall-lang.org/ https://dhall-lang.org/ for some pragmatic that normalises. > A better example of impurity in Haskell for pragmatic's sake is the trace function, that can be used to print debugging information from pure functions. Well, but that's just unsafePerformIO (or unsafePerformIO-like) stuff under the hood; that was already mentioned.
- instig007 2y ago> They can still have side-effects like non-termination. you can still have total functions that don't finish in humanly/business reasonable amount of time.
- eru 2y agoYes? Just like pure functions can use more memory than your system has. Or computing them can cause your CPU to heat up, which is surely a side-effect.