-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
44 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{-# LANGUAGE MagicHash #-} | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE PolyKinds #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
{-# LANGUAGE UnboxedTuples #-} | ||
{-# LANGUAGE TypeOperators #-} | ||
{-# LANGUAGE KindSignatures #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
module Data.Shaped.Product where | ||
|
||
import GHC.Prim | ||
import GHC.Types | ||
import GHC.IO | ||
|
||
-- This doesn't seem entirely worthless... worth coming up with a decent API for it | ||
-- including perhaps how to actually construct these things... :) | ||
|
||
type family Map (f :: a -> b) (xs :: [a]) :: [b] where | ||
Map f '[] = '[] | ||
Map f (x ': xs) = f x ': Map f xs | ||
|
||
data Product (ts :: [*]) = Product (Array# Any) | ||
data Elem (ts :: [*]) t = Elem Int# | ||
data Length (ts :: [*]) = Length Int# | ||
|
||
pget :: Product ts -> Elem ts t -> t | ||
pget (Product arr#) (Elem i#) = case indexArray# arr# i# of (# x #) -> unsafeCoerce# x | ||
|
||
plength :: Product ts -> Length ts | ||
plength (Product arr#) = Length (sizeofArray# arr#) | ||
|
||
pelems :: Product ts -> Product (Map (Elem ts) ts) | ||
pelems = undefined | ||
|
||
|
||
|
||
|
||
|
||
reallyUnsafeElem :: Int -> Elem ts t | ||
reallyUnsafeElem (I# i#) = Elem i# | ||
|