{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}

{-|
Description : Example of reading a ABIF file
Copyright   : (c) HyraxBio, 2018
License     : BSD3
Maintainer  : andre@hyraxbio.co.za, andre@andrevdm.com

Example of reading a ABIF file.
See other examples in "Examples"
-}
module Examples.ReadAb1 where

import           Protolude

import qualified Hyrax.Abif.Read as H

-- | Read and print a ABIF file
readAbif :: IO ()
readAbif :: IO ()
readAbif = do
  Either Text Abif
abif' <- FilePath -> IO (Either Text Abif)
H.readAbif FilePath
"example.ab1"

  case Either Text Abif
abif' of
    Left Text
e -> forall a (m :: * -> *). (Print a, MonadIO m) => a -> m ()
putStrLn forall a b. (a -> b) -> a -> b
$ Text
"error reading ABIF: " forall a. Semigroup a => a -> a -> a
<> Text
e
    Right Abif
abif ->
      -- Print after removing the data, to make it readable
      forall (m :: * -> *) a. (MonadIO m, Show a) => a -> m ()
print forall a b. (a -> b) -> a -> b
$ Abif -> Abif
H.clearAbif Abif
abif