Well, isLevityTy tests whether its argument is Levity But you want to test if the argument is a data constructor (e.g. Lifted, Unlifted) whose type is Levity. So you need something like isLevityCon :: Type -> Bool isLevityCon (TyConApp tc []) = isLevityTy (tyConKind tc) .. Please document both functions carefully ALSO there is a bug in isLevityTy; it is missing a coreView test. Would you like to fix this? Simon | -----Original Message----- | From: ghc-devs [mailto:ghc-devs-bounces@haskell.org] On Behalf Of Ömer | Sinan Agacan | Sent: 28 January 2016 22:49 | To: Richard Eisenberg <eir@cis.upenn.edu> | Cc: ghc-devs <ghc-devs@haskell.org> | Subject: Re: a reliable way of dropping levity args? | | I finally had some time to have another look. I have this line in my | compiler pass: | | | Just (tc, args) <- splitTyConApp_maybe ty | , isUnboxedTupleTyCon tc | = pprTrace "elimUbxSumRepTypes" | (text "orig args:" <+> ppr args $$ | text "dropWhile isLevityTy args = " <+> ppr (dropWhile | isLevityTy args)) $ | concatMap go (drop (length args `div` 2) args) | | This is one of the outputs: | | elimUbxSumRepTypes | orig args: ['Lifted, 'Lifted, 'Lifted, String, String, String] | dropWhile isLevityTy args = ['Lifted, 'Lifted, 'Lifted, String, | String, String] | | Am I doing this wrong? | | 2016-01-25 7:30 GMT-05:00 Richard Eisenberg <eir@cis.upenn.edu>: | > As discussed on IRC, your approach below looks right to me: dropWhile | (isLevityTy . idType) args. But you then said this wasn't working for | you. What does (map idType args) say? | > | > Richard | > | > On Jan 24, 2016, at 8:58 PM, Ömer Sinan Ağacan <omeragacan@gmail.com> | wrote: | > | >> Hi all, | >> | >> I'm looking for a reliable way of dropping levity args from TyCon | applications. | >> When I know that a particular TyCon gets some number of levity args, | >> I can just drop the args manually (for example, I can drop the first | >> half of arguments of a tuple TyCon application) but the code looks | >> fragile (what happens if I use a different TyCon in the future) and | >> confusing to the reader because it looks like this: | >> | >> drop (length args `div` 2) args | >> | >> Ideally it'd look like this: | >> | >> dropWhile isLevityArg args | >> | >> Now, there's a function called isLevityTy, but I don't understand | >> what it's supposed to do. This doesn't do anyting to 'Boxed and | 'Unboxed arguments: | >> | >> dropWhile (isLevityArg . idType) args | >> | >> Any ideas on this? | >> | >> Thanks.. | > | _______________________________________________ | ghc-devs mailing list | ghc-devs@haskell.org | https://na01.safelinks.protection.outlook.com/?url=http%3a%2f%2fmail.ha | skell.org%2fcgi-bin%2fmailman%2flistinfo%2fghc- | devs%0a&data=01%7c01%7csimonpj%40064d.mgd.microsoft.com%7c60501578c8024 | 97bb4a208d328354eff%7c72f988bf86f141af91ab2d7cd011db47%7c1&sdata=2%2fOf | nL4IPh41UZLx2XskQF%2fTf6kSA%2bP%2bXmn3r346kiI%3d