It seems the dependency graph between cells does not track user-defined types correctly. When a cell containing a type definition is changed, cells using a constructor of that type definition will correctly be rerun, while cells only "consuming" that type will not be rerun. These different cells will then refer to different types (the former to the newly run type, the latter to the type defined before rerunning) and can cause type errors. It is also not possible to manually rerun the missing cells without making a change in them or restarting the kernel.
Consider the following notebook:
- cell 2 uses the constructor of type
A
- cell 3 only "consumes" type
A, but does not use the constructor
consumeA :: A -> ()
consumeA _ = ()
-- consumeA A = () <- would also cause the same issue
- cell 4 uses values from cell 2 and cell 3
problemFun :: ()
problemFun = consumeA mkA
Running the notebook will behave as expected. However, if we now make a change to cell 1, even a trivial whitespace change, we can rerun it. This triggers cells 2 and 4 to be rerun, but not cell 3. This immediately causes a type error in cell 4, since mkA returns a value of the "new" type A, while consumeA expects a value of the "old" type A.
It seems the dependency graph between cells does not track user-defined types correctly. When a cell containing a type definition is changed, cells using a constructor of that type definition will correctly be rerun, while cells only "consuming" that type will not be rerun. These different cells will then refer to different types (the former to the newly run type, the latter to the type defined before rerunning) and can cause type errors. It is also not possible to manually rerun the missing cells without making a change in them or restarting the kernel.
Consider the following notebook:
AAA, but does not use the constructorRunning the notebook will behave as expected. However, if we now make a change to cell 1, even a trivial whitespace change, we can rerun it. This triggers cells 2 and 4 to be rerun, but not cell 3. This immediately causes a type error in cell 4, since
mkAreturns a value of the "new" typeA, whileconsumeAexpects a value of the "old" typeA.