Skip to content

words is not a good producer; unwords is not a good consumer

I think we can do something like this, once we've fixed unfoldr:

unwords = unfoldr go
  where
    go [] = Nothing
    go ("":ws) = Just (' ', ws)
    go ((l:ls):ws) = Just (l, ls:ws)

With my draft unfoldr, GHC turns this into

lvl_r1EN
lvl_r1EN = C# ' '

Rec {
unwords_$sgo
unwords_$sgo =
  \ sc_s1Gx sc1_s1Gy ->
    case sc_s1Gx of _ {
      [] -> : lvl_r1EN (unwords_go sc1_s1Gy);
      : l_a1Ew ls_a1Ex -> : l_a1Ew (unwords_$sgo ls_a1Ex sc1_s1Gy)
    }

unwords_go
unwords_go =
  \ b1_a1Fb ->
    case b1_a1Fb of _ {
      [] -> [];
      : ds_d1F5 ws_a1Ev ->
        case ds_d1F5 of _ {
          [] -> : lvl_r1EN (unwords_go ws_a1Ev);
          : l_a1Ew ls_a1Ex -> : l_a1Ew (unwords_$sgo ls_a1Ex ws_a1Ev)
        }
    }
end Rec }

unwords
unwords = \ b'_a1F9 -> unwords_go b'_a1F9

To my untrained eye, that looks pretty reasonable.

Trac metadata
Trac field Value
Version 7.9
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited by David Feuer
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information