diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml new file mode 100644 index 0000000..347afd2 --- /dev/null +++ b/.github/workflows/haskell.yml @@ -0,0 +1,43 @@ +name: Haskell CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-haskell@v1 + with: + ghc-version: '8.10.3' + cabal-version: '3.2' + + - name: Cache + uses: actions/cache@v3 + env: + cache-name: cache-cabal + with: + path: ~/.cabal + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install dependencies + run: | + cabal update + cabal build --only-dependencies --enable-tests --enable-benchmarks + - name: Build + run: cabal build --enable-tests --enable-benchmarks all + - name: Run tests + run: cabal test all diff --git a/CHANGELOG.md b/CHANGELOG.md index c44b63d..0b3be96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,3 +8,7 @@ * First version revised A. Added two new functions. +## 0.1.2.0 -- 2024-09-28 + +* First version revised B. Some code changes that reduce a generated stg code. + diff --git a/Data/IntermediateStructures1.hs b/Data/IntermediateStructures1.hs index 368a096..5d50cd8 100644 --- a/Data/IntermediateStructures1.hs +++ b/Data/IntermediateStructures1.hs @@ -10,7 +10,7 @@ {-# LANGUAGE NoImplicitPrelude, BangPatterns #-} {-# OPTIONS_HADDOCK -show-extensions #-} - +{-# OPTIONS_GHC -O #-} module Data.IntermediateStructures1 ( @@ -30,13 +30,21 @@ import GHC.List (concatMap) -- | Function that applies additional function @f :: a -> [a]@ to @a@ if @p :: a -> Bool@ and @p a = True@ mapI :: (a -> Bool) -> (a -> [a]) -> [a] -> [a] -mapI p f = concatMap (\x -> if p x then f x else [x]) -{-# INLINE mapI #-} +mapI p f (x:xs) = + case p x of + True -> f x `mappend` mapI p f xs + _ -> x:mapI p f xs +mapI _ _ _ = [] +{-# NOINLINE mapI #-} -- | Function that applies additional function @f :: a -> [[a]]@ to @a@ if @p :: a -> Bool@ and @p a = True@ map2I :: (a -> Bool) -> (a -> [[a]]) -> [a] -> [a] -map2I p f = mconcat . concatMap (\x -> if p x then f x else [[x]]) -{-# INLINE map2I #-} +map2I p f (x:xs) = + case p x of + True -> (mconcat . f $ x) `mappend` map2I p f xs + _ -> x : map2I p f xs +map2I _ _ _ = [] +{-# NOINLINE map2I #-} -- | Some general transformation where the arguments that are not present are calculated from the one data argument @a@ being just present. Can be used to contstruct function @a -> d@ from some additional ideas. inter :: (a -> b) -> (a -> c) -> (a -> b -> c -> d) -> a -> d diff --git a/README.md b/README.md index ce0f386..fa8976b 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,4 @@ - Devotion - ======== - -The author would like to devote this project to support the [Foundation Gastrostars](https://gastrostars.nl). - -The foundation founder is [Emma Kok](https://www.emmakok.nl). - -On the 05/01/2024 Emma starts a world tour with [André Rieu and Johann Strauss Orchestra](https://www.andrerieu.com). - -On the 06/01/2024 there are a feast of Epiphany, and Sophie's Kok, a sister of Emma, 19th Birthday (she is 18). Therefore, the version 0.1.1.0 is devoted also to her. - -Besides, you can support Ukraine and Ukrainian people. +You can support Ukraine and Ukrainian people. All support is welcome, including donations for the needs of the Ukrainian army, IDPs and refugees. -If you would like to share some financial support with Gastrostars, please, contact the mentioned foundation -using the URL: - -[Contact Foundation GASTROSTARS](https://gastrostars.nl/hou-mij-op-de-hoogte) - -or - -[Donation Page](https://gastrostars.nl/doneren) - diff --git a/intermediate-structures.cabal b/intermediate-structures.cabal index 54f7ae8..efb0dcb 100644 --- a/intermediate-structures.cabal +++ b/intermediate-structures.cabal @@ -1,6 +1,6 @@ cabal-version: 3.0 name: intermediate-structures -version: 0.1.1.0 +version: 0.1.2.0 synopsis: Some simple functions to deal with transformations from structures to other ones, basically lists. @@ -19,7 +19,6 @@ build-type: Simple extra-doc-files: CHANGELOG.md, README.md common warnings - ghc-options: -Wall library import: warnings