morloc-project / morloc

A typed, polyglot, functional language
GNU General Public License v3.0
195 stars 4 forks source link

Bad error message when missing top-level signature #19

Open arendsee opened 9 months ago

arendsee commented 9 months ago

In the flu case study of commit d6c2aba3d3e, in the function definition:

plotCladeTree :: FluConfig -> RootedTree Str e (a, Clade) -> ()
plotCladeTree config = plotTree config@treefile . mapLeaf setLeafName 

where plotTree, mapLeaf, and setLeafName have the following signatures:

plotTree :: Filename -> RootedTree n Real Str -> ()
setLeafName :: (JsonObj, Sequence) -> Str
mapLeaf :: (l -> l') -> RootedTree n e l -> RootedTree n e l'

Removal of the signature causes the following error to be raised the following error:

morloc: Bug in expressPolyExpr - this should be unreachable

Obviously this case is not unreachable. The type signature ought to be mostly inferrable. The sticky bit is the record FluConfig. All that can be inferred without that annotation is that some record with the field treefile :: Filename exists. Currently partially inferred types like this are not supported, so an error should be raised here. This is a user error. The problem is simply that a type annotation is required. The error message should indicate this.