blob: 5b8b355feec9d046e888f815a667a44d017b29c5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
module RepPolyCase2 where
import Data.Kind
import GHC.Exts
type Rep :: Type -> RuntimeRep
type family Rep a
class Unboxable a where
type Unbox a :: TYPE (Rep a)
unbox :: a -> Unbox a
type instance Rep Int = IntRep
instance Unboxable Int where
type Unbox Int = Int#
unbox (I# i#) = i#
type instance Rep Double = DoubleRep
instance Unboxable Double where
type Unbox Double = Double#
unbox (D# d#) = d#
x :: () -> ()
x _ = case unbox (3 :: Int) of { _ -> () }
|