1
votes

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?

1
You're using the wrong lens library. Thermite uses profunctor-lenses.Phil Freeman
This worked perfectly. If you promote it to an answer, I'll give you the credit.Savanni D'Gerinel

1 Answers

2
votes

The fact that you're importing Optic.Lens suggests that you're using the wrong lens library here. purescript-lens provides traditional van-Laarhoven lenses (like Haskell's lens library), but Thermite uses the profunctor-lenses library.