I am following various Thermite tutorials about setting up task lists. The only tutorial with a lot of explanation is also quite far out of date, so I am modifying it to fit the current Thermite. However, I have one call in which I cannot make the data types match.
import Optic.Lens (lens)
import Optic.Prism (prism)
import Optic.Types (Prism', Lens')
import Thermite as T
_TaskAction :: Prism' TaskListAction (Tuple Int TaskAction)
_TaskAction = ...
_tasks :: Lens' TaskListState (L.List TaskState)
_tasks = lens _.tasks (_ { tasks = _ })
taskList :: T.Spec _ TaskListState _ TaskListAction
taskList = T.focus _tasks _TaskAction taskSpec
However, this gives me an error message:
Could not match type p0 with type Function while trying to match type p0 t1 with type Function (List { text :: String } ) while checking that expression _tasks has type p0 t1 t1 -> p0 t2 t2 in value declaration taskList where p0 is a rigid type variable bound at line 213, column 20 - line 213, column 26 t1 is an unknown type t2 is an unknown type
The error message is specifically talking about the _tasks
parameter I am passing to T.focus
. But I do not know what the error is trying to tell me. I also know that the type signature for T.focus
is...
focus :: forall eff props state2 state1 action1 action2.
Lens' state2 state1
-> Prism' action2 action1
-> Spec eff state1 props action1
-> Spec eff state2 props action2
So, the first parameter is a lens.
More frustratingly, I've checked more modern (but larger and less comprehensible) example code, and it shows exactly the same definition for _tasks
as I have here.
So, what does this error message mean, and what do I need to do to fix it?
profunctor-lenses
. – Phil Freeman