PARSER: improve function names
This commit is contained in:
parent
a33b451740
commit
44fee35926
@ -36,4 +36,4 @@ gifDiag p xs =
|
|||||||
-- |Same as gifDiag, except that it takes a string containing the
|
-- |Same as gifDiag, except that it takes a string containing the
|
||||||
-- mesh file content instead of the the points.
|
-- mesh file content instead of the the points.
|
||||||
gifDiagS :: DiagProp -> B.ByteString -> [(Diagram Cairo R2, GifDelay)]
|
gifDiagS :: DiagProp -> B.ByteString -> [(Diagram Cairo R2, GifDelay)]
|
||||||
gifDiagS p = gifDiag p . filterValidPT p . meshToArr
|
gifDiagS p = gifDiag p . filterValidPT p . meshVertices
|
||||||
|
@ -61,8 +61,8 @@ diagS :: DiagProp -> B.ByteString -> Diagram Cairo R2
|
|||||||
diagS p mesh =
|
diagS p mesh =
|
||||||
diag p diagAlgos
|
diag p diagAlgos
|
||||||
. fmap (filterValidPT p)
|
. fmap (filterValidPT p)
|
||||||
. (\x -> if null x then [meshToArr mesh] else x)
|
. (\x -> if null x then [meshVertices mesh] else x)
|
||||||
. facesToArr
|
. meshFaceVertices
|
||||||
$ mesh
|
$ mesh
|
||||||
|
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ diagTreeS :: DiagProp -> B.ByteString -> Diagram Cairo R2
|
|||||||
diagTreeS p mesh =
|
diagTreeS p mesh =
|
||||||
diag p diagTreAlgos
|
diag p diagTreAlgos
|
||||||
. fmap (filterValidPT p)
|
. fmap (filterValidPT p)
|
||||||
. (\x -> if null x then [meshToArr mesh] else x)
|
. (\x -> if null x then [meshVertices mesh] else x)
|
||||||
. facesToArr
|
. meshFaceVertices
|
||||||
$ mesh
|
$ mesh
|
||||||
|
|
||||||
|
@ -11,17 +11,17 @@ import Diagrams.TwoD.Types
|
|||||||
|
|
||||||
-- |Convert a text String with multiple vertices and faces into
|
-- |Convert a text String with multiple vertices and faces into
|
||||||
-- a list of vertices, ordered by the faces specification.
|
-- a list of vertices, ordered by the faces specification.
|
||||||
facesToArr :: B.ByteString -> [[P2]]
|
meshFaceVertices :: B.ByteString -> [[P2]]
|
||||||
facesToArr str = fmap (fmap (\y -> meshToArr str !! (fromIntegral y - 1)))
|
meshFaceVertices str = fmap (fmap (\y -> meshVertices str !! (y - 1)))
|
||||||
(meshFaces str)
|
(meshFaces str)
|
||||||
|
|
||||||
|
|
||||||
-- |Convert a text String with multiple vertices into
|
-- |Convert a text String with multiple vertices into
|
||||||
-- an array of float tuples.
|
-- an array of float tuples.
|
||||||
meshToArr :: B.ByteString -- ^ the string to convert
|
meshVertices :: B.ByteString -- ^ the string to convert
|
||||||
-> [P2] -- ^ the resulting vertice table
|
-> [P2] -- ^ the resulting vertice table
|
||||||
meshToArr =
|
meshVertices
|
||||||
fmap p2
|
= fmap p2
|
||||||
. rights
|
. rights
|
||||||
. fmap (parseOnly parseVertice)
|
. fmap (parseOnly parseVertice)
|
||||||
. B.lines
|
. B.lines
|
||||||
@ -35,7 +35,7 @@ parseVertice =
|
|||||||
<*> (many' space *> double)
|
<*> (many' space *> double)
|
||||||
|
|
||||||
|
|
||||||
parseFace :: Parser [Integer]
|
parseFace :: (Integral a) => Parser [a]
|
||||||
parseFace = char 'f' *> many1' (many' space *> decimal)
|
parseFace = char 'f' *> many1' (many' space *> decimal)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user