-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
This example shows getA as a weed if foo5 is not defined:
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NamedFieldPuns #-}
module MyLib where
data family DF a
data instance DF Int = A { getA :: Int }
foo :: DF Int -> IO ()
foo (A x) = print x
bar :: DF Int -> IO ()
bar (A{getA}) = print getA
baz :: DF Int -> IO ()
baz (A{..}) = print getA
foo2 :: Int -> DF Int
foo2 x = A x
foo3 :: Int -> DF Int
foo3 x = A { getA = x }
foo4 :: Int -> DF Int -> DF Int
foo4 x a = a { getA = x }
foo5 :: DF Int -> Int
foo5 a = getA aNote that if this is not a data family, the field is declared as used as soon as it is pattern-matched, without mentioning the actual field name. This shows no weeds
module MyLib where
data A = A { getA :: Int }
foo :: A -> IO ()
foo (A x) = print xI'm using the following weeder.toml file, and an executable that uses all the functions available:
roots = ["Main.main"]
type-class-roots = true
unused-types = true
The readme says:
Type families
Weeder cannot yet analyse uses of type family instances. For this reason type family instances will be marked as implicit roots if analysis of types is enabled via unused-types.
However either I am misunderstanding that note, or these are not being marked as roots.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels