Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't defunctionalize helpers for class defaults or instance methods #609

Merged
merged 2 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 12 additions & 168 deletions singletons-base/tests/compile-and-dump/GradingClient/Database.golden

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions singletons-base/tests/compile-and-dump/GradingClient/Main.golden
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ GradingClient/Main.hs:(0,0)-(0,0): Splicing declarations
type LastName :: [AChar]
type family LastName :: [AChar] where
LastName = Apply (Apply (:@#@$) CLSym0) (Apply (Apply (:@#@$) CASym0) (Apply (Apply (:@#@$) CSSym0) (Apply (Apply (:@#@$) CTSym0) NilSym0)))
sNames :: (Sing (NamesSym0 :: Schema) :: Type)
sGradingSchema :: (Sing (GradingSchemaSym0 :: Schema) :: Type)
sMajorName :: (Sing (MajorNameSym0 :: [AChar]) :: Type)
sGradeName :: (Sing (GradeNameSym0 :: [AChar]) :: Type)
sYearName :: (Sing (YearNameSym0 :: [AChar]) :: Type)
sFirstName :: (Sing (FirstNameSym0 :: [AChar]) :: Type)
sLastName :: (Sing (LastNameSym0 :: [AChar]) :: Type)
sNames :: (Sing (Names :: Schema) :: Type)
sGradingSchema :: (Sing (GradingSchema :: Schema) :: Type)
sMajorName :: (Sing (MajorName :: [AChar]) :: Type)
sGradeName :: (Sing (GradeName :: [AChar]) :: Type)
sYearName :: (Sing (YearName :: [AChar]) :: Type)
sFirstName :: (Sing (FirstName :: [AChar]) :: Type)
sLastName :: (Sing (LastName :: [AChar]) :: Type)
sNames
= applySing
(singFun1 @SchSym0 SSch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,13 @@ InsertionSort/InsertionSortImp.hs:(0,0)-(0,0): Splicing declarations
Leq ('Succ a) ('Succ b) = Apply (Apply LeqSym0 a) b
sInsertionSort ::
(forall (t :: [Nat]).
Sing t -> Sing (Apply InsertionSortSym0 t :: [Nat]) :: Type)
Sing t -> Sing (InsertionSort t :: [Nat]) :: Type)
sInsert ::
(forall (t :: Nat) (t :: [Nat]).
Sing t
-> Sing t -> Sing (Apply (Apply InsertSym0 t) t :: [Nat]) :: Type)
Sing t -> Sing t -> Sing (Insert t t :: [Nat]) :: Type)
sLeq ::
(forall (t :: Nat) (t :: Nat).
Sing t
-> Sing t -> Sing (Apply (Apply LeqSym0 t) t :: Bool) :: Type)
Sing t -> Sing t -> Sing (Leq t t :: Bool) :: Type)
sInsertionSort SNil = SNil
sInsertionSort (SCons (sH :: Sing h) (sT :: Sing t))
= applySing
Expand All @@ -152,7 +150,7 @@ InsertionSort/InsertionSortImp.hs:(0,0)-(0,0): Splicing declarations
sInsert (sN :: Sing n) (SCons (sH :: Sing h) (sT :: Sing t))
= let
sScrutinee_0123456789876543210 ::
Sing @_ (Let0123456789876543210Scrutinee_0123456789876543210Sym0 n h t)
Sing @_ (Let0123456789876543210Scrutinee_0123456789876543210 n h t)
sScrutinee_0123456789876543210
= applySing (applySing (singFun2 @LeqSym0 sLeq) sN) sH
in
Expand Down
23 changes: 1 addition & 22 deletions singletons-base/tests/compile-and-dump/Promote/Newtypes.golden
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,5 @@ Promote/Newtypes.hs:(0,0)-(0,0): Splicing declarations
type TFHelper_0123456789876543210 :: Foo -> Foo -> Bool
type family TFHelper_0123456789876543210 (a :: Foo) (a :: Foo) :: Bool where
TFHelper_0123456789876543210 (Foo a_0123456789876543210) (Foo b_0123456789876543210) = Apply (Apply (==@#@$) a_0123456789876543210) b_0123456789876543210
type TFHelper_0123456789876543210Sym0 :: (~>) Foo ((~>) Foo Bool)
data TFHelper_0123456789876543210Sym0 :: (~>) Foo ((~>) Foo Bool)
where
TFHelper_0123456789876543210Sym0KindInference :: SameKind (Apply TFHelper_0123456789876543210Sym0 arg) (TFHelper_0123456789876543210Sym1 arg) =>
TFHelper_0123456789876543210Sym0 a0123456789876543210
type instance Apply @Foo @((~>) Foo Bool) TFHelper_0123456789876543210Sym0 a0123456789876543210 = TFHelper_0123456789876543210Sym1 a0123456789876543210
instance SuppressUnusedWarnings TFHelper_0123456789876543210Sym0 where
suppressUnusedWarnings
= snd ((,) TFHelper_0123456789876543210Sym0KindInference ())
type TFHelper_0123456789876543210Sym1 :: Foo -> (~>) Foo Bool
data TFHelper_0123456789876543210Sym1 (a0123456789876543210 :: Foo) :: (~>) Foo Bool
where
TFHelper_0123456789876543210Sym1KindInference :: SameKind (Apply (TFHelper_0123456789876543210Sym1 a0123456789876543210) arg) (TFHelper_0123456789876543210Sym2 a0123456789876543210 arg) =>
TFHelper_0123456789876543210Sym1 a0123456789876543210 a0123456789876543210
type instance Apply @Foo @Bool (TFHelper_0123456789876543210Sym1 a0123456789876543210) a0123456789876543210 = TFHelper_0123456789876543210 a0123456789876543210 a0123456789876543210
instance SuppressUnusedWarnings (TFHelper_0123456789876543210Sym1 a0123456789876543210) where
suppressUnusedWarnings
= snd ((,) TFHelper_0123456789876543210Sym1KindInference ())
type TFHelper_0123456789876543210Sym2 :: Foo -> Foo -> Bool
type family TFHelper_0123456789876543210Sym2 (a0123456789876543210 :: Foo) (a0123456789876543210 :: Foo) :: Bool where
TFHelper_0123456789876543210Sym2 a0123456789876543210 a0123456789876543210 = TFHelper_0123456789876543210 a0123456789876543210 a0123456789876543210
instance PEq Foo where
type (==) a a = Apply (Apply TFHelper_0123456789876543210Sym0 a) a
type (==) a a = TFHelper_0123456789876543210 a a
29 changes: 13 additions & 16 deletions singletons-base/tests/compile-and-dump/Singletons/AsPattern.golden
Original file line number Diff line number Diff line change
Expand Up @@ -172,31 +172,29 @@ Singletons/AsPattern.hs:(0,0)-(0,0): Splicing declarations
MaybePlus ('Just n) = Apply JustSym0 (Apply (Apply PlusSym0 (Apply SuccSym0 ZeroSym0)) n)
MaybePlus 'Nothing = Let0123456789876543210PSym0
sFoo ::
(forall (t :: [Nat]).
Sing t -> Sing (Apply FooSym0 t :: [Nat]) :: Type)
(forall (t :: [Nat]). Sing t -> Sing (Foo t :: [Nat]) :: Type)
sTup ::
(forall (t :: (Nat, Nat)).
Sing t -> Sing (Apply TupSym0 t :: (Nat, Nat)) :: Type)
Sing t -> Sing (Tup t :: (Nat, Nat)) :: Type)
sBaz_ ::
(forall (t :: Maybe Baz).
Sing t -> Sing (Apply Baz_Sym0 t :: Maybe Baz) :: Type)
Sing t -> Sing (Baz_ t :: Maybe Baz) :: Type)
sBar ::
(forall (t :: Maybe Nat).
Sing t -> Sing (Apply BarSym0 t :: Maybe Nat) :: Type)
Sing t -> Sing (Bar t :: Maybe Nat) :: Type)
sMaybePlus ::
(forall (t :: Maybe Nat).
Sing t -> Sing (Apply MaybePlusSym0 t :: Maybe Nat) :: Type)
Sing t -> Sing (MaybePlus t :: Maybe Nat) :: Type)
sFoo SNil
= let
sP :: Sing @_ Let0123456789876543210PSym0
sP :: Sing @_ Let0123456789876543210P
sP = SNil
in sP
sFoo
(SCons (sWild_0123456789876543210 :: Sing wild_0123456789876543210)
SNil)
= let
sP ::
Sing @_ (Let0123456789876543210PSym0 wild_0123456789876543210)
sP :: Sing @_ (Let0123456789876543210P wild_0123456789876543210)
sP
= applySing
(applySing (singFun2 @(:@#@$) SCons) sWild_0123456789876543210)
Expand All @@ -208,7 +206,7 @@ Singletons/AsPattern.hs:(0,0)-(0,0): Splicing declarations
(sWild_0123456789876543210 :: Sing wild_0123456789876543210)))
= let
sP ::
Sing @_ (Let0123456789876543210PSym0 wild_0123456789876543210 wild_0123456789876543210 wild_0123456789876543210)
Sing @_ (Let0123456789876543210P wild_0123456789876543210 wild_0123456789876543210 wild_0123456789876543210)
sP
= applySing
(applySing (singFun2 @(:@#@$) SCons) sWild_0123456789876543210)
Expand All @@ -221,7 +219,7 @@ Singletons/AsPattern.hs:(0,0)-(0,0): Splicing declarations
(sWild_0123456789876543210 :: Sing wild_0123456789876543210))
= let
sP ::
Sing @_ (Let0123456789876543210PSym0 wild_0123456789876543210 wild_0123456789876543210)
Sing @_ (Let0123456789876543210P wild_0123456789876543210 wild_0123456789876543210)
sP
= applySing
(applySing
Expand All @@ -230,7 +228,7 @@ Singletons/AsPattern.hs:(0,0)-(0,0): Splicing declarations
in sP
sBaz_ SNothing
= let
sP :: Sing @_ Let0123456789876543210PSym0
sP :: Sing @_ Let0123456789876543210P
sP = SNothing
in sP
sBaz_
Expand All @@ -239,7 +237,7 @@ Singletons/AsPattern.hs:(0,0)-(0,0): Splicing declarations
(sWild_0123456789876543210 :: Sing wild_0123456789876543210)))
= let
sP ::
Sing @_ (Let0123456789876543210PSym0 wild_0123456789876543210 wild_0123456789876543210 wild_0123456789876543210)
Sing @_ (Let0123456789876543210P wild_0123456789876543210 wild_0123456789876543210 wild_0123456789876543210)
sP
= applySing
(singFun1 @JustSym0 SJust)
Expand All @@ -252,8 +250,7 @@ Singletons/AsPattern.hs:(0,0)-(0,0): Splicing declarations
sBar
(SJust (sWild_0123456789876543210 :: Sing wild_0123456789876543210))
= let
sX ::
Sing @_ (Let0123456789876543210XSym0 wild_0123456789876543210)
sX :: Sing @_ (Let0123456789876543210X wild_0123456789876543210)
sX = applySing (singFun1 @JustSym0 SJust) sWild_0123456789876543210
in sX
sBar SNothing = SNothing
Expand All @@ -267,7 +264,7 @@ Singletons/AsPattern.hs:(0,0)-(0,0): Splicing declarations
sN)
sMaybePlus SNothing
= let
sP :: Sing @_ Let0123456789876543210PSym0
sP :: Sing @_ Let0123456789876543210P
sP = SNothing
in sP
instance SingI (FooSym0 :: (~>) [Nat] [Nat]) where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,78 +88,48 @@ Singletons/BoundedDeriving.hs:(0,0)-(0,0): Splicing declarations
type MinBound_0123456789876543210 :: Foo1
type family MinBound_0123456789876543210 :: Foo1 where
MinBound_0123456789876543210 = Foo1Sym0
type MinBound_0123456789876543210Sym0 :: Foo1
type family MinBound_0123456789876543210Sym0 :: Foo1 where
MinBound_0123456789876543210Sym0 = MinBound_0123456789876543210
type MaxBound_0123456789876543210 :: Foo1
type family MaxBound_0123456789876543210 :: Foo1 where
MaxBound_0123456789876543210 = Foo1Sym0
type MaxBound_0123456789876543210Sym0 :: Foo1
type family MaxBound_0123456789876543210Sym0 :: Foo1 where
MaxBound_0123456789876543210Sym0 = MaxBound_0123456789876543210
instance PBounded Foo1 where
type MinBound = MinBound_0123456789876543210Sym0
type MaxBound = MaxBound_0123456789876543210Sym0
type MinBound = MinBound_0123456789876543210
type MaxBound = MaxBound_0123456789876543210
type MinBound_0123456789876543210 :: Foo2
type family MinBound_0123456789876543210 :: Foo2 where
MinBound_0123456789876543210 = ASym0
type MinBound_0123456789876543210Sym0 :: Foo2
type family MinBound_0123456789876543210Sym0 :: Foo2 where
MinBound_0123456789876543210Sym0 = MinBound_0123456789876543210
type MaxBound_0123456789876543210 :: Foo2
type family MaxBound_0123456789876543210 :: Foo2 where
MaxBound_0123456789876543210 = ESym0
type MaxBound_0123456789876543210Sym0 :: Foo2
type family MaxBound_0123456789876543210Sym0 :: Foo2 where
MaxBound_0123456789876543210Sym0 = MaxBound_0123456789876543210
instance PBounded Foo2 where
type MinBound = MinBound_0123456789876543210Sym0
type MaxBound = MaxBound_0123456789876543210Sym0
type MinBound = MinBound_0123456789876543210
type MaxBound = MaxBound_0123456789876543210
type MinBound_0123456789876543210 :: forall a. Foo3 a
type family MinBound_0123456789876543210 @a :: Foo3 a where
MinBound_0123456789876543210 @a = Apply Foo3Sym0 MinBoundSym0
type MinBound_0123456789876543210Sym0 :: forall a. Foo3 a
type family MinBound_0123456789876543210Sym0 @a :: Foo3 a where
MinBound_0123456789876543210Sym0 = MinBound_0123456789876543210
type MaxBound_0123456789876543210 :: forall a. Foo3 a
type family MaxBound_0123456789876543210 @a :: Foo3 a where
MaxBound_0123456789876543210 @a = Apply Foo3Sym0 MaxBoundSym0
type MaxBound_0123456789876543210Sym0 :: forall a. Foo3 a
type family MaxBound_0123456789876543210Sym0 @a :: Foo3 a where
MaxBound_0123456789876543210Sym0 = MaxBound_0123456789876543210
instance PBounded (Foo3 a) where
type MinBound = MinBound_0123456789876543210Sym0
type MaxBound = MaxBound_0123456789876543210Sym0
type MinBound = MinBound_0123456789876543210
type MaxBound = MaxBound_0123456789876543210
type MinBound_0123456789876543210 :: forall a b. Foo4 a b
type family MinBound_0123456789876543210 @a @b :: Foo4 a b where
MinBound_0123456789876543210 @a @b = Foo41Sym0
type MinBound_0123456789876543210Sym0 :: forall a b. Foo4 a b
type family MinBound_0123456789876543210Sym0 @a @b :: Foo4 a b where
MinBound_0123456789876543210Sym0 = MinBound_0123456789876543210
type MaxBound_0123456789876543210 :: forall a b. Foo4 a b
type family MaxBound_0123456789876543210 @a @b :: Foo4 a b where
MaxBound_0123456789876543210 @a @b = Foo42Sym0
type MaxBound_0123456789876543210Sym0 :: forall a b. Foo4 a b
type family MaxBound_0123456789876543210Sym0 @a @b :: Foo4 a b where
MaxBound_0123456789876543210Sym0 = MaxBound_0123456789876543210
instance PBounded (Foo4 a b) where
type MinBound = MinBound_0123456789876543210Sym0
type MaxBound = MaxBound_0123456789876543210Sym0
type MinBound = MinBound_0123456789876543210
type MaxBound = MaxBound_0123456789876543210
type MinBound_0123456789876543210 :: Pair
type family MinBound_0123456789876543210 :: Pair where
MinBound_0123456789876543210 = Apply (Apply PairSym0 MinBoundSym0) MinBoundSym0
type MinBound_0123456789876543210Sym0 :: Pair
type family MinBound_0123456789876543210Sym0 :: Pair where
MinBound_0123456789876543210Sym0 = MinBound_0123456789876543210
type MaxBound_0123456789876543210 :: Pair
type family MaxBound_0123456789876543210 :: Pair where
MaxBound_0123456789876543210 = Apply (Apply PairSym0 MaxBoundSym0) MaxBoundSym0
type MaxBound_0123456789876543210Sym0 :: Pair
type family MaxBound_0123456789876543210Sym0 :: Pair where
MaxBound_0123456789876543210Sym0 = MaxBound_0123456789876543210
instance PBounded Pair where
type MinBound = MinBound_0123456789876543210Sym0
type MaxBound = MaxBound_0123456789876543210Sym0
type MinBound = MinBound_0123456789876543210
type MaxBound = MaxBound_0123456789876543210
data SFoo1 :: Foo1 -> Type where SFoo1 :: SFoo1 (Foo1 :: Foo1)
type instance Sing @Foo1 = SFoo1
instance SingKind Foo1 where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ Singletons/BoxUnBox.hs:(0,0)-(0,0): Splicing declarations
type family UnBox @a (a :: Box a) :: a where
UnBox (FBox a) = a
sUnBox ::
(forall (t :: Box a).
Sing t -> Sing (Apply UnBoxSym0 t :: a) :: Type)
(forall (t :: Box a). Sing t -> Sing (UnBox t :: a) :: Type)
sUnBox (SFBox (sA :: Sing a)) = sA
instance SingI (UnBoxSym0 :: (~>) (Box a) a) where
sing = singFun1 @UnBoxSym0 sUnBox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,17 @@ Singletons/CaseExpressions.hs:(0,0)-(0,0): Splicing declarations
type Foo1 :: a -> Maybe a -> a
type family Foo1 @a (a :: a) (a :: Maybe a) :: a where
Foo1 d x = Case_0123456789876543210 d x x
sFoo5 ::
(forall (t :: a). Sing t -> Sing (Apply Foo5Sym0 t :: a) :: Type)
sFoo4 :: forall a (t :: a). Sing t -> Sing (Apply Foo4Sym0 t :: a)
sFoo5 :: (forall (t :: a). Sing t -> Sing (Foo5 t :: a) :: Type)
sFoo4 :: forall a (t :: a). Sing t -> Sing (Foo4 t :: a)
sFoo3 ::
(forall (t :: a) (t :: b).
Sing t -> Sing t -> Sing (Apply (Apply Foo3Sym0 t) t :: a) :: Type)
Sing t -> Sing t -> Sing (Foo3 t t :: a) :: Type)
sFoo2 ::
(forall (t :: a) (t :: Maybe a).
Sing t -> Sing t -> Sing (Apply (Apply Foo2Sym0 t) t :: a) :: Type)
Sing t -> Sing t -> Sing (Foo2 t t :: a) :: Type)
sFoo1 ::
(forall (t :: a) (t :: Maybe a).
Sing t -> Sing t -> Sing (Apply (Apply Foo1Sym0 t) t :: a) :: Type)
Sing t -> Sing t -> Sing (Foo1 t t :: a) :: Type)
sFoo5 (sX :: Sing x)
= id
@(Sing (Case_0123456789876543210 x x))
Expand All @@ -201,13 +200,13 @@ Singletons/CaseExpressions.hs:(0,0)-(0,0): Splicing declarations
(case sX of
(sY :: Sing y)
-> let
sZ :: (Sing (Let0123456789876543210ZSym0 a y x :: a) :: Type)
sZ :: (Sing (Let0123456789876543210Z a y x :: a) :: Type)
sZ = sY
in sZ)
sFoo3 (sA :: Sing a) (sB :: Sing b)
= let
sScrutinee_0123456789876543210 ::
Sing @_ (Let0123456789876543210Scrutinee_0123456789876543210Sym0 a b)
Sing @_ (Let0123456789876543210Scrutinee_0123456789876543210 a b)
sScrutinee_0123456789876543210
= applySing (applySing (singFun2 @Tuple2Sym0 STuple2) sA) sB
in
Expand All @@ -218,7 +217,7 @@ Singletons/CaseExpressions.hs:(0,0)-(0,0): Splicing declarations
sFoo2 (sD :: Sing d) _
= let
sScrutinee_0123456789876543210 ::
Sing @_ (Let0123456789876543210Scrutinee_0123456789876543210Sym0 d)
Sing @_ (Let0123456789876543210Scrutinee_0123456789876543210 d)
sScrutinee_0123456789876543210
= applySing (singFun1 @JustSym0 SJust) sD
in
Expand Down
Loading