packages feed

lists-flines (empty) → 0.1.0.0

raw patch · 5 files changed

+123/−0 lines, 5 filesdep +basesetup-changed

Dependencies added: base

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Revision history for lists-flines++## 0.1.0.0 -- 2020-10-05++* First version. Released on an unsuspecting world.
+ Data/Lists/FLines.hs view
@@ -0,0 +1,71 @@+-- |+-- Module      :  Data.Lists.FLines+-- Copyright   :  (c) OleksandrZhabenko 2020+-- License     :  MIT+-- Stability   :  Experimental+-- Maintainer  :  olexandr543@yahoo.com+--+-- Additional data and structures to some 'String'-related lists.+--++{-# LANGUAGE CPP, FlexibleInstances, MultiParamTypeClasses #-}++module Data.Lists.FLines where++#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__>=710+/* code that applies only to GHC 7.10.* and higher versions */+import GHC.Base (mconcat)+#endif+#endif+#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__==708+/* code that applies only to GHC 7.8.* */+mconcat = concat+#endif+#endif+import System.IO++-- | Auxiliary printing function to define the line ending needed to be shown and printed. Is primarily defined in the @uniqueness-periods-vector-general@ package (https://hackage.haskell.org/package/uniqueness-periods-vector-general).+newLineEnding :: String+newLineEnding+  | nativeNewline == LF = "\n"+  | otherwise = "\r\n"++data FLines a = F1 a | FL [a] deriving Eq++type Flines = FLines String++-- | Is intended to be printed and so adds the new line ending.+instance Show (FLines String) where+  show (F1 xs) = mconcat [xs, newLineEnding]+  show (FL (xs:xss)) = mconcat (xs:newLineEnding:[show (FL xss)])+  show _ = newLineEnding++class GetN a b where+  getN :: Int -> a -> Maybe b++instance GetN (FLines String) String where+  getN n (F1 xs)+    | null xs = Nothing+    | n == 1 = Just xs+    | otherwise = Nothing+  getN n (FL (xs:xss))+   | n == 1 = if null xs then Nothing else Just xs+   | compare n 1 == LT = Nothing+   | otherwise = getN (n - 1) (FL xss)+  getN _ _ = Nothing++class GetNTrans a b where+  getNT :: Int -> (b -> b) -> a -> Maybe b++instance GetNTrans (FLines String) String where+  getNT n g (F1 xs)+    | null (g xs) = Nothing+    | n == 1  = Just (g xs)+    | otherwise = Nothing+  getNT n g (FL (xs:xss))+   | n == 1 = if null (g xs) then Nothing else Just (g xs)+   | compare n 1 == LT = Nothing+   | otherwise = getNT (n - 1) g (FL xss)+  getNT _ _ _ = Nothing
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2020 OleksandrZhabenko++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ lists-flines.cabal view
@@ -0,0 +1,25 @@+-- Initial lists-flines.cabal generated by cabal init.  For further+-- documentation, see http://haskell.org/cabal/users-guide/++name:                lists-flines+version:             0.1.0.0+synopsis:            Additional data and structures to some 'String'-related lists.+description:         Is primarily used to transform some Strings read from a file.+homepage:            https://hackage.haskell.org/package/lists-flines+license:             MIT+license-file:        LICENSE+author:              OleksandrZhabenko+maintainer:          olexandr543@yahoo.com+copyright:           Oleksandr Zhabenko+category:            Data+build-type:          Simple+extra-source-files:  CHANGELOG.md+cabal-version:       >=1.10++library+  exposed-modules:     Data.Lists.FLines+  -- other-modules:+  other-extensions:    CPP, FlexibleInstances, MultiParamTypeClasses+  build-depends:       base >=4.7 && <4.15+  -- hs-source-dirs:+  default-language:    Haskell2010