File: Types.hs

package info (click to toggle)
haskell-pem 0.2.4-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 76 kB
  • sloc: haskell: 197; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 982 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
-- |
-- Module      : Data.PEM.Types
-- License     : BSD-style
-- Maintainer  : Vincent Hanquez <vincent@snarc.org>
-- Stability   : experimental
-- Portability : portable
--
module Data.PEM.Types where

import Data.ByteString (ByteString)
import Basement.NormalForm

-- | Represent one PEM section
--
-- for now headers are not serialized at all.
-- this is just available here as a placeholder for a later implementation.
data PEM = PEM
    { pemName    :: String                 -- ^ the name of the section, found after the dash BEGIN tag.
    , pemHeader  :: [(String, ByteString)] -- ^ optionals key value pair header
    , pemContent :: ByteString             -- ^ binary content of the section
    } deriving (Show,Eq)

instance NormalForm PEM where
    toNormalForm pem =
        toNormalForm (pemName pem) `seq` nfLbs (pemHeader pem) `seq` pemContent pem `seq` ()
      where
        nfLbs []         = ()
        nfLbs ((s,bs):l) = toNormalForm s `seq` bs `seq` nfLbs l