slowly porting fixpoint sortchecking from ml to hs