Skip to content

Commit c4d7386

Browse files
Merge branch 'develop-remove-ifelse' into develop. Close #150.
**Description** The dependency on `IfElse` is quite unnecessary: it seems like the only function we use from that library is `awhen :: Monad m => Maybe a -> (a -> m ()) -> m ()`, which is a type-specialized version of [`Data.Foldable.for_`.](https://hackage.haskell.org/package/base-4.20.0.1/docs/Data-Foldable.html#v:for_). Since the latter is in `base`, we can simplify Ogma by removing the dependency on `IfElse`. **Type** - Management: Reduce technical debt, in compliance with style guide. **Additional context** None. **Requester** - Ivan Perez **Method to check presence of bug** The following dockerfile checks that no cabal package depends on IfElse, in which case it prints the message "Success": ```Dockerfile FROM ubuntu:focal RUN apt-get update RUN apt-get install --yes git SHELL ["/bin/bash", "-c"] CMD git clone $REPO \ && cd $NAME \ && git checkout $COMMIT \ && ! grep -niHre 'IfElse' --include='*.cabal' ogma** \ && echo "Success" ``` Command (substitute variables based on new path after merge): ```sh $ docker run -e "REPO=https://github.com/NASA/ogma" -e "NAME=ogma" -e PAT="ogma-" -e "COMMIT=<HASH>" -it ogma-verify-150 ``` **Expected result** Running the dockerfile above prints the message "Success", indicating that IfElse is not required by any library in ogma. **Solution implemented** Replace calls to `awhen`, from IfElse, with calls to `for_`, from Data.Foldable. Remove the dependency on IfElse from all cabal files. **Further notes** None.
2 parents 62a45e8 + 0db6542 commit c4d7386

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

ogma-core/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Revision history for ogma-core
22

3+
## [1.4.X] - 2024-09-21
4+
5+
* Remove dependency on IfElse (#150).
6+
37
## [1.4.0] - 2024-05-21
48

59
* Version bump 1.4.0 (#145).

ogma-core/ogma-core.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ library
107107
, aeson >= 2.0.0.0 && < 2.2
108108
, bytestring
109109
, filepath
110-
, IfElse
111110
, mtl
112111

113112
, ogma-extra >= 1.4.0 && < 1.5

ogma-core/src/Command/FRETComponentSpec2Copilot.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ module Command.FRETComponentSpec2Copilot
4141
where
4242

4343
-- External imports
44-
import Control.Monad.IfElse ( awhen )
4544
import Data.Aeson ( eitherDecode, decode )
4645
import Data.ByteString.Lazy (fromStrict)
46+
import Data.Foldable (for_)
4747

4848
-- External imports: auxiliary
4949
import Data.ByteString.Extra as B ( safeReadFile )
@@ -91,7 +91,7 @@ fretComponentSpec2Copilot fp options = do
9191
let (mOutput, result) =
9292
fretComponentSpec2CopilotResult options fp copilot
9393

94-
awhen mOutput putStrLn
94+
for_ mOutput putStrLn
9595
return result
9696

9797
-- | Print the contents of a Copilot module that implements the Past-time TL

ogma-core/src/Command/FRETReqsDB2Copilot.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ module Command.FRETReqsDB2Copilot
3939
where
4040

4141
-- External imports
42-
import Control.Monad.IfElse ( awhen )
43-
import Data.Aeson ( eitherDecode )
44-
import Data.List ( nub, (\\) )
42+
import Data.Aeson (eitherDecode)
43+
import Data.Foldable (for_)
44+
import Data.List (nub, (\\))
4545

4646
-- External imports: auxiliary
4747
import Data.ByteString.Extra as B ( safeReadFile )
@@ -88,7 +88,7 @@ fretReqsDB2Copilot fp options = do
8888
let (mOutput, result) =
8989
fretReqsDB2CopilotResult options fp copilot
9090

91-
awhen mOutput putStrLn
91+
for_ mOutput putStrLn
9292
return result
9393

9494
-- | Print the contents of a Copilot module that implements the Past-time TL

0 commit comments

Comments
 (0)