简体   繁体   中英

Haskell: GADT with UNPACK Pragma

UNPACK supports normal data types, as shown in the following:

data T = T {-# UNPACK #-} ! Int

But is there a way to use the UNPACK Pragma with GADT?

Tried it and found that it actually works with Constructor function arguments.

data BinHeap a where
  Empty :: (Ord a) => BinHeap a
  HeapNode :: (Ord a) => a -> {-# UNPACK #-} !Int -> BinHeap a -> BinHeap a -> BinHeap a

Nice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM