The type of
'a t list -> 'a list t (where
You are applying
check_fun_def_body_in_block : ('a,'b) stmt list option -> unit t to each element of the list giving you a
unit t list. When you then sequence the effects, you get back
unit list t.
However, in the first case of your match statement, you are returning
unit t. Since
unit t does not equal
unit list t (!) it will not type check.
There are two ways to fix this:
ok  from the first branch and add
Validation.map ~f:List.concat after
sequence on the second branch;
Validation.map ~f:(fun _ -> ()) after
sequence on the second branch.
(EDIT: it turns out I can’t code without a type checker… you will still have to flatten the list of lists for the first option, above)
The semantic check code isn’t quite where I want it to be at the moment so it probably doesn’t matter which you use (
Semantic_check currently performs type checking which requires a monadic interface - see below) but I would usually prefer the first option. It might be worth taking a look at the docs I added explaining
apply works here.
If the computations are independent (i.e. checking the validity of one statement does not depend on the result of a previously checked statement) you only require the
Validation should not really support the
Monad interface since the implementation violates the monad laws and, more practically, doing so means it doesn’t actually accumulate errors through monadic bind!.
NB In the PR I submitted yesterday for semantic warnings I actually changed the interface to validation to match the standard
Core_kernel signatures so
sequence is called