Textual Haskell source

From HaskellWiki
Revision as of 18:38, 8 October 2006 by BrettGiles (talk | contribs) (Textual Haskell Source moved to Textual Haskell source)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Files with a .ths extension can be Textual Haskell Source. Currently you have .hs (source code is the main thing), .lhs (comments are the main thing) and now you have .ths (text is the main thing).

The code: darcs get http://www.cs.york.ac.uk/fp/darcs/ths

Example 1

> showHtml :: String -> String
> showHtml search = pure
[html]
[head]
[title]<% search %> - Hoogle[/title]
[/head]

Note that in this example I am escaping the code (with > ticks), and the text is just the main bit. I also have which is substituted inline.

Example 2

> showList :: FilePath -> [Bool] -> IO String
> showList filename items =
> src <- readFile filename
The length of <% filename %> is <% length src %>
And the booleans are
<%for i = items %> <%if i %>ON<%else%>off<%end if%><%end for%>