-
Notifications
You must be signed in to change notification settings - Fork 723
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New File type that tracks whether the file is an input or output file…
… or both.
- Loading branch information
Showing
59 changed files
with
715 additions
and
645 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | ||
{-# LANGUAGE InstanceSigs #-} | ||
{-# LANGUAGE KindSignatures #-} | ||
|
||
module Cardano.Api.IO | ||
( File(..) | ||
, In | ||
, Out | ||
, InOut | ||
, HasFileMode(..) | ||
) where | ||
|
||
import Data.Kind (Type) | ||
import Data.String (IsString) | ||
|
||
-- | Phantom type to indicate a file for reading. | ||
data In | ||
|
||
-- | Phantom type to indicate a file for writing. | ||
data Out | ||
|
||
-- | Phantom type to indicate a file for reading or writing. | ||
data InOut | ||
|
||
-- | A file path with additional type information to indicate whether it is to | ||
-- be used for reading or writing. | ||
newtype File direction = File { unFile :: FilePath } | ||
deriving (Eq, Ord) | ||
deriving newtype (Show, IsString) | ||
|
||
class HasFileMode (f :: Type -> Type) where | ||
usingIn :: f InOut -> f In | ||
usingOut :: f InOut -> f Out | ||
|
||
instance HasFileMode File where | ||
usingIn :: File InOut -> File In | ||
usingIn = File . unFile | ||
|
||
usingOut :: File InOut -> File Out | ||
usingOut = File . unFile |
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
Oops, something went wrong.