Concurrent Clean : 型エラーに悩む

もう自分の書いている型が正しいのかどうか全く自信がない。
Cleanは、対話環境がない上に、一意型の関係を正しく指定しないといけないので、複雑な関数の型を正しく書くのは至難だ。
まあ、例えば、こんな型エラーになるのですよ。

Compiling Controller
Type error [Controller.icl,38,cgi0]: near cgi : cannot unify types:
 MCGI v0
 ((CGIInfo -> ModelDef ModelHandle (PassFailModel v0)) -> (MapView ModelHandle (PassFailModel v0) (PassFailModel HtmlData)) -> v2 -> ModelDef ModelHandle (PassFailModel HtmlData)) -> (CGIInfo -> ModelDef ModelHandle (PassFailModel v0)) -> (MapView ModelHandle (PassFailModel v0) (PassFailModel HtmlData)) -> ModelDef ModelHandle (PassFailModel HtmlData)
Uniqueness error [Controller.icl,41,model0]:attribute at indicated position could not be coerced ((CGIInfo -> (*ModelHandle -> ((PassFail a ErrorInfo),^ ModelHandle))) -> u:(v:((PassFail a ErrorInfo) -> w:(ModelHandle -> x:(y:(PassFail z:HtmlData u0:ErrorInfo),v0:ModelHandle))) -> w0:(*ModelHandle -> x:(y:(PassFail z:HtmlData u0:ErrorInfo),v0:ModelHandle))))
Uniqueness error [Controller.icl,44,view0]:attribute at indicated position could not be coerced ((PassFail HtmlData ErrorInfo) -> (*ModelHandle -> ^ *((PassFail HtmlData ErrorInfo),*ModelHandle)))
Uniqueness error [Controller.icl,31,runCGI]:attribute at indicated position could not be coerced MDef a
Uniqueness error [Controller.icl,35,runCGI]:"argument 1 of closeModelHandle" attribute at indicated position could not be coerced ^ ModelHandle
Uniqueness error [Controller.icl,33,runCGI]:"argument 1 of closeModelHandle" attribute at indicated position could not be coerced ^ ModelHandle

今悩んでいるのはこれ。

Compiling Controller
Uniqueness error [Controller.icl,41,cgi0]:attribute at indicated position could not be coerced *(((CGIInfo -> *ModelHandle -> *(u:(PassFail a v:ErrorInfo),*ModelHandle)) -> (((PassFail a ErrorInfo) -> *ModelHandle -> *(w:(PassFail x:HtmlData y:ErrorInfo),*ModelHandle)) -> (*ModelHandle -> *((PassFail HtmlData ErrorInfo),*ModelHandle)))) -> ^ *((CGIInfo -> *ModelHandle -> *(u:(PassFail a v:ErrorInfo),*ModelHandle)) -> *(((PassFail a ErrorInfo) -> *ModelHandle -> *(w:(PassFail x:HtmlData y:ErrorInfo),*ModelHandle)) -> *((PassFail HtmlData ErrorInfo),*ModelHandle))))
Type error [Controller.icl,47,view0]:derived type conflicts with specified type:
 MView HtmlData
 MView a
      • -

解決した。

::*MapCGI   c h e i j :== (MapModel c h e i j) -> (c -> ModelDef h e i) -> (i -> ModelDef h e j) -> *MapResult h e j

を、次のように直す必要があった。

::*MapCGI   c h e i j :== *((MapModel c h e i j) -> *((c -> ModelDef h e i) -> *((i -> ModelDef h e j) -> *MapResult h e j)))

関数型と一意型の関係のルールを忘れていた。
これは、なかなかややこしいルールなので、一度解説記事を書いておく方がよいかもしれない。