Hello,
I have this piece of code:
trgls <- trianglesIO
triangles <- newIORef trgls
How can I get triangles
from trianglesIO
in one line?
Hello,
I have this piece of code:
trgls <- trianglesIO
triangles <- newIORef trgls
How can I get triangles
from trianglesIO
in one line?
I’ve found: triangles <- trianglesIO >>= newIORef
.
You can also use the flipped version to keep the information flow direction right to left:
triangles <- newIORef =<< trianglesIO
The .. <- ..
is built in syntax while >>=
and =<<
are normal operators which could have be defined by users. User defined operators will always be more flexible than built in syntax.
Alternatively, use more exact names:
initial <- initTriangles
current <- newIORef initial