{-# options_ghc -Wno-unused-imports -Wno-type-defaults #-} module Algebra.Graph.IO.Datasets where import Algebra.Graph (Graph) import Algebra.Graph.IO.GML (GMLGraph, gmlGraph, gmlGraphP) import Algebra.Graph.IO.Internal.Megaparsec (Parser, anyString) import Text.Megaparsec (parse) import Text.Megaparsec.Error (errorBundlePretty) import Text.Megaparsec.Char.Lexer (decimal) import Data.Text.IO (readFile) import Prelude hiding (readFile) lesMiserables :: IO (Graph Int) lesMiserables :: IO (Graph Int) lesMiserables = do Text t <- FilePath -> IO Text readFile FilePath "assets/lesmiserables.gml" case Parsec Void Text (GMLGraph Int Integer) -> FilePath -> Text -> Either (ParseErrorBundle Text Void) (GMLGraph Int Integer) forall e s a. Parsec e s a -> FilePath -> s -> Either (ParseErrorBundle s e) a parse (Parser Int -> Parser Integer -> Parsec Void Text (GMLGraph Int Integer) forall a b. Parser a -> Parser b -> Parser (GMLGraph a b) gmlGraphP Parser Int forall e s (m :: * -> *) a. (MonadParsec e s m, Token s ~ Char, Num a) => m a decimal Parser Integer forall e s (m :: * -> *) a. (MonadParsec e s m, Token s ~ Char, Num a) => m a decimal) FilePath "" Text t of Right GMLGraph Int Integer gg -> Graph Int -> IO (Graph Int) forall (f :: * -> *) a. Applicative f => a -> f a pure (Graph Int -> IO (Graph Int)) -> Graph Int -> IO (Graph Int) forall a b. (a -> b) -> a -> b $ GMLGraph Int Integer -> Graph Int forall a b. GMLGraph a b -> Graph a gmlGraph GMLGraph Int Integer gg Left ParseErrorBundle Text Void e -> FilePath -> IO (Graph Int) forall a. HasCallStack => FilePath -> a error (FilePath -> IO (Graph Int)) -> FilePath -> IO (Graph Int) forall a b. (a -> b) -> a -> b $ ParseErrorBundle Text Void -> FilePath forall s e. (VisualStream s, TraversableStream s, ShowErrorComponent e) => ParseErrorBundle s e -> FilePath errorBundlePretty ParseErrorBundle Text Void e karateClub :: IO (Graph Int) karateClub :: IO (Graph Int) karateClub = do Text t <- FilePath -> IO Text readFile FilePath "assets/karate.gml" case Parsec Void Text (GMLGraph Int FilePath) -> FilePath -> Text -> Either (ParseErrorBundle Text Void) (GMLGraph Int FilePath) forall e s a. Parsec e s a -> FilePath -> s -> Either (ParseErrorBundle s e) a parse (Parser Int -> Parser FilePath -> Parsec Void Text (GMLGraph Int FilePath) forall a b. Parser a -> Parser b -> Parser (GMLGraph a b) gmlGraphP Parser Int forall e s (m :: * -> *) a. (MonadParsec e s m, Token s ~ Char, Num a) => m a decimal Parser FilePath anyString) FilePath "" Text t of Right GMLGraph Int FilePath gg -> Graph Int -> IO (Graph Int) forall (f :: * -> *) a. Applicative f => a -> f a pure (Graph Int -> IO (Graph Int)) -> Graph Int -> IO (Graph Int) forall a b. (a -> b) -> a -> b $ GMLGraph Int FilePath -> Graph Int forall a b. GMLGraph a b -> Graph a gmlGraph GMLGraph Int FilePath gg Left ParseErrorBundle Text Void e -> FilePath -> IO (Graph Int) forall a. HasCallStack => FilePath -> a error (FilePath -> IO (Graph Int)) -> FilePath -> IO (Graph Int) forall a b. (a -> b) -> a -> b $ ParseErrorBundle Text Void -> FilePath forall s e. (VisualStream s, TraversableStream s, ShowErrorComponent e) => ParseErrorBundle s e -> FilePath errorBundlePretty ParseErrorBundle Text Void e