Skip to content

Replace Backpack with IORef-based app registration - #13

Merged
jappeace merged 3 commits into
jappeace:masterfrom
jappeace-sloth:ioref-registration
Mar 29, 2026
Merged

jappeace merged 3 commits into
jappeace:masterfrom
jappeace-sloth:ioref-registration

Conversation

@jappeace-sloth

Copy link
Copy Markdown

Summary

  • Replace Backpack signature with IORef-based MobileApp registration pattern, fixing Nix compatibility (callCabal2nix can't handle Backpack instantiation across derivations)
  • Main library exports MobileApp record, runMobileApp, getMobileApp; FFI entry points read from global IORef
  • Android builds use CPP flag HASKELL_MOBILE_ANDROID to auto-register via haskellInit

Test plan

  • cabal build passes (all libraries + exe)
  • cabal test passes (27 tests including new registration tests)
  • CI passes on GitHub

🤖 Generated with Claude Code

jappeace-sloth and others added 3 commits March 28, 2026 21:00
Backpack doesn't work with Nix: callCabal2nix builds packages as separate
derivations, but Backpack instantiation requires both the indefinite library
and its instantiation in the same cabal build.

Replace the Backpack signature with an IORef registration pattern:
- Main library exports MobileApp record type, runMobileApp, getMobileApp
- FFI entry points read from a global IORef (Maybe MobileApp)
- Desktop: downstream main calls runMobileApp before lifecycle simulation
- Android: haskellInit calls runMobileApp via CPP-guarded import
- Delete src-sig/HaskellMobile/App.hsig (Backpack signature)
- default-app/HaskellMobile/App.hs now exports mobileApp :: MobileApp
- haskell-mobile-default-app sub-library now depends on main library
- Add -DHASKELL_MOBILE_ANDROID to android.nix GHC flags
- Add registration tests for runMobileApp/getMobileApp

Prompt: implement plan to replace Backpack with IORef/main registration
Tokens: ~60k input, ~10k output

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The iOS and Android nix builds compile HaskellMobile.hs directly with GHC
(not via cabal), so default-extensions from the cabal file don't apply.
platformLog expects Text, so OverloadedStrings is needed for string literals.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract MobileApp type into HaskellMobile.Types to break the import
cycle between HaskellMobile and HaskellMobile.App in raw-GHC builds
(nix/android.nix, nix/ios.nix).

Rename CPP flag HASKELL_MOBILE_ANDROID to HASKELL_MOBILE_PLATFORM and
add it to the iOS build so haskellInit registers the default app on
both platforms, fixing the missing Lifecycle: Create/Resume events in
the iOS simulator test.

Prompt: PR 13 for haskell-mobile appears to have build failures, here
we're replacing backpack with ioref based approach. make sure it builds
locally and then ensure CI builds

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jappeace
jappeace merged commit 5c52a37 into jappeace:master Mar 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants