Skip to content

Commit 0c6acff

Browse files
Merge branch 'develop-deprecate-uTypeType'. Close #484.
**Description** The record field `uTypeType`, part of `Copilot.Core.Type.UType`, is never really used within the module or in any other part of Copilot or, as far as we know, by any user of Copilot. As a matter of fact, we cannot use it to obtain the value inside the `UType` due to the existential it encloses. It also makes the test report lower coverage than they otherwise might, since the record access function is not used by the tests. This field is not necessary parts of the interface to use Copilot, and not required by Copilot's requirements. Therefore, it would be suitable to remove that definitions from the module. As per our internal policy of waiting 3 versions from deprecation until a public interface declaration can be removed, those definitions should be deprecated. **Type** - Bug: unused code included in the implementation. **Additional context** None. **Requester** - Ivan Perez **Method to check presence of bug** The field is mentioned in the record definition, but making it a non-record datatype, or not exporting that field in the module exports, does not change the behavior and does not otherwise affect Copilot. The code compiles without errors and behaves in the same way. **Expected result** The following elements are deprecated: - `Copilot.Core.Type.UType.uTypeType` The following Dockerfile tries to import and use uTypeType, printing "Success" if the import is deprecated, and "Failure" otherwise: ``` ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update RUN apt-get install --yes libz-dev RUN apt-get install --yes git RUN apt-get install --yes wget RUN mkdir -p $HOME/.ghcup/bin RUN wget https://downloads.haskell.org/~ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 -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/ RUN apt-get install --yes curl RUN apt-get install --yes gcc g++ make libgmp3-dev RUN apt-get install --yes pkg-config SHELL ["/bin/bash", "-c"] RUN ghcup install ghc 9.8.2 RUN ghcup install cabal 3.2 RUN ghcup set ghc 9.8.2 RUN cabal update SHELL ["/bin/bash", "-c"] CMD git clone $REPO && cd $NAME && git checkout $COMMIT && cd .. \ && cabal v1-sandbox init \ && cabal v1-install $NAME/copilot-core/ \ && ! cabal v1-exec -- runhaskell -XGADTs -Wall -Werror <<< 'import Copilot.Core.Type(UType(UType, uTypeType), Type(Int8)); main :: IO (); main = case UType Int8 of; (UType { uTypeType = Int8}) -> putStrLn "Failure"' \ && 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-484 ``` **Solution implemented** Deprecate `Copilot.Core.Type.UType.uTypeType`. **Further notes** None.
2 parents d3f7f77 + 2a47663 commit 0c6acff

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

copilot-core/CHANGELOG

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
2024-10-19
1+
2024-10-28
22
* Add Haddocks for updateField. (#525)
33
* Standardize changelog format. (#550)
4+
* Deprecate Copilot.Core.Type.UType.uTypeType. (#484)
45

56
2024-09-07
67
* Version bump (4.0). (#532)

copilot-core/src/Copilot/Core/Type.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ instance (Typeable t, Typed t, KnownNat n) => Typed (Array n t) where
268268

269269
-- | A untyped type (no phantom type).
270270
data UType = forall a . Typeable a => UType { uTypeType :: Type a }
271+
{-# DEPRECATED uTypeType "This field is deprecated in Copilot 4.1. Use pattern matching instead." #-}
271272

272273
instance Eq UType where
273274
UType ty1 == UType ty2 = typeRep ty1 == typeRep ty2

0 commit comments

Comments
 (0)