Sometimes when I want to explain that a list is just a parameterized data structure, I want to avoid writing
[a], is there a way to use the word
List in a type definition:
For example, instead of
filter : (a -> Bool) -> [a] -> [a]
filter : (a -> Bool) -> List a -> List a
I get a scary warning about imports when I try the above.
The warning isn’t all that scary:
In the use of type constructor or class ‘List’
(imported from Prelude, but defined in DA.Internal.Compatible):
Deprecated: "Daml compatibility helper, use [a] instead of 'List a'"
You can safely ignore that if you want.
Alternatively, you can define your own synonym which then does not trigger the warning:
module Main where
import Prelude hiding (List)
type List a = [a]
test : List a -> List a
test = identity
I’d personally prefer if the deprecation were the other way around, that is, suggesting
List a instead of
[a]. I think that would fit better with
Daml's preference for simpler terms, such as
Action instead of
@akrmn fair point but I think the breakage from that is too large at this point.