Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. GPT-6 Sol and Luna(openai.com)
    586comments
  2. Claude Opus 5.5(anthropic.com)
    790comments
  3. 'We hacked the FBI:' Hackers say they have data on all FBI employees(404media.co)
    250comments
  4. OpenAI GPT–6 Astra breaks Enigma message that has resisted solution since 2005(cryptocellar.org)
    356comments
  5. ReBarUEFI: Resizable BAR for almost any UEFI system(github.com/xcuri0)
    17comments
  6. Microsoft killed FoxPro in 2007. Anyway, here's FoxPro revived(foxscript.org)
    117comments
  7. What California is learning from solar panels built over irrigation canals(kqed.org)
    122comments
  8. SAML: A fractal of bad design(trailofbits.com)
    83comments
  9. Claude Opus 5.5 Intelligence, Performance and Price Analysis (Max)(artificialanalysis.ai)
    65comments
  10. Unreal Agent(unreallabs.ai)
    72comments
  11. WordPress: Unauthenticated path traversal leading to conditional RCE(github.com/wordpress)
    79comments
  12. The new CC, an AI agent built for families(blog.google)
    1comments
  13. Pentagon says overreliance on AI contributed to missile strike on Iran school(bloomberg.com)
    201comments
  14. How did AMD Ryzen get 50% faster in two years?(lemire.me)
    69comments
  15. MUNI Heritage Weekend in San Francisco(lawrence.lu)
    40comments
  16. Native apps written in TypeScript and CSS(github.com/geastack)
    21comments
  17. The current balance of power in open models(interconnects.ai)
    8comments
  18. Show HN: JevBench, a reproducible benchmark for typed decision models(benchmarkheaven.com)
    11comments
  19. OpenAI is well positioned to fast-follow Jev(arcturus-labs.com)
    190comments
  20. Markdown in /src(htmx.org)
    42comments
  21. Obscura: VPN that can't log your activity(obscura.com)
    72comments
  22. The UV index is not the warm sensation of sunlight on bare skin(asciitweezers.com)
    49comments
  23. George Lucas Returns to Earth, Bearing Gifts(commonedge.org)
    39comments
  24. Make Math Automatic with Mathy(gmays.com)
    1comments
  25. People hooked on vapes try a new way to quit: cigarettes(bloomberg.com)
    88comments
  26. Show HN: Training a model to identify AI web content from structure alone(arxiv.org)
    9comments
  27. 16-bit Intel 8088 chip (c. 1985)(allpoetry.com)
    13comments
  28. The JavaScript Midlife Crisis(maroun-baydoun.com)
    15comments
  29. Apple has added persistent 'ads' to iOS, and it's driving users crazy(techradar.com)
    451comments
  30. Launch HN: Coverage Cat (YC S22) – Umbrella insurance via your personal agent(coveragecat.com)
    24comments

Show HN: LazyPromise = Observable – Signals

34 pointsby 9mo agogithub.com
10 comments
A Promise-like primitive which is lazy/cancelable, has typed errors, and emits synchronously instead of on the microtask queue. In a way LazyPromise is what you get if you take an Observable and make it impossible to misuse it for what the Signals were built to do.
9mo agoHN ↗

Interesting, interesting. It would take me a few hours of playing with this mechanism to know what I think of it as a primitive, but for me this solution is relevant to a problem I really have so I might take a look. Right now I just write methods that sometimes return a promise and sometimes don't.

8mo agoHN ↗

Yes, do take a look, I've just added a `log` function that makes it easy to play around with lazy promises and see everything that's going on.

9mo agoHN ↗

Do you want monads? Because this is how you get monads.

8mo agoHN ↗

Author here. What's pretty cool about LazyPromise is that when it's paired with Signals, you can do some of the stuff that you'd otherwise do with functional reactive programming, but you don't have to tell your team to learn RxJS or another FRP library - instead there is an API that capitalizes on the existing knowledge of the native promise.

9mo agoHN ↗

Interesting stuff!

The two separate failure channels turn me off. Is this practical or does it introduce unwanted complexity in most cases?

Also wondering what are the Signals that are mentioned.

8mo agoHN ↗

Author here. Good questions.

About the two error channels: what I tried to do is to make it really easy to not use typed errors when you don't need them. In that case your promise is typed as `LazyPromise<Value, never>`.

Signals is a reactive primitive that has been initially introduced in SolidJS framework and have then made their way to other frameworks like Angular.

9mo agoHN ↗

Quick question - would something like this cover the basic cancelable promise use case, or am I missing something important about what LazyPromise does differently?

  function cancelablePromise() {
    const promise = new Promise(resolve => setTimeout(resolve, 1000))
  
    let cancel: () => void
    const cancelPromise = new Promise((_, reject) => {
      cancel = () => reject("promise canceled")
    })
  
    const wrappedPromise = Promise.race([promise, cancelPromise])
  
    return {
      promise: wrappedPromise,
      cancel: cancel,
    }
  }
8mo agoHN ↗

Yeah, I think this will cover the basic use-case, although the way I'd approach this is by starting with AbortSignal API and then maybe creating a wrapper around it. In a way `eager` and `lazy` functions from LazyPromise library are such wrappers.

9mo agoHN ↗

Observability is step one. The hard part is what the system is allowed to do once you observe it.