Concurrent Clean : wc
先の一意型に関する便利関数を利用して、以下のように書けました。すっきり。
Start world #(console,world) = stdio world #(nl,nw,nc) = wc console = toString nl +++ " " +++ toString nw +++ " " +++ toString nc wc :: *File -> (Int, Int, Int) wc f = (\((x,y,z,_),_) = (x,y,z)) $ foldUwhile (\(nl,nw,nc,ns) c = \!!!! $ let ps = isSpace c in ( nl + if (c=='\n') 1 0 , nw + if (ns&¬ ps) 1 0 , nc + 1 , ps)) (0,0,0,True) (repeat freadc) f