Textual Haskell source
From HaskellWiki
(Difference between revisions)
m (Category) |
|||
| (2 intermediate revisions not shown.) | |||
| Line 1: | Line 1: | ||
| + | [[Category:Applications]] | ||
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). | 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). | ||
| Line 5: | Line 6: | ||
== Example 1 == | == Example 1 == | ||
| - | > showHtml :: String -> String | + | > showHtml :: String -> String |
| - | > showHtml search = pure | + | > showHtml search = pure |
| - | [html] | + | [html] |
| - | [head] | + | [head] |
| - | [title]<% search %> - Hoogle[/title] | + | [title]<% search %> - Hoogle[/title] |
| - | [/head] | + | [/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. | 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. | ||
| Line 16: | Line 17: | ||
== Example 2 == | == Example 2 == | ||
| - | > showList :: FilePath -> [Bool] -> IO String | + | > showList :: FilePath -> [Bool] -> IO String |
| - | > showList filename items = | + | > showList filename items = |
| - | > src <- readFile filename | + | > src <- readFile filename |
| - | The length of <% filename %> is <% length src %> | + | The length of <% filename %> is <% length src %> |
| - | And the booleans are | + | And the booleans are |
| - | <%for i = items %> <%if i %>ON<%else%>off<%end if%><%end for%> | + | <%for i = items %> <%if i %>ON<%else%>off<%end if%><%end for%> |
Current revision
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
1 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.
2 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%>
