Urgent.News

What's breaking now, across thousands of outlets.

Tech

Writing stateful effect handlers in EYG

In the context of managing effects in EYG, it is often necessary to maintain state outside of the computation that raises the effects. Consider an Increment effect that requires tracking the current count, or a handler for StandardOut that accumulates a list of all messages written during testing. The following example demonstrates a stateful Increment effect.

Each handle expression is associated with a single effect label. Handlers can be nested to handle multiple effects, but one must be cautious in managing the same state between different handlers. This design choice aims to keep the type system simple, although the restriction may be relaxed in the future. If you require multiple effectful operations, you have two options.

The counter value can be incremented and retrieved using the get and increase functions, which serve as the public interface for the stateful operation.

A generic Update effect allows for transforming the current state into a new state. However, this approach is only feasible if you have control over the effect design, which is not always the case. For instance, when testing a library using the Get and Increase effects, one might need to bounce the effects onto a new effect that you have control over.

When type checking the following code snippet, an error will be encountered: "this expression has a recursive type." This error is not immediately apparent. The issue arises because the type of f appears in the return type of the Get effect row within the main function. When f is called, its effects are unified with the effects present in the current function block, which is the main block.

As a result, a recursive type is constructed, leading to the aforementioned error. It is strongly recommended not to return functions from effects due to this limitation.

Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at eyg.run →

More in Tech

Tax Officers Reject New Plans for FBR

The Inland Revenue Service Officers Association (IRSOA) has opposed further structural changes at the Federal Board of Revenue (FBR), urging … Read More The post Tax Officers Reject New Plans for FBR appeared first on ProPakistani .

Blue Owl defends software exposure amid private credit redemption pressures

Blue Owl Capital has played down concerns over AI-driven disruption to its software investments, as the alternative asset manager continues to face elevated redemption requests across some private…

  • Blue Owl Capital confident in software investments despite AI disruption concerns.
  • Private credit redemption requests rise, especially for software borrowers facing AI competition.
  • Blue Owl expands to Asia-Pacific data center financing, appoints Takeo Ikemori for Japan business.

Apple Store Down Ahead of iPhone Duo Pre-Orders

Apple's online store is down ahead of iPhone Duo pre-orders, which begin at 5:00 a.m. Pacific Time on Friday, October 16. "We love that early energy," reads the Apple Store 's message when visiting the U.S. website. "Almost ready for you. Pre-order begins at 5:00 a.m. PT. See you soon." Apple has been opening pre-orders at 5:00 a.m.

More from Friday 16 October →