Link styling tweaks
This commit is contained in:
parent
5ad9ff656f
commit
972b73f665
3 changed files with 31 additions and 11 deletions
|
@ -47,7 +47,6 @@ sub site-header(BlogMeta:D $meta) is export {
|
|||
sub header-link($name, $path, $icon) {
|
||||
a :href("$path"), [
|
||||
icon $icon;
|
||||
' ';
|
||||
span $name;
|
||||
]
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ sub show-html($html) is export {
|
|||
# Work around HTML::Functional automatically putting newlines between tags
|
||||
$out ~~ s:g/'</i>' \v+ '<span>'/<\/i><span>/;
|
||||
$out ~~ s:g/\v+ '</a>'/<\/a>/;
|
||||
$out ~~ s:g/',' \v+ '<span'/,<span/;
|
||||
$out ~~ s:g/\s+ ',' \s+ '<span'/, <span/;
|
||||
# TODO: Deal with the nbsps in the header
|
||||
$out
|
||||
}
|
||||
|
||||
|
|
|
@ -11,18 +11,19 @@ unsafe variadics, and dynamic languages, like python, can do the same while
|
|||
being memory safe by not being type safe, many type safe languages, such as
|
||||
Rust, are forced to provide such functionality through the use of a macro.
|
||||
Dependently typed languages, like Idris, can provide a printf like formatting
|
||||
interface, while maintaining both memory and type saftey, without the need for
|
||||
interface, while maintaining both memory and type safety, without the need for
|
||||
the macro. We will explore this by implementing a simplified version of `printf`
|
||||
in Idris from scratch.
|
||||
|
||||
This article is inspired by an exercise from chapter 6 of [Type Driven
|
||||
Development with
|
||||
Idris](https://www.manning.com/books/type-driven-development-with-idris), and is
|
||||
written as a literate Idris file.
|
||||
This article is inspired by an exercise from chapter 6 of
|
||||
[Type Driven Development with Idris](https://www.manning.com/books/type-driven-development-with-idris),
|
||||
and is written as a literate Idris file, with the source available
|
||||
[here](https://git.stranger.systems/thatonelutenist/website/src/branch/trunk/projects/Idris/src/LessMacrosMoreTypes/Printf.md).
|
||||
|
||||
## Gameplan
|
||||
|
||||
Our goal is to provide a printf function that can be called, much like it's C equivlant, like so:
|
||||
Our goal is to provide a printf function that can be called, much like it's C
|
||||
equivalent:
|
||||
|
||||
> [!NOTE]
|
||||
> As this is a literate Idris document, and we haven't defined our `printf`
|
||||
|
@ -33,13 +34,32 @@ Our goal is to provide a printf function that can be called, much like it's C eq
|
|||
```idris
|
||||
failing
|
||||
example_usage : String
|
||||
example_usage = printf "%s %d %02d" "hello" 1 2
|
||||
example_usage = printf "%s %d %2d" "hello" 1 2
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Parsing a Format String
|
||||
|
||||
First, we need a data structure to describe our format string. We define the
|
||||
`Format` data type, with constructors for each of the format specifiers we will
|
||||
be supporting, as well as a constructor to hold literal components.
|
||||
|
||||
```idris
|
||||
data Format : Type where
|
||||
||| A slot that should be filled in with a number
|
||||
Number : (next : Format) -> Format
|
||||
||| A slot that should be filled in with a number, padded to a certian number
|
||||
||| of digits
|
||||
PaddedNumber : (digits : Nat) -> Format
|
||||
||| A slot that should be filled in with a string
|
||||
Str : (next : Format) -> Format
|
||||
||| A literal component of the format string that should not be interpolated
|
||||
Literal : (literal : String) -> (next : Format) -> Format
|
||||
||| The end of the format string
|
||||
End : Format
|
||||
```
|
||||
|
||||
## Calculating a Type From a Format String
|
||||
|
||||
## printf
|
||||
|
||||
## Working with run-time format strings
|
||||
|
|
Loading…
Add table
Reference in a new issue