@@ -14,7 +14,7 @@ module Semantic.Task.Files
1414 , Handle (.. )
1515 , FilesC (.. )
1616 , FilesArg (.. )
17- , Excludes (.. )
17+ , PathFilter (.. )
1818 ) where
1919
2020import Control.Effect.Carrier
@@ -36,15 +36,17 @@ data Source blob where
3636 FromPath :: File -> Source Blob
3737 FromHandle :: Handle 'IO.ReadMode -> Source [Blob ]
3838 FromDir :: FilePath -> Source [Blob ]
39- FromGitRepo :: FilePath -> Git. OID -> Excludes -> Source [Blob ]
39+ FromGitRepo :: FilePath -> Git. OID -> PathFilter -> Source [Blob ]
4040 FromPathPair :: Both File -> Source BlobPair
4141 FromPairHandle :: Handle 'IO.ReadMode -> Source [BlobPair ]
4242
4343data Destination = ToPath FilePath | ToHandle (Handle 'IO.WriteMode )
4444
45- data Excludes
45+ data PathFilter
4646 = ExcludePaths [FilePath ]
4747 | ExcludeFromHandle (Handle 'IO.ReadMode )
48+ | IncludePaths [FilePath ]
49+ | IncludePathsFromHandle (Handle 'IO.ReadMode )
4850
4951-- | An effect to read/write 'Blob's from 'Handle's or 'FilePath's.
5052data Files (m :: * -> * ) k
@@ -80,8 +82,10 @@ instance (Member (Error SomeException) sig, Member Catch sig, MonadIO m, Carrier
8082 Read (FromPath path) k -> rethrowing (readBlobFromFile' path) >>= k
8183 Read (FromHandle handle) k -> rethrowing (readBlobsFromHandle handle) >>= k
8284 Read (FromDir dir) k -> rethrowing (readBlobsFromDir dir) >>= k
83- Read (FromGitRepo path sha (ExcludePaths excludePaths)) k -> rethrowing (readBlobsFromGitRepo path sha excludePaths) >>= k
84- Read (FromGitRepo path sha (ExcludeFromHandle handle)) k -> rethrowing (readPathsFromHandle handle >>= readBlobsFromGitRepo path sha) >>= k
85+ Read (FromGitRepo path sha (ExcludePaths excludePaths)) k -> rethrowing (readBlobsFromGitRepo path sha excludePaths mempty ) >>= k
86+ Read (FromGitRepo path sha (ExcludeFromHandle handle)) k -> rethrowing (readPathsFromHandle handle >>= (\ x -> readBlobsFromGitRepo path sha x mempty )) >>= k
87+ Read (FromGitRepo path sha (IncludePaths includePaths)) k -> rethrowing (readBlobsFromGitRepo path sha mempty includePaths) >>= k
88+ Read (FromGitRepo path sha (IncludePathsFromHandle h)) k -> rethrowing (readPathsFromHandle h >>= readBlobsFromGitRepo path sha mempty ) >>= k
8589 Read (FromPathPair paths) k -> rethrowing (runBothWith readFilePair paths) >>= k
8690 Read (FromPairHandle handle) k -> rethrowing (readBlobPairsFromHandle handle) >>= k
8791 ReadProject rootDir dir language excludeDirs k -> rethrowing (readProjectFromPaths rootDir dir language excludeDirs) >>= k
@@ -96,7 +100,7 @@ readBlob file = send (Read (FromPath file) pure)
96100data FilesArg
97101 = FilesFromHandle (Handle 'IO.ReadMode )
98102 | FilesFromPaths [File ]
99- | FilesFromGitRepo FilePath Git. OID Excludes
103+ | FilesFromGitRepo FilePath Git. OID PathFilter
100104
101105-- | A task which reads a list of 'Blob's from a 'Handle' or a list of 'FilePath's optionally paired with 'Language's.
102106readBlobs :: (Member Files sig , Carrier sig m , MonadIO m ) => FilesArg -> m [Blob ]
@@ -107,7 +111,7 @@ readBlobs (FilesFromPaths [path]) = do
107111 then send (Read (FromDir (filePath path)) pure )
108112 else pure <$> send (Read (FromPath path) pure )
109113readBlobs (FilesFromPaths paths) = traverse (send . flip Read pure . FromPath ) paths
110- readBlobs (FilesFromGitRepo path sha excludes ) = send (Read (FromGitRepo path sha excludes ) pure )
114+ readBlobs (FilesFromGitRepo path sha filter ) = send (Read (FromGitRepo path sha filter ) pure )
111115
112116-- | A task which reads a list of pairs of 'Blob's from a 'Handle' or a list of pairs of 'FilePath's optionally paired with 'Language's.
113117readBlobPairs :: (Member Files sig , Carrier sig m ) => Either (Handle 'IO.ReadMode ) [Both File ] -> m [BlobPair ]
0 commit comments