natefaubion / purescript-spork

Elm-like for PureScript
MIT License
157 stars 9 forks source link

The type `AppInstance` is not available #12

Closed dederer closed 6 years ago

dederer commented 6 years ago

The module Spork.App does not export the type AppInstance (and also the type AppChange). Why not?

Here is a simple usecase:

import Spork.App as App

main :: Eff AppEffects Unit
main = do
  inst <- App.makeWithSelector never app "#app"
  onresize inst UpdateSize
  inst.run

onresize 
  :: forall eff s i
   . App.AppInstance (dom :: DOM | eff) s i -- the type AppInstance is needed here
  -> (Int -> Int -> i) 
  -> Eff (dom :: DOM | eff) Unit
onresize inst action = do
  win <- DOM.window
  let updateSize = do
        inst.push =<< action <$> DOM.innerWidth win <*> DOM.innerHeight win
        inst.run
      listener = DOM.eventListener (const updateSize)
  DOM.addEventListener ET.resize listener false (DOM.windowToEventTarget win)
  updateSize
natefaubion commented 6 years ago

It's just an oversight. They should be exported.

natefaubion commented 6 years ago

https://github.com/natefaubion/purescript-spork/commit/9fecba94b4e953fbd724d21ab8c34cb3edca473a