29 Nov 2012 09:27
Computing the final representation type of a TyCon (Was: Unpack primitive types by default in data)
Johan Tibell <johan.tibell <at> gmail.com>
2012-11-29 08:27:39 GMT
2012-11-29 08:27:39 GMT
Hi all,
I've decided to try to implement the proposal included in the end of
this message. To do so I need to write a function
hasPointerSizedRepr :: TyCon -> Bool
This function would check that that the TyCon is either
* a newtype, which representation type has a pointer-sized representation, or
* an algebraic data type, with one field that has a pointer-sized
representation.
I'm kinda lost in all the data types that GHC defines to represent
types. I've gotten no further than
hasPointerSizedRepr :: TyCon -> Bool
hasPointerSizedRepr tc <at> (AlgTyCon {}) = case algTcRhs tc of
DataTyCon{ data_cons = [data_con] }
-> ...
NewTyCon { data_con = [data_con] }
-> ...
_ -> False
hasPointerSizedRepr _ = False
I could use some pointers (no pun intended!) at this point. The
function ought to return True for all the following types:
data A = A Int#
newtype B = B A
(Continue reading)
RSS Feed