unicode-data
unicode-data copied to clipboard
Don't enforce compatibility with `base`
trafficstars
Being compatible with base is NOT required. This is not the responsibility of
the library. Enforcing compatibility also gives an incorrect idea on the
dependency graph. We use functions in base, not the unicode primitives. Hence
it would be incorrect to constraint base depending on the unicode version.
The best case solution is to let base depend unicode-data and
friends. Although, this is not a straightforward task.
The compatibility with the base primitives is a domain specific problem. The
overhead of the check should be pushed to the user. The user may choose to force
compatibility depending on how unicode is being used. The following snippet
checks for compatibility and fails accordingly:
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}
import qualified Unicode.Char as UnicodeData (unicodeVersion)
import qualified GHC.Unicode as Base (unicodeVersion)
unicodeCompatibility :: ()
unicodeCompatibility =
$(if Base.unicodeVersion == UnicodeData.unicodeVersion
then [|()|]
else error $ "Incompatible unicode versions: "
++ "base: " ++ show Base.unicodeVersion ++ " "
++ "unicode-data: " ++ show UnicodeData.unicodeVersion)