Last active
December 26, 2015 04:39
-
-
Save tonymorris/7095376 to your computer and use it in GitHub Desktop.
Run doctest on Link.hs and succeeds. Run doctest on Person.hs, which runs Link.hs and fails with failed unpickling.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- GHC 7.6.3 | |
:load Test/Person.hs | |
fmap (unpickleDoc' xpAuthorElem) . runLA xread $ "<author><link/></author>" -- this succeeds | |
:reload | |
fmap (unpickleDoc' xpLinkElem) . runLA xread $ "<link/>" -- this fails | |
fmap (unpickleDoc' xpAuthorElem) . runLA xread $ "<author><link/></author>" -- this fails in the same way, even though it is the same expression | |
:reload | |
fmap (unpickleDoc' xpAuthorElem) . runLA xread $ "<author><link/></author>" -- now it is working again |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Test/Link.hs | |
module Test.Link where | |
import Text.XML.HXT.Core | |
data Link = | |
Link | |
deriving Show | |
-- | | |
-- | |
-- >>> fmap (unpickleDoc' xpLinkElem) . runLA xread $ "<link/>" | |
-- [Right Link] | |
xpLinkElem :: | |
PU Link | |
xpLinkElem = | |
xpElem "link" | |
(xpWrap (const Link, const ()) | |
xpUnit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Test/Person.hs | |
module Test.Person where | |
import Test.Link(Link, xpLinkElem) | |
import Text.XML.HXT.Core | |
data Person = | |
Person Link | |
deriving Show | |
-- | | |
-- | |
-- >>> fmap (unpickleDoc' xpAuthorElem) . runLA xread $ "<author><link/></author>" | |
-- [Right (Person Link)] | |
xpAuthorElem:: | |
PU Person | |
xpAuthorElem = | |
xpElem "author" | |
(xpWrap | |
(Person, \(Person l) -> l) | |
xpLinkElem) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/sh | |
cabal sandbox init | |
cabal install hxt-9.3.1.1 | |
mkdir -p Test | |
wget https://gist.github.com/tonymorris/7095376/raw/c2bb6d107ae97e52c89807877baa04db56153084/Link.hs -O Test/Link.hs -q -c | |
wget https://gist.github.com/tonymorris/7095376/raw/cbc4aa4bbbbca38979e18cb8620c5fb7748cc28b/Person.hs -O Test/Person.hs -q -c | |
wget -c -q https://gist.github.com/tonymorris/7095376/raw/6f605e841ccb94d37626ea999c944a592e4d9247/.ghci -O .ghci -q -c | |
ghci -package-conf `find .cabal-sandbox -name "*-packages.conf.d"` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% ghc --version [issue-1] | |
The Glorious Glasgow Haskell Compilation System, version 7.6.3 | |
% cabal sandbox hc-pkg list | grep hxt [issue-1] | |
hxt-9.3.1.1 | |
hxt-charproperties-9.1.1.1 | |
hxt-regex-xmlschema-9.1.0 | |
hxt-unicode-9.0.2.1 | |
% cabal sandbox hc-pkg list | grep doctest [issue-1] | |
doctest-0.9.9 | |
% ./.cabal-sandbox/bin/doctest Test/Link.hs | |
Examples: 1 Tried: 1 Errors: 0 Failures: 0 | |
% ./.cabal-sandbox/bin/doctest Test/Person.hs | |
### Failure in ./Test/Link.hs:13: expression `fmap (unpickleDoc' xpLinkElem) . runLA xread $ "<link/>"' | |
expected: [Right Link] | |
but got: [Left "xpElem: got element name \"link\", but expected \"link\"\ncontext: element \"/\""] | |
Examples: 2 Tried: 2 Errors: 0 Failures: 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment