Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 503
Ray Qiu Avatar asked Mar 12 '16 22:03

Ray Qiu


1 Answers

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.

like image 110
Ray Qiu Avatar answered Nov 18 '22 19:11

Ray Qiu