summaryrefslogtreecommitdiff
path: root/src/Codec/Wavefront/IO.hs
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-06-10 23:03:04 -0400
committerJoe Crayne <joe@jerkface.net>2019-06-10 23:03:04 -0400
commit38b7bcf654e5e804a13518b060ebdba59bf232bb (patch)
tree2fa3c4ccf3496750f0ce388a9ea0998fdd93bf69 /src/Codec/Wavefront/IO.hs
Initial commit.
Diffstat (limited to 'src/Codec/Wavefront/IO.hs')
-rw-r--r--src/Codec/Wavefront/IO.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Codec/Wavefront/IO.hs b/src/Codec/Wavefront/IO.hs
new file mode 100644
index 0000000..2bcf2b3
--- /dev/null
+++ b/src/Codec/Wavefront/IO.hs
@@ -0,0 +1,22 @@
1-----------------------------------------------------------------------------
2-- |
3-- Copyright : (C) 2015 Dimitri Sabadie
4-- License : BSD3
5--
6-- Maintainer : Dimitri Sabadie <dimitri.sabadie@gmail.com>
7-- Stability : experimental
8-- Portability : portable
9--
10-----------------------------------------------------------------------------
11
12module Codec.Wavefront.IO where
13
14import Codec.Wavefront.Lexer ( lexer )
15import Codec.Wavefront.Object ( WavefrontOBJ, ctxtToWavefrontOBJ )
16import Codec.Wavefront.Token ( tokenize )
17import Control.Monad.IO.Class ( MonadIO(..) )
18import qualified Data.Text.IO as T ( readFile )
19
20-- |Extract a 'WavefrontOBJ' from a Wavefront OBJ formatted file.
21fromFile :: (MonadIO m) => FilePath -> m (Either String WavefrontOBJ)
22fromFile fd = liftIO $ fmap (fmap (ctxtToWavefrontOBJ . lexer) . tokenize) (T.readFile fd)