Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Functor instance for Token' #3

merged 1 commit into from

2 participants

Michael Snoyman yihuang
Michael Snoyman

I've actually implemented this function and am using it in html-conduit. It would be convenient to have it upstream.

yihuang yihuang merged commit f3e7246 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 7, 2012
  1. Michael Snoyman

    Functor instance for Token'

    snoyberg authored
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 0 deletions.
  1. +9 −0 Text/HTML/TagStream/Types.hs
9 Text/HTML/TagStream/Types.hs
@@ -5,6 +5,7 @@ import Data.Monoid
import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as S
import Blaze.ByteString.Builder (Builder, fromByteString, toByteString)
+import Control.Arrow ((***))
type Attr' s = (s, s)
type Attr = Attr' ByteString
@@ -47,3 +48,11 @@ encode = encodeHL id
encodeHL :: (ByteString -> ByteString) -> [Token] -> ByteString
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)
Something went wrong with that request. Please try again.