Proposal: Export Data.Word.Word from Prelude

Herbert Valerio Riedel hvr at
Sat Aug 9 11:38:03 UTC 2014

Hello *,


I hereby propose to export Haskell2010's Data.Word.Word type from the Prelude


Starting with Haskell2010, "Data.Word" exporting the type 'Word', "an
unsigned integral type, with the same size as 'Int'" became part of the
Haskell Report. 

'Word' is usually a better choice than 'Int' when non-negative
quantities (such as list lengths, bit or vector indices, or number of
items in a container) need to be represented. Currently however, 'Word'
is at a disadvantage (with respect to 'Int') in terms of public exposure
by being accessible only after an "import Data.Word".

Moreover, since 'Word' is now part of the Haskell Report, libraries
should attempt to avoid name-clashing with 'Word' (and if they do, it
ought to be a conscious decision, which ought to be declared by a
requiring a "import Prelude hiding (Word)"). While one might think
'Word' would be a popular type-name to use in Haskell code, the current
level of name collision is still rather low (as is shown in the next
section), so the cost would still be bearable at this point in my

Due diligence (w.r.t. code breakage impact)

Packages depending on `haskell2010` or `haskell98` are not affected, and
neither would be those depending on `base` with a PVP-suggested upper

However, to get a rough idea how widespread the use of 'Word' as a type
on Hackage currently is, here's a simple check for current uses of
'Word' as a type-name performed with the simple heuristic search

  find  -name '*.*hs*' -exec grep \
     '\(data\|newtype\|type\)[[:space:]]\+Word[ =]' {} +

over the unpacked source trees of the latest versions of the current
6766 packages on Hackage resulted in the following 43 packages being
possibly affected (see specific source-code matches at end of email[1]):

 1   adict-0.4.1
 2   boxes-0.1.3
 3   cjk-
 4   clash-prelude-0.5.1
 5   combinat-
 6   concraft-pl-0.7.1
 7   Craft3e-
 8   crf-chain1-0.2.2
 9   crf-chain1-constrained-0.3.0
 10  crf-chain2-generic-0.3.0
 11  crf-chain2-tiers-0.2.1
 12  delta-h-0.0.3
 13  eros-
 14  estimators-0.1.4
 15  estreps-0.3.1
 16  FermatsLastMargin-0.1
 17  fsmActions-0.4.4
 18  gf-3.6
 19  happraise-0.1
 20  HAppS-Data-0.9.3
 21  happstack-contrib-0.2.1
 22  hist-pl-fusion-0.5.3
 23  Holumbus-Searchengine-1.2.3
 24  integer-pure-1.0
 25  ixset-typed-0.3
 26  language-bash-0.6.0
 27  language-sh-
 28  lhc-0.10
 29  MemoTrie-0.6.2
 30  mpppc-0.1.3
 31  nerf-0.5.2
 32  regex-deriv-0.0.4
 33  regex-pderiv-0.1.3
 34  regexpr-symbolic-0.5
 35  remote-0.1.1
 36  soyuz-0.0.0
 37  text-icu-
 38  text-register-machine-0.4.0
 39  utf8-light-0.4.2
 40  WordNet-1.1.0
 41  WordNet-ghc74-0.1.3
 42  xhaskell-library-0.0.6
 43  york-lava-0.2

Discussion period

2 weeks


 [1] More specifically, here's the output of the above mentioned `grep` command:

--8<---------------cut here---------------start------------->8---
adict-0.4.1/src/NLP/Adict/Core.hs:type Word a = V.Vector a
boxes-0.1.3/Text/PrettyPrint/Boxes.hs:data Word = Word { wLen :: Int, getWord  :: String }
cjk- Word = Word {
clash-prelude-0.5.1/src/CLaSH/Tutorial.hs:type Word = Signed 4
combinat- Word a = [Generator a] 
concraft-pl-0.7.1/src/NLP/Concraft/Polish/Morphosyntax.hs:data Word = Word
Craft3e- Word = String
Craft3e- Word = String
crf-chain1-0.2.2/Data/CRF/Chain1/Dataset/External.hs:type Word a = S.Set a
crf-chain1-constrained-0.3.0/src/Data/CRF/Chain1/Constrained/Dataset/External.hs:data Word a b = Word
crf-chain2-generic-0.3.0/Data/CRF/Chain2/Generic/External.hs:data Word a b = Word {
crf-chain2-tiers-0.2.1/src/Data/CRF/Chain2/Tiers/Dataset/External.hs:data Word a b = Word {
delta-h-0.0.3/src/EvalSem.hs:type Word = String
eros- Word         = L.Text
estimators-0.1.4/NLP/Probability/Example/Trigram.hs:newtype Word = Word T.Text 
estreps-0.3.1/src/Repeats.lhs:-- type Word = Int
FermatsLastMargin-0.1/FLM/WikiPages.hs:       newtype Word     = Word String
fsmActions-0.4.4/Data/FsmActions.hs:newtype Word sy = Word [sy]
gf-3.6/lib/src/finnish/wordnet/FreqFin.hs:type Word = String
gf-3.6/treebanks/susanne/SusanneFormat.hs:type Word  = String
gf-3.6/treebanks/talbanken/Format.hs:data Word     = W  {id :: Id, word :: String, pos :: Tag}
happraise-0.1/Main.hs:type Word = String
HAppS-Data-0.9.3/src/HAppS/Data/Atom.hs:    newtype Word = Word String
happstack-contrib-0.2.1/src/Happstack/Contrib/Atom.hs:    newtype Word = Word String
hist-pl-fusion-0.5.3/src/NLP/HistPL/Fusion.hs:type Word = T.Text
Holumbus-Searchengine-1.2.3/src/Holumbus/Index/Common/BasicTypes.hs:type Word                       = String
integer-pure-1.0/Data/Integer.hs:type Word    = Int    -- We fake the Word type, to avoid nasty conversions.
ixset-typed-0.3/src/Data/IxSet/Typed.hs:    > newtype Word = Word String
language-bash-0.6.0/src/Language/Bash/Word.hs:type Word = [Span]
language-sh- Word = [Lexeme]
lhc-0.10/lib/base/src/Data/Word.hs:type Word = Word32
lhc-0.10/lib/base/src/GHC/Word.hs:data Word = W# Word# deriving (Eq, Ord)
MemoTrie-0.6.2/src/Data/MemoTrie.hs:--     newtype Word :->: a = WordTrie ([Bool] :->: a)
mpppc-0.1.3/src/Text/PrettyPrint/MPPPC/TwoDim/Combinators/Flow.hs:data Word s t = Printable s t =>
nerf-0.5.2/src/NLP/Nerf/Types.hs:type Word = T.Text
regex-deriv-0.0.4/Text/Regex/Deriv/ByteString/BitCode.hs:type Word = S.ByteString
regex-deriv-0.0.4/Text/Regex/Deriv/ByteString/Posix.lhs:> type Word = S.ByteString
regex-pderiv-0.1.3/Text/Regex/PDeriv/ByteString/LeftToRight.lhs:> type Word = S.ByteString
regex-pderiv-0.1.3/Text/Regex/PDeriv/ByteString/LeftToRightD.lhs:> type Word = S.ByteString
regex-pderiv-0.1.3/Text/Regex/PDeriv/ByteString/Posix.lhs:> type Word = S.ByteString
regex-pderiv-0.1.3/Text/Regex/PDeriv/ByteString/RightToLeft.lhs:> type Word = S.ByteString
regex-pderiv-0.1.3/Text/Regex/PDeriv/ByteString/TwoPasses.lhs:> type Word = S.ByteString
regex-pderiv-0.1.3/Text/Regex/PDeriv/String/LeftToRightD.lhs:> type Word = String
regexpr-symbolic-0.5/RegExpr/RegExprOperations.lhs:> type Word a = [a]
remote-0.1.1/examples/tests/Test-MapReduce.hs:type Word = String
remote-0.1.1/examples/kmeans/KMeans3.hs:type Word = String
soyuz-0.0.0/DCPU16/Instructions.hs:data Word 
text-icu- Word = Uncategorized       -- ^ A \"word\" that does not fit into another
text-register-machine-0.4.0/Language/TRM/Base.hs:newtype Word = W [Letter] deriving (Eq, Monoid)
utf8-light-0.4.2/src/Codec/Binary/UTF8/Light.hs:data Word = W# Word#
WordNet-1.1.0/NLP/WordNet/Types.hs:type Word = String
WordNet-ghc74-0.1.3/NLP/WordNet/Types.hs:type Word = String
xhaskell-library-0.0.6/Text/Regex/PDeriv/ByteString/LeftToRight.lhs:> type Word = S.ByteString
xhaskell-library-0.0.6/Text/Regex/PDeriv/ByteString/Posix.lhs:> type Word = S.ByteString
xhaskell-library-0.0.6/Text/Regex/PDeriv/ByteString/RightToLeft.lhs:> type Word = S.ByteString
xhaskell-library-0.0.6/Text/Regex/PDeriv/ByteString/TwoPasses.lhs:> type Word = S.ByteString
york-lava-0.2/modules/Lava/Prelude.hs:type Word n = Vec n Bit
--8<---------------cut here---------------end--------------->8---

More information about the Libraries mailing list