[SOLVED] Help! rio-0.1.22.0 to 0.1.23.0 problem

Not much of substance happened between rio-0.1.22.0 and rio-0.1.23.0:

but it seems to have provoked something odd:

In the second example, the stack executable built against rio-0.1.23.0 (and literally no other changes anywhere) halts (after a little while) with GHC RTS message <<loop>> at runtime.

I have been looking hard at what code changed between rio-0.1.22.0 and rio-0.1.23.0 and can’t figure out what can be the cause. There are two commits that may be of particular interest:

The accepting of the few HLint v3.10 hints was not done blindly, at the time. The ones I had to think most about were:

return $! Just x

can be replaced by:

return (Just x)

Any suggestions, gratefully received!

I have found the culprit. It is HLint’s suggestion to change:

instance Monoid Utf8Builder where
  mempty = Utf8Builder mempty
  {-# INLINE mempty #-}
  mappend = (Data.Semigroup.<>)
  {-# INLINE mappend #-}
  mconcat = foldr mappend mempty
  {-# INLINE mconcat #-}

to

instance Monoid Utf8Builder where
  mempty = Utf8Builder mempty
  {-# INLINE mempty #-}
  mappend = (Data.Semigroup.<>)
  {-# INLINE mappend #-}
  mconcat = fold
  {-# INLINE mconcat #-}

I still need to work out why …

2 Likes

fold for lists is defined as mconcat.

2 Likes

Just skip the definition of mconcat altogether?..

1 Like

Thanks! I’ll fix rio now …

Thanks! Am I correct to think that the definition for mappend could also be dropped, given the default for the Monoid class:

class Semigroup a => Monoid a where
        mempty :: a
        mempty = mconcat []
        {-# INLINE mempty #-}

        mappend :: a -> a -> a
        mappend = (<>)
        {-# INLINE mappend #-}

        mconcat :: [a] -> a
        mconcat = foldr mappend mempty
        {-# INLINE mconcat #-}

Yes, unless you need to support ancient GHCs from the times when Semigroup was not a superclass of Monoid (which means base < 4.11 and GHC < 8.4).

1 Like

rio is base >= 4.12, but {-# INLINE mconcat #-} was not added to the default until base-4.16.0.0. I assume that matters, otherwise it would not have been added.

I doubt it matters much to bother; the fraction of users of GHC 9.0 and earlier is very small by now.

3 Likes

Are the usage statistics somewhere?

1 Like

I hope this is not a spoiler, but the Haskell Foundation is currently preparing for a 2025 State of Haskell Survey that should shed light on the question of usage.

4 Likes

Per GHC version? Self reported or some proxy like downloads of a version of base?

To allow for time series and trend analyses, I think the plan is that most 2025 questions will be similar to those in earlier years, albeit options in answers updated for obvious changes in the environment (for example, the increasing market share of AArch64 machine architecture). Past surveys are discussed here:

1 Like