Skip to content

Instantly share code, notes, and snippets.

@nmdanny
Created July 30, 2016 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nmdanny/135ceed89d46cbf8e887890d01e7a556 to your computer and use it in GitHub Desktop.
Save nmdanny/135ceed89d46cbf8e887890d01e7a556 to your computer and use it in GitHub Desktop.
[1/1 TypesDoNotUnify] src\Layout.purs:41:49
41 , effects : newState.effects
^^^^^^^^^^^^^^^^
Could not match type
Action
with type
Action
while trying to match type Aff
( channel :: CHANNEL
, err :: EXCEPTION
, ajax :: AJAX
)
Action
with type Aff
( channel :: CHANNEL
, err :: EXCEPTION
, ajax :: AJAX
)
Action
while checking that expression newState
has type { effects :: Array
(Aff
( channel :: CHANNEL
, err :: EXCEPTION
, ajax :: AJAX
)
Action
)
| t0
}
while checking type of property accessor newState.effects
in value declaration update
where t0 is an unknown type
module App.Layout where
import App.Counter as Counter
import App.CounterPair as CounterPair
import App.NotFound as NotFound
import App.Todos as TodoList
import App.Routes (Route(..))
import Prelude (($), map)
import Network.HTTP.Affjax (AJAX)
import Control.Monad.Aff.Console (CONSOLE)
import DOM (DOM)
import Pux (EffModel,noEffects,mapEffects)
import Pux.Html (Html, div, h1, h2, p, text, nav, ul, li)
import Pux.Router (link)
data Action
= Child (Counter.Action)
| PairChild (CounterPair.Action)
| TodoAction (TodoList.Action)
| PageView Route
type State =
{ route :: Route
, count :: Counter.State
, pairCount :: CounterPair.State
, todos :: TodoList.State }
init :: State
init =
{ route: NotFound
, count: Counter.init
, pairCount : CounterPair.init
, todos : TodoList.init
}
update :: Action -> State -> EffModel State Action (ajax :: AJAX)
update (PageView route) state = noEffects $ state { route = route }
update (Child action) state = noEffects $ state { count = Counter.update action state.count }
update (PairChild action) state = noEffects $ state { pairCount = CounterPair.update action state.pairCount}
update (TodoAction action) cState = { state : cState { todos = newState.state }
, effects : newState.effects -- < error here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
where newState = TodoList.update action cState.todos
view :: State -> Html Action
view state =
div
[]
[ h1 [] [ text "Pux Starter App" ]
, navigation
, p [] [ text "Change src/Layout.purs and watch me hot-reload." ]
, case state.route of
Home -> h2 [] [ text "Home"]
Counter -> map Child $ Counter.view state.count
CounterPair -> map PairChild $ CounterPair.view state.pairCount
Todos -> map TodoAction $ TodoList.view state.todos
NotFound -> NotFound.view state
]
navigation :: Html Action
navigation =
nav
[]
[ ul
[]
[ li [] [ link "/" [] [ text "Home" ]]
, li [] [ link "/counter" [] [ text "Counter"]]
, li [] [ link "/counterPair" [] [ text "Counter Pair" ]]
, li [] [ link "/todos" [] [ text "Todo Manager" ]]
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment