core: derive classics for BaseEncoding enum

This commit is contained in:
sorki 2023-11-30 06:03:23 +01:00
parent e950c84408
commit 1702fa0abf

View File

@ -6,6 +6,7 @@ module System.Nix.Base
import Data.ByteString (ByteString) import Data.ByteString (ByteString)
import Data.Text (Text) import Data.Text (Text)
import GHC.Generics (Generic)
import qualified Data.Text.Encoding import qualified Data.Text.Encoding
import qualified Data.ByteString.Base16 import qualified Data.ByteString.Base16
@ -21,6 +22,7 @@ data BaseEncoding
-- & NixBase seems be the most widely used in Nix. -- & NixBase seems be the most widely used in Nix.
| Base16 | Base16
| Base64 | Base64
deriving (Bounded, Eq, Enum, Generic, Ord, Show)
-- | Encode @ByteString@ with @Base@ encoding, produce @Text@. -- | Encode @ByteString@ with @Base@ encoding, produce @Text@.
encodeWith :: BaseEncoding -> ByteString -> Text encodeWith :: BaseEncoding -> ByteString -> Text