Skip to content

Commit

Permalink
Merge pull request #3 from snoyberg/master
Browse files Browse the repository at this point in the history
Functor instance for Token'
  • Loading branch information
yihuang committed May 7, 2012
2 parents 4ddde6c + 4349c4e commit f3e7246
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Text/HTML/TagStream/Types.hs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Data.Monoid
import Data.ByteString (ByteString) import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as S import qualified Data.ByteString.Char8 as S
import Blaze.ByteString.Builder (Builder, fromByteString, toByteString) import Blaze.ByteString.Builder (Builder, fromByteString, toByteString)
import Control.Arrow ((***))


type Attr' s = (s, s) type Attr' s = (s, s)
type Attr = Attr' ByteString type Attr = Attr' ByteString
Expand Down Expand Up @@ -47,3 +48,11 @@ encode = encodeHL id


encodeHL :: (ByteString -> ByteString) -> [Token] -> ByteString encodeHL :: (ByteString -> ByteString) -> [Token] -> ByteString
encodeHL hl = toByteString . mconcat . map (showToken hl) encodeHL hl = toByteString . mconcat . map (showToken hl)

instance Functor Token' where
fmap f (TagOpen x pairs b) = TagOpen (f x) (map (f *** f) pairs) b
fmap f (TagClose x) = TagClose (f x)
fmap f (Text x) = Text (f x)
fmap f (Comment x) = Comment (f x)
fmap f (Special x y) = Special (f x) (f y)
fmap f (Incomplete x) = Incomplete (f x)

0 comments on commit f3e7246

Please sign in to comment.