Proposal: add `Proxy`fied versions of `bitSizeMaybe` and `finiteBitSize`

Simon Peyton Jones simonpj at microsoft.com
Thu Dec 14 10:12:03 UTC 2017


Now that we have visible type application, we could stop using these Proxy arguments, thus

	class Bits a where
 	  ...
	  bitSizeMaybe' :: Maybe Int

And you invoke it by saying
	bitSizeMaybe @ T
rather than 
	bitSizeMaybe (Proxy :: Proxy T)

Looks like a straight win to me.

Simon

|  -----Original Message-----
|  From: Libraries [mailto:libraries-bounces at haskell.org] On Behalf Of M
|  Farkas-Dyck
|  Sent: 14 December 2017 03:48
|  To: libraries at haskell.org
|  Subject: Proposal: add `Proxy`fied versions of `bitSizeMaybe` and
|  `finiteBitSize`
|  
|  I propose to add the following methods to `Bits` and `FiniteBits`
|  classes:
|  
|  class Bits a where
|       ...
|  
|       bitSizeMaybe' :: Proxy a -> Maybe Int
|  
|  class FiniteBits b where
|       ...
|  
|       finiteBitSize' :: Proxy b -> Int
|  
|  Rationale: working with an arbitrary `Bits a => a`, one may not have a
|  value of type `a` as argument to `bitSizeMaybe` or `finiteBitSize`,
|  and writing `undefined` makes me feel dirty.
|  _______________________________________________
|  Libraries mailing list
|  Libraries at haskell.org
|  https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail.h
|  askell.org%2Fcgi-
|  bin%2Fmailman%2Flistinfo%2Flibraries&data=04%7C01%7Csimonpj%40microsof
|  t.com%7Cd88222263d04465efcf608d542a6473f%7C72f988bf86f141af91ab2d7cd01
|  1db47%7C1%7C0%7C636488204282827644%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4
|  wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwifQ%3D%3D%7C-
|  1&sdata=GUcUpHRarbB8uky4m%2Fve1l3ZbtPnDIndzPM9FG5Jj44%3D&reserved=0


More information about the Libraries mailing list