lymar / hastache

Haskell implementation of Mustache template
Other
96 stars 16 forks source link

Data.Text and Generic Multiple Constructors results in error in Data.Text.Lazy #45

Open sw17ch opened 9 years ago

sw17ch commented 9 years ago

Hello,

I noticed a regression that was introduced in 0.6.1. Some git bisect'ing later, and I narrowed down the offending commit to this: fc8d09be0dc305c73b3e8b1d3f5c693e31ae18aa.

Looks like this was a pretty big change, so this is as far as I've gotten it.

Here's a file that highlights the issue. On 0.6.0, this prints t. On 0.6.1, this hits an error in Data.Text.Lazy and outputs Data.Text.Lazy.Text.toConstr. I've narrowed this error down to this line in Data.Text.Lazy which is part of the Data instance for Text involving toConstr.

{-# LANGUAGE OverloadedStrings, DeriveDataTypeable #-}
module Main (main) where

import Text.Hastache
import Text.Hastache.Context

import Data.Data
import Data.Text.Lazy hiding (unlines)
import qualified Data.Text.Lazy.IO as TL

data C = C { someText :: Text }
  deriving (Data, Typeable, Show)

main :: IO ()
main = hastacheStr defaultConfig (encodeStr template) context >>= TL.putStrLn

template :: String
template = unlines [ "{{#C}}"
                   , "{{someText}}"
                   , "{{/C}}"
                   ]

context :: MuContext IO
context = let v = C { someText = "t" }
          in mkGenericContext v

Here's the cabal file I used to build this:

name:                repro
version:             0.1.0.0
license-file:        LICENSE
author:              (me)
maintainer:          (me@place.com)
build-type:          Simple
cabal-version:       >=1.10

executable repro
  main-is: Main.hs
  build-depends:       base >=4.7 && <4.8,
                       text ==1.1.0.0,
                       hastache == 0.6.1
  default-language:    Haskell2010