Skip to content

Commit

Permalink
Changed code to reduce generated stg code
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr-Zhabenko committed Sep 28, 2024
1 parent aa37ef0 commit c6d7860
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 28 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

18 changes: 13 additions & 5 deletions Data/IntermediateStructures1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

{-# LANGUAGE NoImplicitPrelude, BangPatterns #-}
{-# OPTIONS_HADDOCK -show-extensions #-}

{-# OPTIONS_GHC -O #-}

module Data.IntermediateStructures1
(
Expand All @@ -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
Expand Down
22 changes: 1 addition & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

3 changes: 1 addition & 2 deletions intermediate-structures.cabal
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -19,7 +19,6 @@ build-type: Simple
extra-doc-files: CHANGELOG.md, README.md

common warnings
ghc-options: -Wall

library
import: warnings
Expand Down

0 comments on commit c6d7860

Please sign in to comment.