Changes between Initial Version and Version 12 of Ticket #4116


Ignore:
Timestamp:
Jun 13, 2010 2:14:22 PM (4 years ago)
Author:
igloo
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #4116

    • Property Cc ozgurakgun@… griba2001@… added
    • Property Version changed from 6.13 to
  • Ticket #4116 – Description

    initial v12  
    1313* Actual system: undefined cases are discriminated with runtime errors or  
    1414exception throwing or optional Maybe results. 
    15  
     15{{{ 
    1616   hd :: List a -> a 
    1717   hd (Cons x _) -> x 
    1818   hd Nil -> error "error: hd: empty list" -- (as in GHC Data.List head) 
    19  
     19}}} 
    2020* Proposed system: supplement types with  
    2121     a suffix ''@Constructor'' or ''@{Constructor1, Constructor2}'' 
    2222 
    2323denoting the list of constructors to which the function can be applied. 
    24  
     24{{{ 
    2525   hd :: List @Cons a -> a 
    2626   hd (Cons x _) = x 
    2727 
    2828   -- no definition for unappropriate constructors. 
    29  
     29}}} 
    3030The caller must do pattern matching before applying the constructor-specific function. 
    3131 
     
    3838 
    3939using it: 
    40  
     40{{{ 
    4141   accumulateHead :: (a->b) -> a -> List a -> b 
    4242 
     
    5353 
    5454        _ -> accum       -- default option closing pattern matching exhaustivity. 
    55  
     55}}} 
    5656(from Jason Dagit contribution)  
    5757 
    5858Syntax ''{Cons, Cons2}'' for more than one constructor  
    59  
     59{{{ 
    6060  data List2 a = Nil | Cons a (List2 a) | Cons2 a a (List2 a) 
    6161 
    6262hd :: List2 @ {Cons, Cons2} a -> a 
    63  
     63}}} 
    6464Discussion thread: 
    6565