Hacker News

Top stories

Live mirror
30 storiesupdated just nowView source snapshot
  1. GPT-6 Sol and Luna(openai.com)
    486comments
  2. Claude Opus 5.5(anthropic.com)
    706comments
  3. Microsoft killed FoxPro in 2007. Anyway, here's FoxPro revived(foxscript.org)
    32comments
  4. OpenAI GPT–6 Astra breaks Enigma message that has resisted solution since 2005(cryptocellar.org)
    345comments
  5. 'We hacked the FBI:' Hackers say they have data on all FBI employees(404media.co)
    137comments
  6. LLM Ass Bench(assbench.com)
    22comments
  7. The UV index is not the warm sensation of sunlight on bare skin(asciitweezers.com)
    15comments
  8. SAML: A Fractal of Bad Design(trailofbits.com)
    47comments
  9. Claude Opus 5.5 Intelligence, Performance and Price Analysis (Max)(artificialanalysis.ai)
    52comments
  10. WordPress: Unauthenticated path traversal leading to conditional RCE(github.com/wordpress)
    66comments
  11. Native apps written in TypeScript and CSS(github.com/geastack)
    10comments
  12. Markdown in /src(htmx.org)
    22comments
  13. An update on how we confirm your age group on Discord(discord.com)
    20comments
  14. OpenAI is well positioned to fast-follow Jev(arcturus-labs.com)
    176comments
  15. Show HN: JevBench, a reproducible benchmark for typed decision models(benchmarkheaven.com)
    4comments
  16. How did AMD Ryzen get 50% faster in two years?(lemire.me)
    30comments
  17. MUNI Heritage Weekend in San Francisco(lawrence.lu)
    32comments
  18. Did OpenAI solve the wrong Navier-Stokes problem?(scientificamerican.com)
    31comments
  19. Unreal Agent(unreallabs.ai)
    52comments
  20. What California is learning from solar panels built over irrigation canals(kqed.org)
    50comments
  21. The Trouble with 'Ntile()'(djnavarro.net)
    discuss
  22. Rabbit Hole: Minimum L-seams(fractalkitty.com)
    5comments
  23. George Lucas Returns to Earth, Bearing Gifts(commonedge.org)
    25comments
  24. Pentagon says overreliance on AI contributed to missile strike on Iran school(bloomberg.com)
    139comments
  25. Show HN: Training a model to identify AI web content from structure alone(arxiv.org)
    8comments
  26. 16-bit Intel 8088 chip (c. 1985)(allpoetry.com)
    13comments
  27. People hooked on vapes try a new way to quit: cigarettes(bloomberg.com)
    51comments
  28. Apple has added persistent 'ads' to iOS, and it's driving users crazy(techradar.com)
    410comments
  29. There's a high chance of devices being sold with GrapheneOS preinstalled in 2027(grapheneos.social)
    101comments
  30. Launch HN: Coverage Cat (YC S22) – Umbrella insurance via your personal agent(coveragecat.com)
    19comments

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.