summary refs log tree commit diff stats
path: root/tests/generics/tbindoncevsbindmany.nim
blob: 01e801f0e6ba0c88d23fc4cc768183477d9dce70 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
template accept(x) =
  static: assert(compiles(x))

template reject(x) =
  static: assert(not compiles(x))

type
  ObjectWithNumber = concept obj
    obj.number is int

  Foo[T] = object
    x: T

type A = object
  anumber: int

type B = object
  bnumber: int

proc number(a: A): int = a.anumber
proc number(b: B): int = b.bnumber

proc notDistincConcept1(a: ObjectWithNumber, b: ObjectWithNumber) = discard
proc notDistincConcept2(a, b: ObjectWithNumber) = discard
proc distinctConcept1(a, b: distinct ObjectWithNumber) = discard
proc distinctConcept2(a: ObjectWithNumber, b: distinct ObjectWithNumber) = discard
proc distinctConcept3(a: distinct ObjectWithNumber, b: ObjectWithNumber) = discard
proc distinctConcept4(a: distinct ObjectWithNumber, b: distinct ObjectWithNumber) = discard

var a = A(anumber: 5)
var b = B(bnumber: 6)

accept notDistincConcept1(a, a)
accept notDistincConcept1(b, b)
reject notDistincConcept2(a, b)

accept notDistincConcept2(a, a)
accept notDistincConcept2(b, b)
reject notDistincConcept2(a, b)

accept distinctConcept1(a, b)
accept distinctConcept2(a, b)
accept distinctConcept3(a, b)
accept distinctConcept4(a, b)

proc nonDistincGeneric1(a: Foo, b: Foo) = discard
proc nonDistincGeneric2(a, b: Foo) = discard
proc distinctGeneric1(a, b: distinct Foo) = discard
proc distinctGeneric2(a: distinct Foo, b: Foo) = discard
proc distinctGeneric3(a: Foo, b: distinct Foo) = discard
proc distinctGeneric4(a: distinct Foo, b: distinct Foo) = discard

var f1 = Foo[int](x: 10)
var f2 = Foo[string](x: "x")

accept nonDistincGeneric1(f1, f1)
accept nonDistincGeneric1(f2, f2)
reject nonDistincGeneric1(f1, f2)

accept nonDistincGeneric2(f1, f1)
accept nonDistincGeneric2(f2, f2)
reject nonDistincGeneric2(f1, f2)

accept distinctGeneric1(f1, f1)
accept distinctGeneric2(f1, f1)
accept distinctGeneric3(f1, f1)
accept distinctGeneric4(f1, f1)
                                                                                                     







                                                                                                                                                                                    
          
                   
                                                                         
          


        
<!DOCTYPE PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/1/DTD/1-strict.dtd">
<html xmlns="http://www.w3.org/1999/" lang="en" xml:lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta name="application-name" content="getwtxt {{.Vers}}">
  <link rel="stylesheet" type="text/css" href="/css">
  <title>{{.Name}} - twtxt Registry</title>
</head>
<body>
  <div id="container">
    <div id="head">
      <h2>{{.Name}}</h2>
    </div>
    <div id="subhead">
      twtxt registry
    </div>
    <div id="info">
      Instance Owner:<br />
      <span style="padding-left:1em">{{.Owner}}</span><br />
      Mail:<br />
      <span style="padding-left:1em">{{.Mail}}</span><br />
    </div>
    <div id="body">
      <div id="desc">
        <p>{{.Desc}}</p>
      </div>
      <p>API base URL:</p>
        <pre><code>/api</code></pre>
      <p>Formats available:</p>
        <pre><code>/api/plain</code></pre>
      <p>Endpoints:</p>
        <pre><code>/api/plain/users
/api/plain/mentions
/api/plain/tweets
/api/plain/tags</code></pre>
        <p>Add new user by submitting a <code>POST</code> request to the <code>/api/plain/users</code> endpoint. 
        If both <code>?url=X</code> and <code>?nickname=X</code> are not passed, or the user already exists in 
        this registry, you will receive <code>400 Bad Request</code> as a response. If you are unsure what went
        wrong, the error message should provide enough information for you to correct the request.</p>
        <pre><code>$ curl -X POST '{{.URL}}/api/plain/users?url=https://foo.ext/twtxt.txt&amp;nickname=foobar'
200 OK</code></pre>
      <p>Query responses are in descending chronological order. This means the newest user or tweet will be in the
      first row of the response, with older users or tweets in subsequent rows. Additionally, All queries accept <code>?page=N</code> 
      as a parameter, returning groups of 20 results. This may be omitted for the first page of results.</p>
      <p>Get all users:</p>
        <pre><code>$ curl '{{.URL}}/api/plain/users'
foo               https://example.com/twtxt.txt     2019-05-09T08:42:23.000Z
foobar            https://example2.com/twtxt.txt    2019-04-14T19:23:00.000Z
foo_barrington    https://example3.com/twtxt.txt    2019-03-01T15:59:39.000Z</code></pre>
      <p>Query for user by URL:</p>
        <pre><code>$ curl '{{.URL}}/api/plain/users?url=https://example3.com/twtxt.txt'
foo_barrington    https://example3.com/twtxt.txt    2019-05-01T15:59:39.000Z</code></pre>
      <p>Query for user by keyword:</p>
        <pre><code>$ curl '{{.URL}}/api/plain/users?q=bar'
foobar            https://example2.com/twtxt.txt    2019-05-14T19:23:00.000Z
foo_barrington    https://example3.com/twtxt.txt    2019-04-01T15:59:39.000Z</code></pre>
      <p>Get all tweets:</p>
        <pre><code>$ curl '{{.URL}}/api/plain/tweets'
foobar    https://example2.com/twtxt.txt    2019-05-13T12:46:20.000Z    It's been a busy day at work!
...</code></pre>
      <p>Query tweets by keyword:</p>
        <pre><code>$ curl '{{.URL}}/api/plain/tweets?q=getwtxt'
foo_barrington    https://example3.com/twtxt.txt    2019-04-30T06:00:09.000Z    I just installed getwtxt</code></pre>
      <p>Get all tweets with tags:</p>
        <pre><code>$ curl '{{.URL}}/api/plain/tags'
foo    https://example.com/twtxt.txt    2019-03-01T09:33:12.000Z    No, seriously, I need #help
foo    https://example.com/twtxt.txt    2019-03-01T09:32:05.000Z    Seriously, I love #programming!
foo    https://example.com/twtxt.txt    2019-03-01T09:31:02.000Z    I love #programming!</code></pre>
      <p>Query tweets by tag:</p>
        <pre><code>$ curl '{{.URL}}/api/plain/tags/programming'
foo    https://example.com/twtxt.txt    2019-03-01T09:31:02.000Z    I love #programming!</code></pre>
      <p>Get all tweets with mentions:</p>
        <pre><code>$ curl '{{.URL}}/api/plain/mentions'
foo               https://example.com/twtxt.txt     2019-02-28T11:06:44.000Z    @&lt;foo_barrington https://example3.com/twtxt.txt&gt; Hey!! Are you still working on that project?
bar               https://mxmmplm.com/twtxt.txt     2019-02-27T11:06:44.000Z    @&lt;foobar https://example2.com/twtxt.txt&gt; How's your day going, bud?
foo_barrington    https://example3.com/twtxt.txt    2019-02-26T11:06:44.000Z    @&lt;foo https://example.com/twtxt.txt&gt; Did you eat my lunch?</code></pre>
      <p>Query tweets by mention URL:</p>
        <pre><code>$ curl '{{.URL}}/api/plain/mentions?url=https://foobarrington.co.uk/twtxt.txt'
foo    https://example.com/twtxt.txt    2019-02-26T11:06:44.000Z    @&lt;foo_barrington https://example3.com/twtxt.txt&gt; Hey!! Are you still working on that project?</code></pre>
    </div>
    <div id="foot">
      powered by <a href="https://github.com/getwtxt/getwtxt">getwtxt</a>
    </div>
  </div>
</body>
</html>