dex-lang
dex-lang copied to clipboard
RFC: make print polymorphic and fluent
Putting this out there for comments as to if it is a good idea. If it is then this PR still needs tests added.
- Making it call
show
on its input just seems more convient - Making it return its input means you can (for debugging purposes) slip it inside some compouind expression
- e.g.
x |> f |>g
can becomex |> f |> print |> g
- e.g.
idk how useful this really is.
An alternative would be to have three different functions, like Haskell:
def putString (s:String) : {State World} Unit = ...
def print (_:Show a) ?=> (x:a) : {State World} Unit =
putString $ show x
def trace (s:String) : String = unsafeIO do
putString s
s
Notice that trace
doesn't need the IO effect exposed, because it won't get DCEd as long as its result is used.