Skip to content

Commit

Permalink
Updates for 0.11 (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
natefaubion committed Apr 10, 2017
1 parent 87f145a commit e11ecc5
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,7 +1,7 @@
language: node_js
dist: trusty
sudo: required
node_js: 5
node_js: stable
install:
- npm install
- npm install -g bower
Expand Down
25 changes: 12 additions & 13 deletions bower.json
Expand Up @@ -22,20 +22,19 @@
"output"
],
"dependencies": {
"purescript-prelude": "^2.1.0",
"purescript-eff": "^2.0.0",
"purescript-tuples": "^3.0.0",
"purescript-dom": "^3.3.0",
"purescript-maps": "^2.0.1",
"purescript-maybe": "^2.0.1",
"purescript-unsafe-coerce": "^2.0.0",
"purescript-bifunctors": "^2.0.0",
"purescript-refs": "^2.0.0",
"purescript-foreign": "^3.0.1"
"purescript-prelude": "^3.0.0",
"purescript-eff": "^3.0.0",
"purescript-tuples": "^4.0.0",
"purescript-dom": "^4.0.0",
"purescript-maps": "^3.0.0",
"purescript-maybe": "^3.0.0",
"purescript-unsafe-coerce": "^3.0.0",
"purescript-bifunctors": "^3.0.0",
"purescript-refs": "^3.0.0",
"purescript-foreign": "^4.0.0"
},
"devDependencies": {
"purescript-psci-support": "^2.0.0",
"purescript-js-timers": "^2.0.0",
"purescript-exists": "^2.0.0"
"purescript-js-timers": "^3.0.0",
"purescript-exists": "^3.0.0"
}
}
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -6,9 +6,9 @@
"build": "pulp build -- --censor-lib --strict"
},
"devDependencies": {
"pulp": "^10.0.0",
"purescript": "^0.10.2",
"purescript-psa": "^0.4.0",
"pulp": "^11.0.0",
"purescript": "^0.11.1",
"purescript-psa": "^0.5.1",
"rimraf": "^2.5.4"
}
}
2 changes: 1 addition & 1 deletion src/Halogen/VDom/DOM/Prop.purs
Expand Up @@ -49,7 +49,7 @@ instance functorElemRef ∷ Functor ElemRef where
map f (Created a) = Created (f a)
map f (Removed a) = Removed (f a)

foreign import data PropValue *
foreign import data PropValue Type

propFromString String PropValue
propFromString = unsafeCoerce
Expand Down
2 changes: 1 addition & 1 deletion src/Halogen/VDom/Types.purs
Expand Up @@ -41,7 +41,7 @@ instance bifunctorVDom ∷ Bifunctor VDom where
bimap f g (Grafted a) = Grafted (bimap f g a)
bimap f g a = Grafted (graft (Graft f g a))

foreign import data Graft * * *
foreign import data Graft Type Type Type

instance functorGraftFunctor (Graft a) where
map g = unGraft \(Graft f' g' a) → graft (Graft f' (g <<< g') a)
Expand Down
2 changes: 1 addition & 1 deletion src/Halogen/VDom/Util.purs
Expand Up @@ -170,6 +170,6 @@ foreign import addEventListener
foreign import removeEventListener
eff. Fn.Fn3 String (DOM.EventListener (dom DOM | eff)) DOM.Element (Eff (dom DOM | eff) Unit)

foreign import data JsUndefined *
foreign import data JsUndefined Type

foreign import jsUndefined JsUndefined
22 changes: 11 additions & 11 deletions test/Main.purs
@@ -1,13 +1,13 @@
module Test.Main where

import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff (Eff, kind Effect)
import Control.Monad.Eff.Ref (REF)
import Control.Monad.Eff.Ref as Ref
import Control.Monad.Eff.Timer as Timer
import Data.Exists (Exists, mkExists, runExists)
import Data.Maybe (Maybe(..), isNothing)
import Data.Nullable (toMaybe)
import Data.Newtype (wrap)
import Data.Foldable (for_, traverse_)
import Data.Function.Uncurried as Fn
import Data.Tuple (Tuple)
Expand Down Expand Up @@ -113,15 +113,15 @@ buildWidget
V.VDomMachine (domDOM, refREF | eff) (Exists Thunk) DOM.Node
buildWidget spec = render
where
render = runExists \(Thunk a render) → do
V.Step node m h ← V.buildVDom spec (render a)
render = runExists \(Thunk a render') → do
V.Step node m h ← V.buildVDom spec (render' a)
pure (V.Step node (Fn.runFn4 patch (unsafeCoerce a) node m h) h)

patch = Fn.mkFn4 \a node step halt → runExists \(Thunk b render) →
patch = Fn.mkFn4 \a node step halt → runExists \(Thunk b render') →
if Fn.runFn2 refEq a b
then pure (V.Step node (Fn.runFn4 patch a node step halt) halt)
else do
V.Step node' m h ← step (render b)
V.Step node' m h ← step (render' b)
pure (V.Step node' (Fn.runFn4 patch (unsafeCoerce b) node' m h) h)

mkSpec
Expand All @@ -134,7 +134,7 @@ mkSpec document = V.VDomSpec
, document
}

foreign import data DBMON !
foreign import data DBMON Effect

foreign import getData eff. Eff (dbmon DBMON | eff) State

Expand All @@ -153,7 +153,7 @@ mkRenderQueue
Eff (domDOM, refREF | eff) (a Eff (domDOM, refREF | eff) Unit)
mkRenderQueue spec parent render initialValue = do
initMachine ← V.buildVDom spec (render initialValue)
DOM.appendChild (V.extract initMachine) parent
_ ← DOM.appendChild (V.extract initMachine) parent
ref ← Ref.newRef initMachine
val ← Ref.newRef Nothing
pure \a → do
Expand All @@ -175,7 +175,7 @@ mkRenderQueue'
Eff (domDOM, refREF | eff) (a Eff (domDOM, refREF | eff) Unit)
mkRenderQueue' spec parent render initialValue = do
initMachine ← V.buildVDom spec (render initialValue)
DOM.appendChild (V.extract initMachine) parent
_ ← DOM.appendChild (V.extract initMachine) parent
ref ← Ref.newRef initMachine
pure \v → do
machine ← Ref.readRef ref
Expand All @@ -186,8 +186,8 @@ main :: ∀ eff. Eff (ref ∷ REF, dom ∷ DOM, dbmon ∷ DBMON, timer ∷ Timer
main = do
win ← DOM.window
doc ← DOM.document win
bod ← DOM.querySelector "body" (DOM.htmlDocumentToParentNode doc)
for_ (toMaybe bod) \body → do
bod ← DOM.querySelector (wrap "body") (DOM.htmlDocumentToParentNode doc)
for_ bod \body → do
let spec = mkSpec (DOM.htmlDocumentToDocument doc)
pushQueue ← mkRenderQueue' spec (DOM.elementToNode body) renderData initialState
let
Expand Down

0 comments on commit e11ecc5

Please sign in to comment.