rudymatela / express

Dynamically-typed Haskell expressions involving applications and variables.
Other
22 stars 2 forks source link

Tests fail with ghc 9.6 on stackage nightly #2

Closed alaendle closed 1 year ago

alaendle commented 1 year ago

Tests fail reproducible on every build. Add to expected test failures for now.

express  > test (suite: utils)

*** Failed tests:[22]

express  > Test suite utils failed
rudymatela commented 1 year ago

@alaendle Thanks for reporting.

This has been fixed as of express 1.0.12: 82607ee467cb1961a87035abaa20601cab26d1f8

Express + GHC 9.6 work on CI: https://github.com/rudymatela/express/tree/v1.0.12 / https://github.com/rudymatela/express/actions/runs/5476903152

For my on future reference, here are the details of the bug

Details

The following test was failing on GHC 9.6:

-- showTypesInTypeOf (u :: Either String Bool -> Maybe Int -> Int -> Bool)
map show . typesIn . typeOf (undefined :: Either String Bool -> Maybe Int -> Int -> Bool)
    == [ "Bool"
       , "Char"
       , "Int"
       , "Maybe Int"
       , "[Char]"
       , "Either [Char] Bool"
       , "Int -> Bool"
       , "Maybe Int -> Int -> Bool"
       , "Either [Char] Bool -> Maybe Int -> Int -> Bool"
       ]

Here's what happens on GHC 9.0:

> map show . typesIn . typeOf (undefined :: String -> Maybe Int)
[ "Char"
, "Int"
, "Maybe Int"
, "[Char]"
, "[Char] -> Maybe Int"
]

Here's what happens on GHC 9.6:

> map show . typesIn . typeOf (undefined :: String -> Maybe Int)
[ "Char"
, "Int"
, "[Char]"
, "Maybe Int"
, "[Char] -> Maybe Int"
]

The types [Char] and Maybe Int are reported in a different order!

This relates to the function compareTy from Data.Express.Utils.Typeable which is a (tentative) consistent replacement to compare :: TypeRep -> ... over different GHC versions (this was important to some of my research). It became inconsistent with the new GHC.

-- with
> let string = typeOf (undefined :: String)
> let mint = typeOf (undefined :: Maybe Int)

-- on GHC <= 9.4
> compareTy string mint
GT

-- on GHC == 9.6
> compareTy string mint
LT

The issue is related to showing the list TyCon ([]) which changed to being stringified as [] to List.

On GHCs 9.0, 9.2, 9.4:

> splitTyConApp $ typeOf (undefined :: String)
([],[Char])

On GHC 9.6:

> splitTyConApp $ typeOf (undefined :: String)
(List,[Char])

The function compareTy is now amended considering this caveat and now consistent for all GHCs <= 9.6 and hopefully most future versions. This was fixed on commit 82607ee467cb1961a87035abaa20601cab26d1f8