diff options
author | Joe Crayne <joe@jerkface.net> | 2019-06-10 23:03:04 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-06-10 23:03:04 -0400 |
commit | 38b7bcf654e5e804a13518b060ebdba59bf232bb (patch) | |
tree | 2fa3c4ccf3496750f0ce388a9ea0998fdd93bf69 /src/Codec/Wavefront/IO.hs |
Initial commit.
Diffstat (limited to 'src/Codec/Wavefront/IO.hs')
-rw-r--r-- | src/Codec/Wavefront/IO.hs | 22 |
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 | |||
12 | module Codec.Wavefront.IO where | ||
13 | |||
14 | import Codec.Wavefront.Lexer ( lexer ) | ||
15 | import Codec.Wavefront.Object ( WavefrontOBJ, ctxtToWavefrontOBJ ) | ||
16 | import Codec.Wavefront.Token ( tokenize ) | ||
17 | import Control.Monad.IO.Class ( MonadIO(..) ) | ||
18 | import qualified Data.Text.IO as T ( readFile ) | ||
19 | |||
20 | -- |Extract a 'WavefrontOBJ' from a Wavefront OBJ formatted file. | ||
21 | fromFile :: (MonadIO m) => FilePath -> m (Either String WavefrontOBJ) | ||
22 | fromFile fd = liftIO $ fmap (fmap (ctxtToWavefrontOBJ . lexer) . tokenize) (T.readFile fd) | ||