PARSER: improve modularity

This commit is contained in:
hasufell 2015-02-04 00:25:07 +01:00
parent df4a4c2a27
commit a33b451740
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
1 changed files with 8 additions and 3 deletions

View File

@ -13,9 +13,7 @@ import Diagrams.TwoD.Types
-- a list of vertices, ordered by the faces specification.
facesToArr :: B.ByteString -> [[P2]]
facesToArr str = fmap (fmap (\y -> meshToArr str !! (fromIntegral y - 1)))
(faces str)
where
faces = rights . fmap (parseOnly parseFace) . B.lines
(meshFaces str)
-- |Convert a text String with multiple vertices into
@ -39,3 +37,10 @@ parseVertice =
parseFace :: Parser [Integer]
parseFace = char 'f' *> many1' (many' space *> decimal)
meshFaces :: B.ByteString -> [[Int]]
meshFaces
= rights
. fmap (parseOnly parseFace)
. B.lines