KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm just starting out with SML, and I'm trying to modify some code so I understand what it's doing (I can't find a decent SML/NJ debugger, but that's a separate question). fun type_check e theta env non_gens = case e of constant_int _ => (integer, theta) | constant_bool _ => (boolean, theta) | ... Assume this is valid code in that constant_int is part of a datatype already declared, etc. How do I add a print statement to say 'Returning "integer"' to the case? I tried: ... constant_int _ => (print "returning integer") (integer, theta) ... But I get: stdIn:167.22-167.65 Error: operator is not a function [tycon mismatch] operator: unit in expression: (print "returning integer") (integer,theta) I think I'm just not understanding how to execute a sequence of statements, only the last of which should be treated as the return value. Any advice? Also, how would I print my own datatype value? SML didn't like when I tried to pass a datatype value into print() so I probably have to create a new print function for each datatype, is that correct?
Tags (comma-separated)
Save Edits
Cancel