Skip to content

Commit fbe9d59

Browse files
Merge branch 'develop-remove-deprecatedType'. Close #500.
**Description** The functions `Copilot.Core.Type.typename`, `Copilot.Core.Type.tylength`, `Copilot.Core.Type.tysize`, `Copilot.Core.Type.fieldname`, `Copilot.Core.Type.accessorname` and `Copilot.Core.Type.Array.arrayelems` are not being used by any other part of Copilot. They were replaced by functions with similar names in lowerCamelCase format. The original functions were deprecated in Copilot 3.17 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** - Bug: unused code included in the implementation. **Additional context** - Issue #457, addressed in Copilot 3.17, deprecated the functions. **Requester** - Ivan Perez **Method to check presence of bug** There is no easy, forward-compatible, automated way of detecting that the functions are present and also deprecated. Manual inspection is recommended. At present, they are the only deprecated functions in `copilot-core`, so their presence can be found with: ```sh $ grep -nHre 'DEPRECATED' src/ src/Copilot/Core/Type.hs:58:-- {-# DEPRECATED typename "Use typeName instead." #-} src/Copilot/Core/Type.hs:85:-- {-# DEPRECATED fieldname "Use fieldName instead." #-} src/Copilot/Core/Type.hs:96:-- {-# DEPRECATED accessorname "Use accessorName instead." #-} src/Copilot/Core/Type.hs:139:-- {-# DEPRECATED tylength "Use typeLength instead." #-} src/Copilot/Core/Type.hs:149:-- {-# DEPRECATED tysize "Use typeSize instead." #-} src/Copilot/Core/Type/Array.hs:47:{-# DEPRECATED arrayelems "Use ArrayElems instead." #-} ``` **Expected result** The strings returned by the command above should be empty (nothing is deprecated). **Solution implemented** Remove the deprecated functions from `Copilot.Core.Type` and `Copilot.Core.Type.Array`. **Further notes** None.
2 parents 835deaf + 975c6d0 commit fbe9d59

File tree

3 files changed

+4
-40
lines changed

3 files changed

+4
-40
lines changed

copilot-core/CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2024-03-07
2+
* Remove deprecated functions in Copilot.Core.Type and
3+
Copilot.Core.Type.Array. (#500)
4+
15
2024-01-07
26
* Version bump (3.18.1). (#493)
37

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

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,16 @@ module Copilot.Core.Type
2424
, SimpleType (..)
2525

2626
, typeSize
27-
, tysize
2827
, typeLength
29-
, tylength
3028

3129
, Value (..)
3230
, toValues
3331
, Field (..)
3432
, typeName
35-
, typename
3633

3734
, Struct
3835
, fieldName
39-
, fieldname
4036
, accessorName
41-
, accessorname
4237
)
4338
where
4439

@@ -55,18 +50,11 @@ import GHC.TypeLits (KnownNat, KnownSymbol, Symbol, natVal, sameNat,
5550
-- Internal imports
5651
import Copilot.Core.Type.Array (Array)
5752

58-
{-# DEPRECATED typename "Use typeName instead." #-}
59-
6053
-- | The value of that is a product or struct, defined as a constructor with
6154
-- several fields.
6255
class Struct a where
6356
-- | Returns the name of struct in the target language.
6457
typeName :: a -> String
65-
typeName = typename
66-
67-
-- | Returns the name of struct in the target language.
68-
typename :: a -> String
69-
typename = typeName
7058

7159
-- | Transforms all the struct's fields into a list of values.
7260
toValues :: a -> [Value a]
@@ -83,24 +71,12 @@ data Field (s :: Symbol) t = Field t
8371
fieldName :: forall s t . KnownSymbol s => Field s t -> String
8472
fieldName _ = symbolVal (Proxy :: Proxy s)
8573

86-
{-# DEPRECATED fieldname "Use fieldName instead." #-}
87-
-- | Extract the name of a field.
88-
fieldname :: forall s t . KnownSymbol s => Field s t -> String
89-
fieldname = fieldName
90-
9174
-- | Extract the name of an accessor (a function that returns a field of a
9275
-- struct).
9376
accessorName :: forall a s t . (Struct a, KnownSymbol s)
9477
=> (a -> Field s t) -> String
9578
accessorName _ = symbolVal (Proxy :: Proxy s)
9679

97-
{-# DEPRECATED accessorname "Use accessorName instead." #-}
98-
-- | Extract the name of an accessor (a function that returns a field of a
99-
-- struct).
100-
accessorname :: forall a s t . (Struct a, KnownSymbol s)
101-
=> (a -> Field s t) -> String
102-
accessorname = accessorName
103-
10480
instance (KnownSymbol s, Show t) => Show (Field s t) where
10581
show f@(Field v) = fieldName f ++ ":" ++ show v
10682

@@ -137,21 +113,11 @@ data Type :: * -> * where
137113
typeLength :: forall n t . KnownNat n => Type (Array n t) -> Int
138114
typeLength _ = fromIntegral $ natVal (Proxy :: Proxy n)
139115

140-
{-# DEPRECATED tylength "Use typeLength instead." #-}
141-
-- | Return the length of an array from its type
142-
tylength :: forall n t . KnownNat n => Type (Array n t) -> Int
143-
tylength = typeLength
144-
145116
-- | Return the total (nested) size of an array from its type
146117
typeSize :: forall n t . KnownNat n => Type (Array n t) -> Int
147118
typeSize ty@(Array ty'@(Array _)) = typeLength ty * typeSize ty'
148119
typeSize ty@(Array _ ) = typeLength ty
149120

150-
{-# DEPRECATED tysize "Use typeSize instead." #-}
151-
-- | Return the total (nested) size of an array from its type
152-
tysize :: forall n t . KnownNat n => Type (Array n t) -> Int
153-
tysize = typeSize
154-
155121
instance TestEquality Type where
156122
testEquality Bool Bool = Just DE.Refl
157123
testEquality Int8 Int8 = Just DE.Refl

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module Copilot.Core.Type.Array
1414
( Array
1515
, array
1616
, arrayElems
17-
, arrayelems
1817
)
1918
where
2019

@@ -43,8 +42,3 @@ array xs | datalen == typelen = Array xs
4342
-- | Return the elements of an array.
4443
arrayElems :: Array n a -> [a]
4544
arrayElems (Array xs) = xs
46-
47-
{-# DEPRECATED arrayelems "Use ArrayElems instead." #-}
48-
-- | Return the elemts of an array.
49-
arrayelems :: Array n a -> [a]
50-
arrayelems = arrayElems

0 commit comments

Comments
 (0)