-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b35c49
commit 19cf0a1
Showing
6 changed files
with
26 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- | Wrappers for Yaml functions to workaround | ||
-- https://github.com/commercialhaskell/stack/issues/2491. | ||
-- Import Data.Yaml.Extra in place of Data.Yaml to use this workaround. | ||
-- Beware these functions construct/deconstruct the entire file at once! | ||
module Data.Yaml.Extra (decodeFileEither, encodeFile, module Data.Yaml) where | ||
|
||
import Data.Yaml hiding (decodeFileEither, encodeFile) | ||
import qualified Data.ByteString as B | ||
import System.IO | ||
|
||
decodeFileEither :: FromJSON a => FilePath -> IO (Either ParseException a) | ||
decodeFileEither path = withFile path ReadMode $ | ||
\hnd -> do | ||
fileContent <- B.hGetContents hnd | ||
return $ decodeEither' fileContent | ||
|
||
encodeFile :: ToJSON a => FilePath -> a -> IO () | ||
encodeFile path v = withFile path WriteMode $ | ||
\hnd -> do | ||
let fileContent = encode v | ||
B.hPut hnd fileContent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters