Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. GPT-6 Sol and Luna(openai.com)
    550comments
  2. Claude Opus 5.5(anthropic.com)
    763comments
  3. 'We hacked the FBI:' Hackers say they have data on all FBI employees(404media.co)
    200comments
  4. Microsoft killed FoxPro in 2007. Anyway, here's FoxPro revived(foxscript.org)
    88comments
  5. OpenAI GPT–6 Astra breaks Enigma message that has resisted solution since 2005(cryptocellar.org)
    354comments
  6. ReBarUEFI: Resizable BAR for almost any UEFI system(github.com/xcuri0)
    5comments
  7. SAML: A fractal of bad design(trailofbits.com)
    69comments
  8. Claude Opus 5.5 Intelligence, Performance and Price Analysis (Max)(artificialanalysis.ai)
    61comments
  9. Unreal Agent(unreallabs.ai)
    64comments
  10. WordPress: Unauthenticated path traversal leading to conditional RCE(github.com/wordpress)
    74comments
  11. Native apps written in TypeScript and CSS(github.com/geastack)
    18comments
  12. How did AMD Ryzen get 50% faster in two years?(lemire.me)
    57comments
  13. Show HN: JevBench, a reproducible benchmark for typed decision models(benchmarkheaven.com)
    7comments
  14. MUNI Heritage Weekend in San Francisco(lawrence.lu)
    37comments
  15. OpenAI is well positioned to fast-follow Jev(arcturus-labs.com)
    183comments
  16. Markdown in /src(htmx.org)
    35comments
  17. Show HN: Training a model to identify AI web content from structure alone(arxiv.org)
    8comments
  18. Did OpenAI solve the wrong Navier-Stokes problem?(scientificamerican.com)
    38comments
  19. 16-bit Intel 8088 chip (c. 1985)(allpoetry.com)
    13comments
  20. The current balance of power in open models(interconnects.ai)
    2comments
  21. George Lucas Returns to Earth, Bearing Gifts(commonedge.org)
    31comments
  22. Apple's Dimensional Drawings(512pixels.net)
    1comments
  23. The trouble with 'ntile()'(djnavarro.net)
    discuss
  24. The JavaScript Midlife Crisis(maroun-baydoun.com)
    9comments
  25. Launch HN: Coverage Cat (YC S22) – Umbrella insurance via your personal agent(coveragecat.com)
    21comments
  26. People hooked on vapes try a new way to quit: cigarettes(bloomberg.com)
    73comments
  27. Pentagon says overreliance on AI contributed to missile strike on Iran school(bloomberg.com)
    174comments
  28. An update on how we confirm your age group on Discord(discord.com)
    51comments
  29. Apple has added persistent 'ads' to iOS, and it's driving users crazy(techradar.com)
    433comments
  30. There's a high chance of devices being sold with GrapheneOS preinstalled in 2027(grapheneos.social)
    103comments

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.