Skip to content

Commit 4e22d07

Browse files
Merge branch 'develop-deprecate-arrayAccess'. Close #599.
**Description** The functions `copilot-language:Copilot.Language.Operators.Array.(.!!)` and `copilot-libraries:Copilot.Library.Utils.(!!)` were deprecated due to the introduction of a new, common interface to interact with structures and arrays. The original functions were deprecated in Copilot 4 and no messages have been received requesting that they be kept in this library. As per our internal policy of waiting 3 versions from deprecation until a public interface declaration can be removed, these functions can now be removed. **Type** - Management: remove code deprecated by the introduction of a new feature. **Additional context** - Issue #36, addressed in Copilot 4, deprecated the functions. **Requester** - Ivan Perez **Method to check presence of bug** Not applicable (not a bug). **Expected result** Running either of the checks above prints a message indicating that the functions imported do not exist. Running either of the checks above prints a message indicating that the functions imported do not exist. Either of the following should trigger errors: ``` $ runhaskell <<< 'import Copilot.Language.Operators.Array((.!!)); main = return ()' $ runhaskell <<< 'import Copilot.Library.Utils ((!!)); main = return ()' ``` The following Dockerfile tries to import the deprecated functions, succeeding only when the import fails, after which prints the message "Success": ``` FROM ubuntu:focal ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update RUN apt-get install --yes \ libz-dev \ git \ curl \ gcc \ g++ \ make \ libgmp3-dev \ pkg-config \ z3 RUN mkdir -p $HOME/.ghcup/bin RUN curl https://downloads.haskell.org/~ghcup/0.1.40.0/x86_64-linux-ghcup-0.1.40.0 -o $HOME/.ghcup/bin/ghcup RUN chmod a+x $HOME/.ghcup/bin/ghcup ENV PATH=$PATH:/root/.ghcup/bin/ ENV PATH=$PATH:/root/.cabal/bin/ SHELL ["/bin/bash", "-c"] RUN ghcup install ghc 9.10.1 RUN ghcup install cabal 3.2 RUN ghcup set ghc 9.10.1 RUN cabal update SHELL ["/bin/bash", "-c"] CMD git clone $REPO && cd $NAME && git checkout $COMMIT && cd .. \ && cabal v1-sandbox init \ && cabal v1-install alex happy --constraint='happy <= 2' \ && cabal v1-install $NAME/copilot**/ \ && ! cabal v1-exec -- runhaskell <<< 'import Copilot.Language.Operators.Array((.!!)); main = return ()' \ && ! cabal v1-exec -- runhaskell <<< 'import Copilot.Library.Utils ((!!)); main = return ()' \ && echo "Success" ``` Command (substitute variables based on new path after merge): ``` $ docker run -e "REPO=https://github.com/Copilot-Language/copilot" -e "NAME=copilot" -e "COMMIT=<HASH>" -it copilot-verify-599 ``` **Solution implemented** Remove the deprecated functions `copilot-language:Copilot.Language.Operators.Array.(.!!)` and `copilot-libraries:Copilot.Library.Utils.(!!)` , and any references to them. **Further notes** None.
2 parents ca626c0 + 7d22a1b commit 4e22d07

File tree

5 files changed

+10
-25
lines changed

5 files changed

+10
-25
lines changed

copilot-language/CHANGELOG

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
2025-02-28
1+
2025-03-07
22
* Fix typo in documentation. (#587)
33
* Record how a Property's underlying proposition is quantified. (#254)
4+
* Remove deprecated function Copilot.Language.Operators.Array.(.!!).
5+
(#599)
46

57
2025-01-07
68
* Version bump (4.2). (#577)

copilot-language/src/Copilot/Language/Operators/Array.hs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
-- | Combinators to deal with streams carrying arrays.
1010
module Copilot.Language.Operators.Array
11-
( (.!!)
12-
, (!)
11+
( (!)
1312
, (!!)
1413
, (=:)
1514
, (=$)
@@ -34,18 +33,6 @@ import Prelude hiding ((!!))
3433
=> Stream (Array n t) -> Stream Word32 -> Stream t
3534
arr ! n = Op2 (Index typeOf) arr n
3635

37-
-- | Create a stream that carries an element of an array in another stream.
38-
--
39-
-- This function implements a projection of the element of an array at a given
40-
-- position, over time. For example, if @s@ is a stream of type @Stream (Array
41-
-- '5 Word8)@, then @s .!! 3@ has type @Stream Word8@ and contains the 3rd
42-
-- element (starting from zero) of the arrays in @s@ at any point in time.
43-
{-# DEPRECATED (.!!) "This function is deprecated in Copilot 4. Use (!)." #-}
44-
(.!!) :: ( KnownNat n
45-
, Typed t
46-
) => Stream (Array n t) -> Stream Word32 -> Stream t
47-
(.!!) = (!)
48-
4936
-- | Pair a stream with an element accessor, without applying it to obtain the
5037
-- value of the element.
5138
--

copilot-libraries/CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2025-03-07
2+
* Remove deprecated function Copilot.Library.Utils.(!!). (#599)
3+
14
2025-01-07
25
* Version bump (4.2). (#577)
36
* Bump upper version constraint on containers. (#570)

copilot-libraries/src/Copilot/Library/Libraries.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ import Copilot.Library.LTL
2323
import Copilot.Library.PTLTL
2424
import Copilot.Library.Statistics
2525
import Copilot.Library.RegExp
26-
import Copilot.Library.Utils hiding ((!!))
26+
import Copilot.Library.Utils
2727
import Copilot.Library.Voting
2828
import Copilot.Library.Stacks

copilot-libraries/src/Copilot/Library/Utils.hs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ module Copilot.Library.Utils
1313
-- ** Scans
1414
nscanl, nscanr, nscanl1, nscanr1,
1515
-- ** Indexing
16-
case', (!!), (!!!))
16+
case', (!!!))
1717
where
1818

19-
import Copilot.Language hiding ((!!))
19+
import Copilot.Language
2020
import qualified Prelude as P
2121

2222
-- | Given a stream, produce an infinite list of streams dropping an increasing
@@ -131,13 +131,6 @@ case' predicates alternatives =
131131
P.++ "greater by one than the length of predicates list"
132132
in case'' predicates alternatives
133133

134-
-- | Index.
135-
--
136-
-- WARNING: Very expensive! Consider using this only for very short lists.
137-
(!!) :: (Typed a, Eq b, Num b, Typed b) => [Stream a] -> Stream b -> Stream a
138-
(!!) = (!!!)
139-
{-# DEPRECATED (!!) "This function is deprecated in Copilot 4. Use (!!!)." #-}
140-
141134
-- | Index.
142135
--
143136
-- WARNING: Very expensive! Consider using this only for very short lists.

0 commit comments

Comments
 (0)