Changes between Version 13 and Version 14 of PolymorphicComponents
- Timestamp:
- 01/19/07 16:03:18 (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
PolymorphicComponents
v13 v14 40 40 }}} 41 41 1. hugs vs. ghc treatment as keyword (see below) 42 1. design choice: only wildcard & variables required in patterns (ghc allows as-patterns, hugs doesn't) allowed for polymorphic fields42 1. design choice: only wildcard & variables are allowed when pattern matching on polymorphic components (ghc allows as-patterns, hugs doesn't) 43 43 44 44 == Tickets == … … 77 77 | C2 { x :: forall a. (Eq a,Show a) => a -> a } 78 78 }}} 79 1. ''note'' when you pattern-match on a field w/ a polymorphic type, the bound variables also have a polymorphic type80 1. but case is different;it instantiates the forall to a monomorphic type as below:79 1. ''note'' you can name polymorphic components (see design choice above) 80 1. when you match on ''x'' it instantiates the forall to a monomorphic type as below: 81 81 {{{ 82 82 data S = C (forall a. [a]) … … 90 90 f (C []) = True 91 91 }}} 92 1. desugaring... 93 {{{ 94 f (C []) = e1 -- illegal 95 }}} 96 would desugar to 97 {{{ 98 f x = case x of 99 C [] -> e 1 -- illegal 100 _ -> error ... 101 }}} 102 would desugar to 103 {{{ 104 case x of 105 C y -> case y of -- NOT illegal 106 [] -> e1 107 _ -> error... 108 _ -> error... 109 110 }}} 111 which is a little funny. 112 1. where is explanation of type checking... 113 1. where to put the bangs in strict polymorphic fields, hugs and GHC differ - can't figure it out in Hugs
