fork download
  1. data Set e = Set [e] deriving Show
  2.  
  3. mySet :: Set Int
  4. mySet = Set [1, 2, 3, 4, 5]
  5.  
  6. setLength :: Set e -> Int
  7. setLength (Set s) = length s
  8.  
  9. empty :: Set e -> Bool
  10. empty (Set s) = if null s then True else False
  11.  
  12. insert :: Set e -> e -> Set e
  13. insert (Set s) value = Set $ value : s
  14.  
  15. main = print $ insert mySet 4
Success #stdin #stdout 0s 4540KB
stdin
Standard input is empty
stdout
Set [4,1,2,3,4,5]