ucd (empty) → 0.0.0.0
raw patch · 8 files changed
+200/−0 lines, 8 filesdep +basedep +gaugedep +ucdbuild-type:Customsetup-changed
Dependencies added: base, gauge, ucd, util
Files
- CHANGELOG.md +11/−0
- LICENSE +29/−0
- README.md +7/−0
- Setup.hs +50/−0
- bench/Main.hs +7/−0
- src/Data/Char/Properties.hs +3/−0
- test/Spec.hs +4/−0
- ucd.cabal +89/−0
+ CHANGELOG.md view
@@ -0,0 +1,11 @@+# Changelog++`ucd.hs` uses [PVP Versioning][1].+The changelog is available [on GitHub][2].++## 0.0.0.0++* Initially created.++[1]: https://pvp.haskell.org+[2]: https://github.com/strake/ucd.hs/releases
+ LICENSE view
@@ -0,0 +1,29 @@+BSD 3-Clause License++Copyright (c) 2019, M Farkas-Dyck+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this+ list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright notice,+ this list of conditions and the following disclaimer in the documentation+ and/or other materials provided with the distribution.++3. Neither the name of the copyright holder nor the names of its+ contributors may be used to endorse or promote products derived from+ this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,7 @@+# ucd.hs++[](https://travis-ci.org/strake/ucd.hs)+[](https://hackage.haskell.org/package/ucd.hs)+[](LICENSE)++See README for more info
+ Setup.hs view
@@ -0,0 +1,50 @@+{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable #-}+{-# LANGUAGE OverloadedStrings #-}+module Main where++import Control.Applicative+import Control.Monad (join)+import Data.Char+import Data.Foldable+import Data.List (dropWhileEnd, intercalate)+import Data.Map (Map)+import qualified Data.Map as Map+import Text.Regex.Applicative (RE)+import qualified Text.Regex.Applicative as RE+import qualified Text.Regex.Applicative.Common as RE+import Util hiding (intercalate)++import Distribution.Simple+import Distribution.Simple.PreProcess++main = defaultMainWithHooks simpleUserHooks+ { hookedPreProcessors = ("ucd-derived-core-properties", \ _ _ _ -> PreProcessor+ { platformIndependent = True+ , runPreProcessor = mkSimplePreProcessor $ \ inFile outFile _verbosity ->+ readFile inFile >>=+ writeFile outFile .+ ("module Data.Char.Properties.DerivedCore where\n" ++) .+ maybe (error "bad format") generate . parseProps+ }) : hookedPreProcessors simpleUserHooks+ }++data Range a = Range a a+ deriving (Foldable, Functor, Traversable)++rangeRE :: RE Char (Range Int)+rangeRE = join Range <$> n <|> Range <$> n <* ".." <*> n where n = RE.hexadecimal++lineRE :: RE Char ([Char], Range Char)+lineRE = flip ((,) . filter (/= '_')) . fmap toEnum <$> rangeRE <* many (RE.psym isSpace) <* "; " <*> many (RE.psym (liftA2 (||) isAlphaNum (== '_')))++generate :: Map [Char] [Range Char] -> [Char]+generate = unlines . ((:) <$> generateTypes . Map.keys <*> generateCode)++generateTypes :: [[Char]] -> [Char]+generateTypes names = intercalate ", " (("is" ++) <$> names) ++ " :: Char -> Bool"++generateCode :: Map [Char] [Range Char] -> [[Char]]+generateCode = toList . Map.mapWithKey (\ name ranges -> asum ["is", name, " x = ", intercalate " || " [asum ["x >= ", show a, " && x <= ", show b] | Range a b <- ranges]])++parseProps :: [Char] -> Maybe (Map [Char] [Range Char])+parseProps = lines & fmap (takeWhile (/= '#') & dropWhileEnd isSpace) & filter (not . null) & traverse (RE.match lineRE) & fmap ((fmap . fmap) pure & Map.fromListWith (flip (++)))
+ bench/Main.hs view
@@ -0,0 +1,7 @@+module Main (main) where++import Gauge.Main+++main :: IO ()+main = defaultMain [bench "const" (whnf const ())]
+ src/Data/Char/Properties.hs view
@@ -0,0 +1,3 @@+module Data.Char.Properties (module A) where++import Data.Char.Properties.DerivedCore as A
+ test/Spec.hs view
@@ -0,0 +1,4 @@+module Main (main) where++main :: IO ()+main = putStrLn ("Test suite not yet implemented" :: String)
+ ucd.cabal view
@@ -0,0 +1,89 @@+cabal-version: 2.2+name: ucd+version: 0.0.0.0+synopsis: See README for more info+description: See README for more info+homepage: https://github.com/strake/ucd.hs+bug-reports: https://github.com/strake/ucd.hs/issues+license: BSD-3-Clause+license-file: LICENSE+author: M Farkas-Dyck+maintainer: strake888@gmail.com+copyright: 2019 M Farkas-Dyck+category: Data,Text+build-type: Custom+extra-doc-files: README.md+ , CHANGELOG.md+tested-with: GHC == 8.4.4+ GHC == 8.6.5+ GHC == 8.8.1++common c+ build-depends: base ^>= 4.11 || ^>= 4.12 || ^>= 4.13+ , util ^>= 0.1.14+ ghc-options: -Wall+ -Wcompat+ -Wredundant-constraints+ -Wno-name-shadowing+ -Wincomplete-uni-patterns+ -Wincomplete-record-updates+ -Werror=incomplete-patterns+ -Werror=incomplete-uni-patterns+ -Werror=incomplete-record-updates+ -Werror=missing-fields+ -Werror=missing-methods+ default-language: Haskell2010+ default-extensions: UnicodeSyntax+ LambdaCase+ EmptyCase+ InstanceSigs+ PartialTypeSignatures+ PolyKinds+ ConstraintKinds+ FlexibleContexts+ FlexibleInstances+ MonadComprehensions+ StandaloneDeriving+ DeriveFunctor+ DeriveFoldable+ DeriveTraversable++library+ import: c+ hs-source-dirs: src+ exposed-modules: Data.Char.Properties+ Data.Char.Properties.DerivedCore+ autogen-modules: Data.Char.Properties.DerivedCore+ build-depends:++test-suite test+ import: c+ type: exitcode-stdio-1.0+ hs-source-dirs: test+ main-is: Spec.hs+ build-depends: ucd+ ghc-options: -threaded+ -rtsopts+ -with-rtsopts=-N++benchmark bench+ import: c+ type: exitcode-stdio-1.0+ hs-source-dirs: bench+ main-is: Main.hs+ build-depends: gauge+ , ucd+ ghc-options: -threaded+ -rtsopts+ -with-rtsopts=-N++custom-setup+ setup-depends: Cabal ^>= 3.0+ , base ^>= 4.11 || ^>= 4.12 || ^>= 4.13+ , containers ^>= 0.5 || ^>= 0.6+ , regex-applicative ^>= 0.3.3+ , util ^>= 0.1.14++source-repository head+ type: git+ location: https://github.com/strake/ucd.hs.git