fork(2) download
  1. {-# LANGUAGE PolyKinds #-}
  2. {-# LANGUAGE TypeInType #-}
  3. {-# LANGUAGE TypeFamilies #-}
  4. {-# LANGUAGE GADTs #-}
  5.  
  6.  
  7. main = print "Hello"
  8.  
  9. -- type SomeSing :: * -> *
  10. data SomeSing k where
  11. SomeSing :: Sing (a :: k) -> SomeSing k
  12.  
  13. data family Sing (a :: k)
  14.  
  15. class SingKind k where
  16. fromSing :: Sing (a :: k) -> k
  17. toSing :: k -> SomeSing k
  18.  
  19. -----
  20.  
  21. data instance (Sing 'True) = STrue
  22. data instance (Sing 'False) = SFalse
  23.  
  24. instance SingKind Bool where
  25. fromSing s = case s of
  26. STrue -> True
  27. SFalse -> False
  28.  
  29. toSing b = case b of
  30. True -> SomeSing STrue
  31. False -> SomeSing SFalse
  32.  
  33.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
[1 of 1] Compiling Main             ( prog.hs, prog.o )

prog.hs:26:5: error:
    • Couldn't match type ‘a’ with ‘'True’
      ‘a’ is a rigid type variable bound by
        the type signature for:
          fromSing :: forall (a :: Bool). Sing a -> Bool
        at prog.hs:25:3-10
      Expected type: Sing a
        Actual type: Sing 'True
    • In the pattern: STrue
      In a case alternative: STrue -> True
      In the expression:
        case s of
          STrue -> True
          SFalse -> False
    • Relevant bindings include
        s :: Sing a (bound at prog.hs:25:12)
        fromSing :: Sing a -> Bool (bound at prog.hs:25:3)
   |
26 |     STrue  -> True
   |     ^^^^^
stdout
Standard output is empty