@@ -111,7 +111,7 @@ gravGroup sz positions sectors =
111
111
unsafePerformIO $ do
112
112
withArray (map (planetPositionToGlyph sz) positions) $ \ grobs ->
113
113
withArray (map realToFrac sectors) $ \ sbdy ->
114
- withCAString " " $ \ serr -> do
114
+ allocaErrorMessage $ \ serr -> do
115
115
let nob = fromIntegral $ length positions
116
116
nsectors = fromIntegral $ length sectors - 1
117
117
retval <-
@@ -122,7 +122,8 @@ gravGroup sz positions sectors =
122
122
pure $ Left msg
123
123
else do
124
124
repositioned <- peekArray (fromIntegral nob) grobs
125
- pure . Right $ map glyphInfo repositioned
125
+ glyphInfos <- mapM glyphInfo repositioned
126
+ pure . Right $ glyphInfos
126
127
127
128
-- | /Easy/ version of 'gravGroup' that assumes:
128
129
--
@@ -166,7 +167,7 @@ gravGroup2 sz positions sectors allowShift =
166
167
in unsafePerformIO $ do
167
168
withArray (map (planetPositionToGlyph sz) positions) $ \ grobs ->
168
169
withArray (map realToFrac sectors') $ \ sbdy ->
169
- withCAString " " $ \ serr -> do
170
+ allocaErrorMessage $ \ serr -> do
170
171
let nob = fromIntegral $ length positions
171
172
-- empty sector lists are allowed:
172
173
nsectors = max 0 $ fromIntegral $ length sectors - 1
@@ -179,7 +180,8 @@ gravGroup2 sz positions sectors allowShift =
179
180
pure $ Left msg
180
181
else do
181
182
repositioned <- peekArray (fromIntegral nob) grobs
182
- pure . Right $ map glyphInfo repositioned
183
+ glyphInfos <- mapM glyphInfo repositioned
184
+ pure . Right $ glyphInfos
183
185
184
186
185
187
-- | /Easy/ version of 'gravGroup2', same provisions as 'gravGroupEasy'
@@ -215,8 +217,8 @@ planetPositionToGlyph (lwidth, rwidth) (planet, pos) = unsafePerformIO $ do
215
217
, dp = planetPtr
216
218
}
217
219
218
- glyphInfo :: PlanetGlyph -> PlanetGlyphInfo
219
- glyphInfo GravityObject {pos, lsize, rsize, ppos, sector_no, sequence_no, level_no, scale, dp} = unsafePerformIO $ do
220
+ glyphInfo :: PlanetGlyph -> IO PlanetGlyphInfo
221
+ glyphInfo GravityObject {pos, lsize, rsize, ppos, sector_no, sequence_no, level_no, scale, dp} = do
220
222
planet' <- peek dp
221
223
pure $
222
224
GlyphInfo {
0 commit comments