summaryrefslogtreecommitdiff
path: root/AttributeData.hs
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-05-19 22:16:55 -0400
committerJoe Crayne <joe@jerkface.net>2019-05-19 22:16:55 -0400
commitdc5aecfffbe071e9b8714988b9824c4f445f8dfc (patch)
treed3cc59ca11d2e4183d7eb2757b6aa723d5510398 /AttributeData.hs
parenteb02d7ac3e47cba80a1701fc4d755073941e02dd (diff)
Use Data.Data to specify ring buffer attributes.
Diffstat (limited to 'AttributeData.hs')
-rw-r--r--AttributeData.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/AttributeData.hs b/AttributeData.hs
index 8e149af..59b9e6d 100644
--- a/AttributeData.hs
+++ b/AttributeData.hs
@@ -104,8 +104,12 @@ reflectPrim r = case () of
104 104
105 105
106reflectVectorType :: Typeable a => proxy a -> Maybe (Some TypeTag) 106reflectVectorType :: Typeable a => proxy a -> Maybe (Some TypeTag)
107reflectVectorType proxy = case R.someTypeRep proxy of 107reflectVectorType proxy = go (R.someTypeRep proxy)
108 where
109 go :: R.SomeTypeRep -> Maybe (Some TypeTag)
110 go rep = case rep of
108 R.SomeTypeRep r -> case R.splitApps r of 111 R.SomeTypeRep r -> case R.splitApps r of
112
109 (v,[c,a]) -> do 113 (v,[c,a]) -> do
110 cols <- reflectDim c 114 cols <- reflectDim c
111 This p <- reflectPrim a 115 This p <- reflectPrim a
@@ -125,6 +129,7 @@ reflectVectorType proxy = case R.someTypeRep proxy of
125 2 -> This TypeV2F 129 2 -> This TypeV2F
126 3 -> This TypeV3F 130 3 -> This TypeV3F
127 4 -> This TypeV4F 131 4 -> This TypeV4F
132
128 (m,[r,c,a]) -> do 133 (m,[r,c,a]) -> do
129 rows <- reflectDim r 134 rows <- reflectDim r
130 cols <- reflectDim c 135 cols <- reflectDim c
@@ -147,6 +152,9 @@ reflectVectorType proxy = case R.someTypeRep proxy of
147 4 -> Just $ This TypeM44F 152 4 -> Just $ This TypeM44F
148 _ -> Nothing 153 _ -> Nothing
149 _ -> Nothing 154 _ -> Nothing
155
156 (p,[x]) -> go x
157
150 _ -> Nothing 158 _ -> Nothing
151 159
152fieldParameters :: forall attrkeys proxy. Data attrkeys => proxy attrkeys -> (String -> String) -> [Parameter] 160fieldParameters :: forall attrkeys proxy. Data attrkeys => proxy attrkeys -> (String -> String) -> [Parameter]
@@ -156,7 +164,7 @@ fieldParameters proxy toAttrName = do
156 AlgRep (c:_) -> do 164 AlgRep (c:_) -> do
157 let fields = constrFields c 165 let fields = constrFields c
158 mkb :: (MonadPlus m, Data k) => p k -> String -> m InputType 166 mkb :: (MonadPlus m, Data k) => p k -> String -> m InputType
159 mkb pxy n = case reflectVectorType proxy of 167 mkb pxy n = case reflectVectorType pxy of
160 Just (This tt) -> return $ unwitnessType tt 168 Just (This tt) -> return $ unwitnessType tt
161 _ -> mzero 169 _ -> mzero
162 go :: Data c => StateT ([String],[Parameter]) Maybe c 170 go :: Data c => StateT ([String],[Parameter]) Maybe c