packages feed

singletons-base-3.5.1: tests/compile-and-dump/Singletons/Classes.golden

Singletons/Classes.hs:(0,0)-(0,0): Splicing declarations
    singletons
      [d| const :: a -> b -> a
          const x _ = x
          fooCompare :: Foo -> Foo -> Ordering
          fooCompare A A = EQ
          fooCompare A B = LT
          fooCompare B B = GT
          fooCompare B A = EQ
          
          class MyOrd a where
            mycompare :: a -> a -> Ordering
            (<=>) :: a -> a -> Ordering
            (<=>) = mycompare
            infix 4 <=>
          data Foo = A | B
          data Foo2 = F | G
          
          instance Eq Foo2 where
            F == F = True
            G == G = True
            F == G = False
            G == F = False
          instance MyOrd Foo where
            mycompare = fooCompare
          instance MyOrd () where
            mycompare _ = const EQ
          instance MyOrd Nat where
            Zero `mycompare` Zero = EQ
            Zero `mycompare` (Succ _) = LT
            (Succ _) `mycompare` Zero = GT
            (Succ n) `mycompare` (Succ m) = m `mycompare` n |]
  ======>
    const :: a -> b -> a
    const x _ = x
    class MyOrd a where
      mycompare :: a -> a -> Ordering
      (<=>) :: a -> a -> Ordering
      infix 4 <=>
      (<=>) = mycompare
    instance MyOrd Nat where
      mycompare Zero Zero = EQ
      mycompare Zero (Succ _) = LT
      mycompare (Succ _) Zero = GT
      mycompare (Succ n) (Succ m) = (m `mycompare` n)
    instance MyOrd () where
      mycompare _ = const EQ
    data Foo = A | B
    fooCompare :: Foo -> Foo -> Ordering
    fooCompare A A = EQ
    fooCompare A B = LT
    fooCompare B B = GT
    fooCompare B A = EQ
    instance MyOrd Foo where
      mycompare = fooCompare
    data Foo2 = F | G
    instance Eq Foo2 where
      (==) F F = True
      (==) G G = True
      (==) F G = False
      (==) G F = False
    type ASym0 :: Foo
    type family ASym0 :: Foo where
      ASym0 = A
    type BSym0 :: Foo
    type family BSym0 :: Foo where
      BSym0 = B
    type FSym0 :: Foo2
    type family FSym0 :: Foo2 where
      FSym0 = F
    type GSym0 :: Foo2
    type family GSym0 :: Foo2 where
      GSym0 = G
    type FooCompareSym0 :: (~>) Foo ((~>) Foo Ordering)
    data FooCompareSym0 :: (~>) Foo ((~>) Foo Ordering)
      where
        FooCompareSym0KindInference :: SameKind (Apply FooCompareSym0 arg) (FooCompareSym1 arg) =>
                                       FooCompareSym0 a0123456789876543210
    type instance Apply @Foo @((~>) Foo Ordering) FooCompareSym0 a0123456789876543210 = FooCompareSym1 a0123456789876543210
    instance SuppressUnusedWarnings FooCompareSym0 where
      suppressUnusedWarnings = snd ((,) FooCompareSym0KindInference ())
    type FooCompareSym1 :: Foo -> (~>) Foo Ordering
    data FooCompareSym1 (a0123456789876543210 :: Foo) :: (~>) Foo Ordering
      where
        FooCompareSym1KindInference :: SameKind (Apply (FooCompareSym1 a0123456789876543210) arg) (FooCompareSym2 a0123456789876543210 arg) =>
                                       FooCompareSym1 a0123456789876543210 a0123456789876543210
    type instance Apply @Foo @Ordering (FooCompareSym1 a0123456789876543210) a0123456789876543210 = FooCompare a0123456789876543210 a0123456789876543210
    instance SuppressUnusedWarnings (FooCompareSym1 a0123456789876543210) where
      suppressUnusedWarnings = snd ((,) FooCompareSym1KindInference ())
    type FooCompareSym2 :: Foo -> Foo -> Ordering
    type family FooCompareSym2 (a0123456789876543210 :: Foo) (a0123456789876543210 :: Foo) :: Ordering where
      FooCompareSym2 a0123456789876543210 a0123456789876543210 = FooCompare a0123456789876543210 a0123456789876543210
    type ConstSym0 :: (~>) a ((~>) b a)
    data ConstSym0 :: (~>) a ((~>) b a)
      where
        ConstSym0KindInference :: SameKind (Apply ConstSym0 arg) (ConstSym1 arg) =>
                                  ConstSym0 a0123456789876543210
    type instance Apply @a @((~>) b a) ConstSym0 a0123456789876543210 = ConstSym1 a0123456789876543210
    instance SuppressUnusedWarnings ConstSym0 where
      suppressUnusedWarnings = snd ((,) ConstSym0KindInference ())
    type ConstSym1 :: a -> (~>) b a
    data ConstSym1 (a0123456789876543210 :: a) :: (~>) b a
      where
        ConstSym1KindInference :: SameKind (Apply (ConstSym1 a0123456789876543210) arg) (ConstSym2 a0123456789876543210 arg) =>
                                  ConstSym1 a0123456789876543210 a0123456789876543210
    type instance Apply @b @a (ConstSym1 a0123456789876543210) a0123456789876543210 = Const a0123456789876543210 a0123456789876543210
    instance SuppressUnusedWarnings (ConstSym1 a0123456789876543210) where
      suppressUnusedWarnings = snd ((,) ConstSym1KindInference ())
    type ConstSym2 :: a -> b -> a
    type family ConstSym2 @a @b (a0123456789876543210 :: a) (a0123456789876543210 :: b) :: a where
      ConstSym2 a0123456789876543210 a0123456789876543210 = Const a0123456789876543210 a0123456789876543210
    type FooCompare :: Foo -> Foo -> Ordering
    type family FooCompare (a :: Foo) (a :: Foo) :: Ordering where
      FooCompare A A = EQSym0
      FooCompare A B = LTSym0
      FooCompare B B = GTSym0
      FooCompare B A = EQSym0
    type Const :: a -> b -> a
    type family Const @a @b (a :: a) (a :: b) :: a where
      Const x _ = x
    type MycompareSym0 :: forall a. (~>) a ((~>) a Ordering)
    data MycompareSym0 :: (~>) a ((~>) a Ordering)
      where
        MycompareSym0KindInference :: SameKind (Apply MycompareSym0 arg) (MycompareSym1 arg) =>
                                      MycompareSym0 a0123456789876543210
    type instance Apply @a @((~>) a Ordering) MycompareSym0 a0123456789876543210 = MycompareSym1 a0123456789876543210
    instance SuppressUnusedWarnings MycompareSym0 where
      suppressUnusedWarnings = snd ((,) MycompareSym0KindInference ())
    type MycompareSym1 :: forall a. a -> (~>) a Ordering
    data MycompareSym1 (a0123456789876543210 :: a) :: (~>) a Ordering
      where
        MycompareSym1KindInference :: SameKind (Apply (MycompareSym1 a0123456789876543210) arg) (MycompareSym2 a0123456789876543210 arg) =>
                                      MycompareSym1 a0123456789876543210 a0123456789876543210
    type instance Apply @a @Ordering (MycompareSym1 a0123456789876543210) a0123456789876543210 = Mycompare a0123456789876543210 a0123456789876543210
    instance SuppressUnusedWarnings (MycompareSym1 a0123456789876543210) where
      suppressUnusedWarnings = snd ((,) MycompareSym1KindInference ())
    type MycompareSym2 :: forall a. a -> a -> Ordering
    type family MycompareSym2 @a (a0123456789876543210 :: a) (a0123456789876543210 :: a) :: Ordering where
      MycompareSym2 a0123456789876543210 a0123456789876543210 = Mycompare a0123456789876543210 a0123456789876543210
    type (<=>@#@$) :: forall a. (~>) a ((~>) a Ordering)
    data (<=>@#@$) :: (~>) a ((~>) a Ordering)
      where
        (:<=>@#@$###) :: SameKind (Apply (<=>@#@$) arg) ((<=>@#@$$) arg) =>
                         (<=>@#@$) a0123456789876543210
    type instance Apply @a @((~>) a Ordering) (<=>@#@$) a0123456789876543210 = (<=>@#@$$) a0123456789876543210
    instance SuppressUnusedWarnings (<=>@#@$) where
      suppressUnusedWarnings = snd ((,) (:<=>@#@$###) ())
    infix 4 type <=>@#@$
    type (<=>@#@$$) :: forall a. a -> (~>) a Ordering
    data (<=>@#@$$) (a0123456789876543210 :: a) :: (~>) a Ordering
      where
        (:<=>@#@$$###) :: SameKind (Apply ((<=>@#@$$) a0123456789876543210) arg) ((<=>@#@$$$) a0123456789876543210 arg) =>
                          (<=>@#@$$) a0123456789876543210 a0123456789876543210
    type instance Apply @a @Ordering ((<=>@#@$$) a0123456789876543210) a0123456789876543210 = (<=>) a0123456789876543210 a0123456789876543210
    instance SuppressUnusedWarnings ((<=>@#@$$) a0123456789876543210) where
      suppressUnusedWarnings = snd ((,) (:<=>@#@$$###) ())
    infix 4 type <=>@#@$$
    type (<=>@#@$$$) :: forall a. a -> a -> Ordering
    type family (<=>@#@$$$) @a (a0123456789876543210 :: a) (a0123456789876543210 :: a) :: Ordering where
      (<=>@#@$$$) a0123456789876543210 a0123456789876543210 = (<=>) a0123456789876543210 a0123456789876543210
    infix 4 type <=>@#@$$$
    type TFHelper_0123456789876543210 :: forall a. a -> a -> Ordering
    type family TFHelper_0123456789876543210 @a (a :: a) (a :: a) :: Ordering where
      TFHelper_0123456789876543210 @a (a_0123456789876543210 :: a) (a_0123456789876543210 :: a) = Apply (Apply MycompareSym0 a_0123456789876543210) a_0123456789876543210
    class PMyOrd a where
      type family Mycompare (arg :: a) (arg :: a) :: Ordering
      type family (<=>) (arg :: a) (arg :: a) :: Ordering
      type (<=>) a a = TFHelper_0123456789876543210 a a
    type Mycompare_0123456789876543210 :: Nat -> Nat -> Ordering
    type family Mycompare_0123456789876543210 (a :: Nat) (a :: Nat) :: Ordering where
      Mycompare_0123456789876543210 'Zero 'Zero = EQSym0
      Mycompare_0123456789876543210 'Zero ('Succ _) = LTSym0
      Mycompare_0123456789876543210 ('Succ _) 'Zero = GTSym0
      Mycompare_0123456789876543210 ('Succ n) ('Succ m) = Apply (Apply MycompareSym0 m) n
    instance PMyOrd Nat where
      type Mycompare a a = Mycompare_0123456789876543210 a a
    type Mycompare_0123456789876543210 :: () -> () -> Ordering
    type family Mycompare_0123456789876543210 (a :: ()) (a :: ()) :: Ordering where
      Mycompare_0123456789876543210 _ a_0123456789876543210 = Apply (Apply ConstSym0 EQSym0) a_0123456789876543210
    instance PMyOrd () where
      type Mycompare a a = Mycompare_0123456789876543210 a a
    type Mycompare_0123456789876543210 :: Foo -> Foo -> Ordering
    type family Mycompare_0123456789876543210 (a :: Foo) (a :: Foo) :: Ordering where
      Mycompare_0123456789876543210 a_0123456789876543210 a_0123456789876543210 = Apply (Apply FooCompareSym0 a_0123456789876543210) a_0123456789876543210
    instance PMyOrd Foo where
      type Mycompare a a = Mycompare_0123456789876543210 a a
    type TFHelper_0123456789876543210 :: Foo2 -> Foo2 -> Bool
    type family TFHelper_0123456789876543210 (a :: Foo2) (a :: Foo2) :: Bool where
      TFHelper_0123456789876543210 F F = TrueSym0
      TFHelper_0123456789876543210 G G = TrueSym0
      TFHelper_0123456789876543210 F G = FalseSym0
      TFHelper_0123456789876543210 G F = FalseSym0
    instance PEq Foo2 where
      type (==) a a = TFHelper_0123456789876543210 a a
    sFooCompare ::
      (forall (t :: Foo) (t :: Foo).
       Sing t -> Sing t -> Sing (FooCompare t t :: Ordering) :: Type)
    sConst ::
      (forall (t :: a) (t :: b).
       Sing t -> Sing t -> Sing (Const t t :: a) :: Type)
    sFooCompare SA SA = SEQ
    sFooCompare SA SB = SLT
    sFooCompare SB SB = SGT
    sFooCompare SB SA = SEQ
    sConst (sX :: Sing x) _ = sX
    instance SingI (FooCompareSym0 :: (~>) Foo ((~>) Foo Ordering)) where
      sing = singFun2 @FooCompareSym0 sFooCompare
    instance SingI d =>
             SingI (FooCompareSym1 (d :: Foo) :: (~>) Foo Ordering) where
      sing
        = singFun1 @(FooCompareSym1 (d :: Foo)) (sFooCompare (sing @d))
    instance SingI1 (FooCompareSym1 :: Foo -> (~>) Foo Ordering) where
      liftSing (s :: Sing (d :: Foo))
        = singFun1 @(FooCompareSym1 (d :: Foo)) (sFooCompare s)
    instance SingI (ConstSym0 :: (~>) a ((~>) b a)) where
      sing = singFun2 @ConstSym0 sConst
    instance SingI d => SingI (ConstSym1 (d :: a) :: (~>) b a) where
      sing = singFun1 @(ConstSym1 (d :: a)) (sConst (sing @d))
    instance SingI1 (ConstSym1 :: a -> (~>) b a) where
      liftSing (s :: Sing (d :: a))
        = singFun1 @(ConstSym1 (d :: a)) (sConst s)
    data SFoo :: Foo -> Type
      where
        SA :: SFoo (A :: Foo)
        SB :: SFoo (B :: Foo)
    type instance Sing @Foo = SFoo
    instance SingKind Foo where
      type Demote Foo = Foo
      fromSing SA = A
      fromSing SB = B
      toSing A = SomeSing SA
      toSing B = SomeSing SB
    data SFoo2 :: Foo2 -> Type
      where
        SF :: SFoo2 (F :: Foo2)
        SG :: SFoo2 (G :: Foo2)
    type instance Sing @Foo2 = SFoo2
    instance SingKind Foo2 where
      type Demote Foo2 = Foo2
      fromSing SF = F
      fromSing SG = G
      toSing F = SomeSing SF
      toSing G = SomeSing SG
    class SMyOrd a where
      sMycompare ::
        (forall (t :: a) (t :: a).
         Sing t -> Sing t -> Sing (Mycompare t t :: Ordering) :: Type)
      (%<=>) ::
        (forall (t :: a) (t :: a).
         Sing t -> Sing t -> Sing ((<=>) t t :: Ordering) :: Type)
      infix 4 data %<=>
      default (%<=>) ::
                (forall (t :: a) (t :: a).
                 (((<=>) t t :: Ordering) ~ TFHelper_0123456789876543210 t t) =>
                 Sing t -> Sing t -> Sing ((<=>) t t :: Ordering) :: Type)
      (%<=>)
        (sA_0123456789876543210 :: Sing a_0123456789876543210)
        (sA_0123456789876543210 :: Sing a_0123456789876543210)
        = applySing
            (applySing
               (singFun2 @MycompareSym0 sMycompare) sA_0123456789876543210)
            sA_0123456789876543210
    instance SMyOrd Nat where
      sMycompare SZero SZero = SEQ
      sMycompare SZero (SSucc _) = SLT
      sMycompare (SSucc _) SZero = SGT
      sMycompare (SSucc (sN :: Sing n)) (SSucc (sM :: Sing m))
        = applySing (applySing (singFun2 @MycompareSym0 sMycompare) sM) sN
    instance SMyOrd () where
      sMycompare _ (sA_0123456789876543210 :: Sing a_0123456789876543210)
        = applySing
            (applySing (singFun2 @ConstSym0 sConst) SEQ) sA_0123456789876543210
    instance SMyOrd Foo where
      sMycompare
        (sA_0123456789876543210 :: Sing a_0123456789876543210)
        (sA_0123456789876543210 :: Sing a_0123456789876543210)
        = applySing
            (applySing
               (singFun2 @FooCompareSym0 sFooCompare) sA_0123456789876543210)
            sA_0123456789876543210
    instance SEq Foo2 where
      (%==) SF SF = STrue
      (%==) SG SG = STrue
      (%==) SF SG = SFalse
      (%==) SG SF = SFalse
    instance SingI A where
      sing = SA
    instance SingI B where
      sing = SB
    instance SingI F where
      sing = SF
    instance SingI G where
      sing = SG
    instance SMyOrd a =>
             SingI (MycompareSym0 :: (~>) a ((~>) a Ordering)) where
      sing = singFun2 @MycompareSym0 sMycompare
    instance (SMyOrd a, SingI d) =>
             SingI (MycompareSym1 (d :: a) :: (~>) a Ordering) where
      sing = singFun1 @(MycompareSym1 (d :: a)) (sMycompare (sing @d))
    instance SMyOrd a =>
             SingI1 (MycompareSym1 :: a -> (~>) a Ordering) where
      liftSing (s :: Sing (d :: a))
        = singFun1 @(MycompareSym1 (d :: a)) (sMycompare s)
    instance SMyOrd a =>
             SingI ((<=>@#@$) :: (~>) a ((~>) a Ordering)) where
      sing = singFun2 @(<=>@#@$) (%<=>)
    instance (SMyOrd a, SingI d) =>
             SingI ((<=>@#@$$) (d :: a) :: (~>) a Ordering) where
      sing = singFun1 @((<=>@#@$$) (d :: a)) ((%<=>) (sing @d))
    instance SMyOrd a =>
             SingI1 ((<=>@#@$$) :: a -> (~>) a Ordering) where
      liftSing (s :: Sing (d :: a))
        = singFun1 @((<=>@#@$$) (d :: a)) ((%<=>) s)
Singletons/Classes.hs:(0,0)-(0,0): Splicing declarations
    promote
      [d| instance Ord Foo2 where
            F `compare` F = EQ
            F `compare` _ = LT
            _ `compare` _ = GT
          instance MyOrd Foo2 where
            F `mycompare` F = EQ
            F `mycompare` _ = LT
            _ `mycompare` _ = GT |]
  ======>
    instance MyOrd Foo2 where
      mycompare F F = EQ
      mycompare F _ = LT
      mycompare _ _ = GT
    instance Ord Foo2 where
      compare F F = EQ
      compare F _ = LT
      compare _ _ = GT
    type Mycompare_0123456789876543210 :: Foo2 -> Foo2 -> Ordering
    type family Mycompare_0123456789876543210 (a :: Foo2) (a :: Foo2) :: Ordering where
      Mycompare_0123456789876543210 'F 'F = EQSym0
      Mycompare_0123456789876543210 'F _ = LTSym0
      Mycompare_0123456789876543210 _ _ = GTSym0
    instance PMyOrd Foo2 where
      type Mycompare a a = Mycompare_0123456789876543210 a a
    type Compare_0123456789876543210 :: Foo2 -> Foo2 -> Ordering
    type family Compare_0123456789876543210 (a :: Foo2) (a :: Foo2) :: Ordering where
      Compare_0123456789876543210 'F 'F = EQSym0
      Compare_0123456789876543210 'F _ = LTSym0
      Compare_0123456789876543210 _ _ = GTSym0
    instance POrd Foo2 where
      type Compare a a = Compare_0123456789876543210 a a
Singletons/Classes.hs:(0,0)-(0,0): Splicing declarations
    singletons
      [d| data Nat' = Zero' | Succ' Nat'
          
          instance MyOrd Nat' where
            Zero' `mycompare` Zero' = EQ
            Zero' `mycompare` (Succ' _) = LT
            (Succ' _) `mycompare` Zero' = GT
            (Succ' n) `mycompare` (Succ' m) = m `mycompare` n |]
  ======>
    data Nat' = Zero' | Succ' Nat'
    instance MyOrd Nat' where
      mycompare Zero' Zero' = EQ
      mycompare Zero' (Succ' _) = LT
      mycompare (Succ' _) Zero' = GT
      mycompare (Succ' n) (Succ' m) = (m `mycompare` n)
    type Zero'Sym0 :: Nat'
    type family Zero'Sym0 :: Nat' where
      Zero'Sym0 = Zero'
    type Succ'Sym0 :: (~>) Nat' Nat'
    data Succ'Sym0 :: (~>) Nat' Nat'
      where
        Succ'Sym0KindInference :: SameKind (Apply Succ'Sym0 arg) (Succ'Sym1 arg) =>
                                  Succ'Sym0 a0123456789876543210
    type instance Apply @Nat' @Nat' Succ'Sym0 a0123456789876543210 = Succ' a0123456789876543210
    instance SuppressUnusedWarnings Succ'Sym0 where
      suppressUnusedWarnings = snd ((,) Succ'Sym0KindInference ())
    type Succ'Sym1 :: Nat' -> Nat'
    type family Succ'Sym1 (a0123456789876543210 :: Nat') :: Nat' where
      Succ'Sym1 a0123456789876543210 = Succ' a0123456789876543210
    type Mycompare_0123456789876543210 :: Nat' -> Nat' -> Ordering
    type family Mycompare_0123456789876543210 (a :: Nat') (a :: Nat') :: Ordering where
      Mycompare_0123456789876543210 Zero' Zero' = EQSym0
      Mycompare_0123456789876543210 Zero' (Succ' _) = LTSym0
      Mycompare_0123456789876543210 (Succ' _) Zero' = GTSym0
      Mycompare_0123456789876543210 (Succ' n) (Succ' m) = Apply (Apply MycompareSym0 m) n
    instance PMyOrd Nat' where
      type Mycompare a a = Mycompare_0123456789876543210 a a
    data SNat' :: Nat' -> Type
      where
        SZero' :: SNat' (Zero' :: Nat')
        SSucc' :: forall (n :: Nat'). (Sing n) -> SNat' (Succ' n :: Nat')
    type instance Sing @Nat' = SNat'
    instance SingKind Nat' where
      type Demote Nat' = Nat'
      fromSing SZero' = Zero'
      fromSing (SSucc' b) = Succ' (fromSing b)
      toSing Zero' = SomeSing SZero'
      toSing (Succ' (b :: Demote Nat'))
        = (\cases (SomeSing c) -> SomeSing (SSucc' c))
            (toSing b :: SomeSing Nat')
    instance SMyOrd Nat' where
      sMycompare SZero' SZero' = SEQ
      sMycompare SZero' (SSucc' _) = SLT
      sMycompare (SSucc' _) SZero' = SGT
      sMycompare (SSucc' (sN :: Sing n)) (SSucc' (sM :: Sing m))
        = applySing (applySing (singFun2 @MycompareSym0 sMycompare) sM) sN
    instance SingI Zero' where
      sing = SZero'
    instance SingI n => SingI (Succ' (n :: Nat')) where
      sing = SSucc' sing
    instance SingI1 Succ' where
      liftSing = SSucc'
    instance SingI (Succ'Sym0 :: (~>) Nat' Nat') where
      sing = singFun1 @Succ'Sym0 SSucc'