unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.77k stars 267 forks source link

certain @typecheck blocks render with a `let` which then doesn't parse #2884

Open aryairani opened 2 years ago

aryairani commented 2 years ago

Here's a transcript to reproduce

```ucm
.docs> pull.without-history https://github.com/unisonweb/website:#8agaqj52kh
.docs> edit fundamentals.abilities.exercises.ex1
.docs> load

The transcript is in this indirect format due to #2826
aryairani commented 2 years ago

and here's that definition, for reference:

fundamentals.abilities.exercises.ex1 : Doc
fundamentals.abilities.exercises.ex1 =
  use Map get
  {{
  {{ exercise }} Exercise: Implement functions with calls to Ability operations

  Given the type signatures below, implement the functions to satisfy the
  compiler using the request operations of the Ability or functions found in
  ''.base''

  @typecheck ```
  getWithAbort : a -> Map a b ->{Abort} b
  getWithAbort key map = todo "implement me!"

{{ Folded true {{ {{ hint }} Hint: how do I see the request operations of an ability? }} {{ In the UCM, you can enter ''view Abort'' to see the ability definition. The function signatures after the ''where'' keyword are the request operations. }} }}

{{ Folded true {{ {{ answer }} Answer: }} {{ Using the {toAbort} function.

@typecheck ```
let
  getWithAbort : a -> Map a b ->{Abort} b
  getWithAbort key map = toAbort (get key map)
```

Pattern matching on {type Optional}

@typecheck ```
let
  getWithAbort : a -> Map a b ->{Abort} b
  getWithAbort key map =
    match get key map with
      Some a -> a
      None   -> abort
``` }} }}

}}

aryairani commented 2 years ago

Hopefully will fix these definitions from the repo in the description: