KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm learning Haskell and would like to impose the use of positive integers (1,2,3, ...) in some constructors, but I only seem to find the 'Int' and 'Integer' datatypes. I could use the canonical data Nat = Zero | Succ Nat but then I couldn't use 1, 4, ... to denote them. So I ask, is there a way to accomplish this? (which is like using 'unsigned' in C) Thanks in advance. EDIT: I'm going the way of hiding it inside a module, as explained by C. A. McCann. Also, I must add the following link: http://haskell.org/haskellwiki/Smart_constructors for a summary on the subject. Thanks for taking the time to answer!
Tags (comma-separated)
Save Edits
Cancel