Skip to content

Commit

Permalink
Fix inconsistent TypeRep ordering on GHC 9.8
Browse files Browse the repository at this point in the history
... in relation to GHC <= 9.6
  • Loading branch information
rudymatela committed Jan 22, 2024
1 parent 8eff7d9 commit bac46de
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Data/Express/Utils/Typeable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,27 @@ compareTy t1 t2 = tyArity t1 `compare` tyArity t2
-- > > showTyCon listTyCon
-- > "[]"
--
-- On GHC <= 9.6:
--
-- > > show unitTyCon
-- > "()"
--
-- On GHC >= 9.8:
--
-- > > show unitTyCon
-- > "Unit"
--
-- On all GHCs:
--
-- > > showTyCon unitTyCon
-- > "()"
--
-- Further exceptions to `show :: TyCon -> String` may be added here
-- on future versions.
showTyCon :: TyCon -> String
showTyCon con
| con == listTyCon = "[]"
| con == unitTyCon = "()"
| otherwise = show con

-- | Returns the functional arity of the given 'TypeRep'.
Expand Down Expand Up @@ -187,6 +203,10 @@ funTyCon = typeRepTyCon $ typeOf (undefined :: () -> ())
listTyCon :: TyCon
listTyCon = typeRepTyCon $ typeOf (undefined :: [()])

-- | The unit type constructor as a 'TyCon'
unitTyCon :: TyCon
unitTyCon = typeRepTyCon $ typeOf (undefined :: ())

-- | Returns whether a 'TypeRep' is functional.
--
-- > > isFunTy $ typeOf (undefined :: Int -> Int)
Expand Down

0 comments on commit bac46de

Please sign in to comment.