on master help sign in
Update tutorial for class->interface
23a2bfbEdwin Brady
docs/tutorial/index.rst+1−1
@@ -21,7 +21,7 @@ The is the Idris Tutorial. It will teach you about programming in the Idris Lang
21 introduction
21 introduction
22 starting
22 starting
23 typesfuns
23 typesfuns
24− classes
24+ interfaces
25 modules
25 modules
26 packages
26 packages
27 testing
27 testing
docs/tutorial/classes.rst → docs/tutorial/interfaces.rstrenamed+89−91
@@ -1,8 +1,8 @@
1.. _sect-classes:
1.. _sect-classes:
2
2
3−************
3+**********
4−Type Classes
4+Interfaces
5−************
5+**********
6
6
7We often want to define functions which work across several different
7We often want to define functions which work across several different
8data types. For example, we would like arithmetic operators to work on
8data types. For example, we would like arithmetic operators to work on
@@ -10,34 +10,33 @@ data types. For example, we would like arithmetic operators to work on
10``==`` to work on the majority of data types. We would like to be able
10``==`` to work on the majority of data types. We would like to be able
11to display different types in a uniform way.
11to display different types in a uniform way.
12
12
13−To achieve this, we use a feature which has proved to be effective in
13+To achieve this, we use *interfaces*, which are similar to type classes in
14−Haskell, namely *type classes*. To define a type class, we provide a
14+Haskell or traits in Rust. To define an interface, we provide a collection of
15−collection of overloaded operations which describe the interface for
16−*instances* of that class. A simple example is the ``Show`` type
15+overloadable functions. A simple example is the ``Show``
17−class, which is defined in the prelude and provides an interface for
16+interface, which is defined in the prelude and provides an interface for
18converting values to ``String``:
17converting values to ``String``:
19
18
20.. code-block:: idris
19.. code-block:: idris
21
20
22− class Show a where
21+ interface Show a where
23 show : a -> String
22 show : a -> String
24
23
25This generates a function of the following type (which we call a
24This generates a function of the following type (which we call a
26−*method* of the ``Show`` class):
25+*method* of the ``Show`` interface):
27
26
28.. code-block:: idris
27.. code-block:: idris
29
28
30 show : Show a => a -> String
29 show : Show a => a -> String
31
30
32−We can read this as: “under the constraint that ``a`` is an instance
31+We can read this as: “under the constraint that ``a`` has an implementation
33−of ``Show``, take an input ``a`` and return a ``String``.” An instance
32+of ``Show``, take an input ``a`` and return a ``String``.” An implementation
34−of a class is defined with an ``instance`` declaration, which provides
33+of an interface is defined by giving definitions of the methods of the interface.
35−implementations of the function for a specific type. For example, the
34+For example, the
36−``Show`` instance for ``Nat`` could be defined as:
35+``Show`` implementation for ``Nat`` could be defined as:
37
36
38.. code-block:: idris
37.. code-block:: idris
39
38
40− instance Show Nat where
39+ Show Nat where
41 show Z = "Z"
40 show Z = "Z"
42 show (S k) = "s" ++ show k
41 show (S k) = "s" ++ show k
43
42
@@ -46,18 +45,18 @@ implementations of the function for a specific type. For example, the
46 Idris> show (S (S (S Z)))
45 Idris> show (S (S (S Z)))
47 "sssZ" : String
46 "sssZ" : String
48
47
49−Only one instance of a class can be given for a type — instances may
48+Only one implementation of an interface can be given for a type — implementations may
50−not overlap. Instance declarations can themselves have constraints.
49+not overlap. Implementation declarations can themselves have constraints.
51−To help with resolution, the arguments of an instance must be
50+To help with resolution, the arguments of an implementation must be
52constructors (either data or type constructors), variables or
51constructors (either data or type constructors), variables or
53−constants (i.e. you cannot give an instance for a function). For
52+constants (i.e. you cannot give an implementation for a function). For
54−example, to define a ``Show`` instance for vectors, we need to know
53+example, to define a ``Show`` implementation for vectors, we need to know
55−that there is a ``Show`` instance for the element type, because we are
54+that there is a ``Show`` implementation for the element type, because we are
56going to use it to convert each element to a ``String``:
55going to use it to convert each element to a ``String``:
57
56
58.. code-block:: idris
57.. code-block:: idris
59
58
60− instance Show a => Show (Vect n a) where
59+ Show a => Show (Vect n a) where
61 show xs = "[" ++ show' xs ++ "]" where
60 show xs = "[" ++ show' xs ++ "]" where
62 show' : Vect n a -> String
61 show' : Vect n a -> String
63 show' Nil = ""
62 show' Nil = ""
@@ -67,22 +66,22 @@ going to use it to convert each element to a ``String``:
67Default Definitions
66Default Definitions
68===================
67===================
69
68
70−The library defines an ``Eq`` class which provides an interface for
69+The library defines an ``Eq`` interface which provides methods for
71−comparing values for equality or inequality, with instances for all of
70+comparing values for equality or inequality, with implementations for all of
72the built-in types:
71the built-in types:
73
72
74.. code-block:: idris
73.. code-block:: idris
75
74
76− class Eq a where
75+ interface Eq a where
77 (==) : a -> a -> Bool
76 (==) : a -> a -> Bool
78 (/=) : a -> a -> Bool
77 (/=) : a -> a -> Bool
79
78
80−To declare an instance of a type, we have to give definitions of all
79+To declare an implementation for a type, we have to give definitions of all
81−of the methods. For example, for an instance of ``Eq`` for ``Nat``:
80+of the methods. For example, for an implementation of ``Eq`` for ``Nat``:
82
81
83.. code-block:: idris
82.. code-block:: idris
84
83
85− instance Eq Nat where
84+ Eq Nat where
86 Z == Z = True
85 Z == Z = True
87 (S x) == (S y) = x == y
86 (S x) == (S y) = x == y
88 Z == (S y) = False
87 Z == (S y) = False
@@ -93,28 +92,28 @@ of the methods. For example, for an instance of ``Eq`` for ``Nat``:
93It is hard to imagine many cases where the ``/=`` method will be
92It is hard to imagine many cases where the ``/=`` method will be
94anything other than the negation of the result of applying the ``==``
93anything other than the negation of the result of applying the ``==``
95method. It is therefore convenient to give a default definition for
94method. It is therefore convenient to give a default definition for
96−each method in the class declaration, in terms of the other method:
95+each method in the interface declaration, in terms of the other method:
97
96
98.. code-block:: idris
97.. code-block:: idris
99
98
100− class Eq a where
99+ interface Eq a where
101 (==) : a -> a -> Bool
100 (==) : a -> a -> Bool
102 (/=) : a -> a -> Bool
101 (/=) : a -> a -> Bool
103
102
104 x /= y = not (x == y)
103 x /= y = not (x == y)
105 x == y = not (x /= y)
104 x == y = not (x /= y)
106
105
107−A minimal complete definition of an ``Eq`` instance requires either
106+A minimal complete implementation of ``Eq`` requires either
108``==`` or ``/=`` to be defined, but does not require both. If a method
107``==`` or ``/=`` to be defined, but does not require both. If a method
109definition is missing, and there is a default definition for it, then
108definition is missing, and there is a default definition for it, then
110the default is used instead.
109the default is used instead.
111
110
112−Extending Classes
111+Extending Interfaces
113−=================
112+====================
114
113
115−Classes can also be extended. A logical next step from an equality
114+Interfaces can also be extended. A logical next step from an equality
116relation ``Eq`` is to define an ordering relation ``Ord``. We can
115relation ``Eq`` is to define an ordering relation ``Ord``. We can
117−define an ``Ord`` class which inherits methods from ``Eq`` as well as
116+define an ``Ord`` interface which inherits methods from ``Eq`` as well as
118defining some of its own:
117defining some of its own:
119
118
120.. code-block:: idris
119.. code-block:: idris
@@ -123,7 +122,7 @@ defining some of its own:
123
122
124.. code-block:: idris
123.. code-block:: idris
125
124
126− class Eq a => Ord a where
125+ interface Eq a => Ord a where
127 compare : a -> a -> Ordering
126 compare : a -> a -> Ordering
128
127
129 (<) : a -> a -> Bool
128 (<) : a -> a -> Bool
@@ -133,11 +132,11 @@ defining some of its own:
133 max : a -> a -> a
132 max : a -> a -> a
134 min : a -> a -> a
133 min : a -> a -> a
135
134
136−The ``Ord`` class allows us to compare two values and determine their
135+The ``Ord`` interface allows us to compare two values and determine their
137ordering. Only the ``compare`` method is required; every other method
136ordering. Only the ``compare`` method is required; every other method
138has a default definition. Using this we can write functions such as
137has a default definition. Using this we can write functions such as
139``sort``, a function which sorts a list into increasing order,
138``sort``, a function which sorts a list into increasing order,
140−provided that the element type of the list is in the ``Ord`` class. We
139+provided that the element type of the list is in the ``Ord`` interface. We
141give the constraints on the type variables left of the fat arrow
140give the constraints on the type variables left of the fat arrow
142``=>``, and the function type to the right of the fat arrow:
141``=>``, and the function type to the right of the fat arrow:
143
142
@@ -145,7 +144,7 @@ give the constraints on the type variables left of the fat arrow
145
144
146 sort : Ord a => List a -> List a
145 sort : Ord a => List a -> List a
147
146
148−Functions, classes and instances can have multiple
147+Functions, interfaces and implementations can have multiple
149constraints. Multiple constraints are written in brackets in a comma
148constraints. Multiple constraints are written in brackets in a comma
150separated list, for example:
149separated list, for example:
151
150
@@ -157,16 +156,16 @@ separated list, for example:
157Functors and Applicatives
156Functors and Applicatives
158=========================
157=========================
159
158
160−So far, we have seen single parameter type classes, where the parameter
159+So far, we have seen single parameter interfaces, where the parameter
161−is of type ``Type``. In general, there can be any number (greater than
160+is of type ``Type``. In general, there can be any number of parameters
162−0) of parameters, and the parameters can have *any* type. If the type
161+(even zero), and the parameters can have *any* type. If the type
163of the parameter is not ``Type``, we need to give an explicit type
162of the parameter is not ``Type``, we need to give an explicit type
164−declaration. For example, the ``Functor`` class is defined in the
163+declaration. For example, the ``Functor`` interface is defined in the
165−library:
164+prelude:
166
165
167.. code-block:: idris
166.. code-block:: idris
168
167
169− class Functor (f : Type -> Type) where
168+ interface Functor (f : Type -> Type) where
170 map : (m : a -> b) -> f a -> f b
169 map : (m : a -> b) -> f a -> f b
171
170
172A functor allows a function to be applied across a structure, for
171A functor allows a function to be applied across a structure, for
@@ -174,7 +173,7 @@ example to apply a function to every element in a ``List``:
174
173
175.. code-block:: idris
174.. code-block:: idris
176
175
177− instance Functor List where
176+ Functor List where
178 map f [] = []
177 map f [] = []
179 map f (x::xs) = f x :: map f xs
178 map f (x::xs) = f x :: map f xs
180
179
@@ -190,21 +189,21 @@ abstracts the notion of function application:
190
189
191 infixl 2 <*>
190 infixl 2 <*>
192
191
193− class Functor f => Applicative (f : Type -> Type) where
192+ interface Functor f => Applicative (f : Type -> Type) where
194 pure : a -> f a
193 pure : a -> f a
195 (<*>) : f (a -> b) -> f a -> f b
194 (<*>) : f (a -> b) -> f a -> f b
196
195
197Monads and ``do``-notation
196Monads and ``do``-notation
198==========================
197==========================
199
198
200−The ``Monad`` class allows us to encapsulate binding and computation,
199+The ``Monad`` interface allows us to encapsulate binding and computation,
201and is the basis of ``do``-notation introduced in Section
200and is the basis of ``do``-notation introduced in Section
202:ref:`sect-do`. It extends ``Applicative`` as defined above, and is
201:ref:`sect-do`. It extends ``Applicative`` as defined above, and is
203defined as follows:
202defined as follows:
204
203
205.. code-block:: idris
204.. code-block:: idris
206
205
207− class Applicative m => Monad (m : Type -> Type) where
206+ interface Applicative m => Monad (m : Type -> Type) where
208 (>>=) : m a -> (a -> m b) -> m b
207 (>>=) : m a -> (a -> m b) -> m b
209
208
210Inside a ``do`` block, the following syntactic transformations are
209Inside a ``do`` block, the following syntactic transformations are
@@ -216,12 +215,12 @@ applied:
216
215
217- ``let x = v; e`` becomes ``let x = v in e``
216- ``let x = v; e`` becomes ``let x = v in e``
218
217
219−``IO`` is an instance of ``Monad``, defined using primitive functions.
218+``IO`` has an implementation of ``Monad``, defined using primitive functions.
220−We can also define an instance for ``Maybe``, as follows:
219+We can also define an implementation for ``Maybe``, as follows:
221
220
222.. code-block:: idris
221.. code-block:: idris
223
222
224− instance Monad Maybe where
223+ Monad Maybe where
225 Nothing >>= k = Nothing
224 Nothing >>= k = Nothing
226 (Just x) >>= k = k x
225 (Just x) >>= k = k x
227
226
@@ -242,9 +241,9 @@ are both available, or return ``Nothing`` if one or both are not ("fail fast").
242
241
243::
242::
244
243
245− *classes> m_add (Just 20) (Just 22)
244+ *ifaces> m_add (Just 20) (Just 22)
246 Just 42 : Maybe Int
245 Just 42 : Maybe Int
247− *classes> m_add (Just 20) Nothing
246+ *ifaces> m_add (Just 20) Nothing
248 Nothing : Maybe Int
247 Nothing : Maybe Int
249
248
250``!``-notation
249``!``-notation
@@ -296,11 +295,11 @@ Monad comprehensions
296
295
297The list comprehension notation we saw in Section
296The list comprehension notation we saw in Section
298:ref:`sect-more-expr` is more general, and applies to anything which
297:ref:`sect-more-expr` is more general, and applies to anything which
299−is an instance of both ``Monad`` and ``Alternative``:
298+has an implementation of both ``Monad`` and ``Alternative``:
300
299
301.. code-block:: idris
300.. code-block:: idris
302
301
303− class Applicative f => Alternative (f : Type -> Type) where
302+ interface Applicative f => Alternative (f : Type -> Type) where
304 empty : f a
303 empty : f a
305 (<|>) : f a -> f a -> f a
304 (<|>) : f a -> f a -> f a
306
305
@@ -364,19 +363,19 @@ alternative notion of function application, with explicit calls to
364
363
365Rather than having to insert ``m_app`` everywhere there is an
364Rather than having to insert ``m_app`` everywhere there is an
366application, we can use idiom brackets to do the job for us.
365application, we can use idiom brackets to do the job for us.
367−To do this, we can make ``Maybe`` an instance of ``Applicative``
366+To do this, we can give ``Maybe`` an implementation of ``Applicative``
368as follows, where ``<*>`` is defined in the same way as ``m_app``
367as follows, where ``<*>`` is defined in the same way as ``m_app``
369above (this is defined in the Idris library):
368above (this is defined in the Idris library):
370
369
371.. code-block:: idris
370.. code-block:: idris
372
371
373− instance Applicative Maybe where
372+ Applicative Maybe where
374 pure = Just
373 pure = Just
375
374
376 (Just f) <*> (Just a) = Just (f a)
375 (Just f) <*> (Just a) = Just (f a)
377 _ <*> _ = Nothing
376 _ <*> _ = Nothing
378
377
379−Using ``<*>`` we can use this instance as follows, where a function
378+Using ``<*>`` we can use this implementation as follows, where a function
380application ``[| f a1 …an |]`` is translated into ``pure f <*> a1 <*>
379application ``[| f a1 …an |]`` is translated into ``pure f <*> a1 <*>
381… <*> an``:
380… <*> an``:
382
381
@@ -407,8 +406,8 @@ We define a data type ``Eval`` to wrap an evaluator:
407 data Eval : Type -> Type where
406 data Eval : Type -> Type where
408 MkEval : (List (String, Int) -> Maybe a) -> Eval a
407 MkEval : (List (String, Int) -> Maybe a) -> Eval a
409
408
410−Wrapping the evaluator in a data type means we will be able to make it
409+Wrapping the evaluator in a data type means we will be able to provide
411−an instance of a type class later. We begin by defining a function to
410+implementations of interfaces for it later. We begin by defining a function to
412retrieve values from the context during evaluation:
411retrieve values from the context during evaluation:
413
412
414.. code-block:: idris
413.. code-block:: idris
@@ -421,18 +420,18 @@ retrieve values from the context during evaluation:
421 then (Just val)
420 then (Just val)
422 else (fetchVal xs)
421 else (fetchVal xs)
423
422
424−When defining an evaluator for the language, we will be applying
423+When defining an evaluator for the language, we will be applying functions in
425−functions in the context of an ``Eval``, so it is natural to make
424+the context of an ``Eval``, so it is natural to give ``Eval`` an implementation
426−``Eval`` an instance of ``Applicative``. Before ``Eval`` can be an
425+of ``Applicative``. Before ``Eval`` can have an implementation of
427−instance of ``Applicative`` it is necessary to make ``Eval`` an
426+``Applicative`` it is necessary for ``Eval`` to have an implementation of
428−instance of ``Functor``:
427+``Functor``:
429
428
430.. code-block:: idris
429.. code-block:: idris
431
430
432− instance Functor Eval where
431+ Functor Eval where
433 map f (MkEval g) = MkEval (\e => map f (g e))
432 map f (MkEval g) = MkEval (\e => map f (g e))
434
433
435− instance Applicative Eval where
434+ Applicative Eval where
436 pure x = MkEval (\e => Just x)
435 pure x = MkEval (\e => Just x)
437
436
438 (<*>) (MkEval f) (MkEval g) = MkEval (\x => app (f x) (g x)) where
437 (<*>) (MkEval f) (MkEval g) = MkEval (\x => app (f x) (g x)) where
@@ -454,24 +453,24 @@ to handle errors:
454 runEval env e = case eval e of
453 runEval env e = case eval e of
455 MkEval envFn => envFn env
454 MkEval envFn => envFn env
456
455
457−Named Instances
456+Named Implementations
458−===============
457+=====================
459
458
460−It can be desirable to have multiple instances of a type class, for
459+It can be desirable to have multiple implementations of an interface for the
461−example to provide alternative methods for sorting or printing values.
460+same type, for example to provide alternative methods for sorting or printing
462−To achieve this, instances can be *named* as follows:
461+values. To achieve this, implementations can be *named* as follows:
463
462
464.. code-block:: idris
463.. code-block:: idris
465
464
466− instance [myord] Ord Nat where
465+ [myord] Ord Nat where
467 compare Z (S n) = GT
466 compare Z (S n) = GT
468 compare (S n) Z = LT
467 compare (S n) Z = LT
469 compare Z Z = EQ
468 compare Z Z = EQ
470 compare (S x) (S y) = compare @{myord} x y
469 compare (S x) (S y) = compare @{myord} x y
471
470
472−This declares an instance as normal, but with an explicit name,
471+This declares an implementation as normal, but with an explicit name,
473−``myord``. The syntax ``compare @{myord}`` gives an explicit instance to
472+``myord``. The syntax ``compare @{myord}`` gives an explicit implementation to
474−``compare``, otherwise it would use the default instance for ``Nat``. We
473+``compare``, otherwise it would use the default implementation for ``Nat``. We
475can use this, for example, to sort a list of ``Nat`` in reverse.
474can use this, for example, to sort a list of ``Nat`` in reverse.
476Given the following list:
475Given the following list:
477
476
@@ -480,35 +479,34 @@ Given the following list:
480 testList : List Nat
479 testList : List Nat
481 testList = [3,4,1]
480 testList = [3,4,1]
482
481
483−We can sort it using the default ``Ord`` instance, then the named
482+We can sort it using the default ``Ord`` implementation, then the named
484−instance ``myord`` as follows, at the Idris prompt:
483+implementation ``myord`` as follows, at the Idris prompt:
485
484
486::
485::
487
486
488− *named_instance> show (sort testList)
487+ *named_impl> show (sort testList)
489 "[sO, sssO, ssssO]" : String
488 "[sO, sssO, ssssO]" : String
490− *named_instance> show (sort @{myord} testList)
489+ *named_impl> show (sort @{myord} testList)
491 "[ssssO, sssO, sO]" : String
490 "[ssssO, sssO, sO]" : String
492
491
493
492
494Determining Parameters
493Determining Parameters
495======================
494======================
496
495
497−When a class has more than one parameter, it can help resolution if
496+When an interface has more than one parameter, it can help resolution if the
498−the parameters used to resolve the type class are restricted. For
497+parameters used to find an implementation are restricted. For example:
499−example:
500
498
501.. code-block:: idris
499.. code-block:: idris
502
500
503− class Monad m => MonadState s (m : Type -> Type) | m where
501+ interface Monad m => MonadState s (m : Type -> Type) | m where
504 get : m s
502 get : m s
505 put : s -> m ()
503 put : s -> m ()
506
504
507−In this class, only ``m`` needs to be known to resolve this class, and
505+In this interface, only ``m`` needs to be known to find an implementation of
508−``s`` can then be determined from the instance. This is declared with
506+this interface, and ``s`` can then be determined from the implementation. This
509−the ``| m`` after the class declaration. We call ``m`` a *determining
507+is declared with the ``| m`` after the interface declaration. We call ``m`` a
510−parameter* of the ``MonadState`` class, because it is the parameter
508+*determining parameter* of the ``MonadState`` interface, because it is the
511−used to resolve an instance.
509+parameter used to find an implementation.
512
510
513
511
514.. [1] Conor McBride and Ross Paterson. 2008. Applicative programming
512.. [1] Conor McBride and Ross Paterson. 2008. Applicative programming
docs/tutorial/interp.rst+3−3
@@ -285,15 +285,15 @@ program at the Idris interactive environment is:
285Aside: ``cast``
285Aside: ``cast``
286---------------
286---------------
287
287
288−The prelude defines a type class ``Cast`` which allows conversion
288+The prelude defines an interface ``Cast`` which allows conversion
289between types:
289between types:
290
290
291.. code-block:: idris
291.. code-block:: idris
292
292
293− class Cast from to where
293+ interface Cast from to where
294 cast : from -> to
294 cast : from -> to
295
295
296−It is a *multi-parameter* type class, defining the source type and
296+It is a *multi-parameter* interface, defining the source type and
297object type of the cast. It must be possible for the type checker to
297object type of the cast. It must be possible for the type checker to
298infer *both* parameters at the point where the cast is applied. There
298infer *both* parameters at the point where the cast is applied. There
299are casts defined between all of the primitive types, as far as they
299are casts defined between all of the primitive types, as far as they
docs/tutorial/modules.rst+4−4
@@ -8,7 +8,7 @@ An Idris program consists of a collection of modules. Each module
8includes an optional ``module`` declaration giving the name of the
8includes an optional ``module`` declaration giving the name of the
9module, a list of ``import`` statements giving the other modules which
9module, a list of ``import`` statements giving the other modules which
10are to be imported, and a collection of declarations and definitions of
10are to be imported, and a collection of declarations and definitions of
11−types, classes and functions. For example, the listing below gives a
11+types, interfaces and functions. For example, the listing below gives a
12module which defines a binary tree type ``BTree`` (in a file
12module which defines a binary tree type ``BTree`` (in a file
13``Btree.idr``):
13``Btree.idr``):
14
14
@@ -78,19 +78,19 @@ Export Modifiers
78By default, all names defined in a module are exported for use by other
78By default, all names defined in a module are exported for use by other
79modules. However, it is good practice only to export a minimal interface
79modules. However, it is good practice only to export a minimal interface
80and keep internal details abstract. Idris allows functions, types,
80and keep internal details abstract. Idris allows functions, types,
81−and classes to be marked as: ``public``, ``abstract`` or ``private``:
81+and interfaces to be marked as: ``public``, ``abstract`` or ``private``:
82
82
83- ``public`` means that both the name and definition are exported. For
83- ``public`` means that both the name and definition are exported. For
84 functions, this means that the implementation is exported (which
84 functions, this means that the implementation is exported (which
85 means, for example, it can be used in a dependent type). For data
85 means, for example, it can be used in a dependent type). For data
86 types, this means that the type name and the constructors are
86 types, this means that the type name and the constructors are
87− exported. For classes, this means that the class name and method
87+ exported. For interfaces, this means that the interface name and method
88 names are exported.
88 names are exported.
89
89
90- ``abstract`` means that only the name is exported. For functions,
90- ``abstract`` means that only the name is exported. For functions,
91 this means that the implementation is not exported. For data types,
91 this means that the implementation is not exported. For data types,
92 this means that the type name is exported but not the constructors.
92 this means that the type name is exported but not the constructors.
93− For classes, this means that the class name is exported but not the
93+ For interfaces, this means that the interface name is exported but not the
94 method names.
94 method names.
95
95
96- ``private`` means that neither the name nor the definition is
96- ``private`` means that neither the name nor the definition is
docs/tutorial/provisional.rst+2−2
@@ -266,12 +266,12 @@ the user and outputs it in binary.
266 x <- getLine
266 x <- getLine
267 print (natToBin (fromInteger (cast x)))
267 print (natToBin (fromInteger (cast x)))
268
268
269−For this to work, of course, we need a ``Show`` instance for
269+For this to work, of course, we need a ``Show`` implementation for
270``Binary n``:
270``Binary n``:
271
271
272.. code-block:: idris
272.. code-block:: idris
273
273
274− instance Show (Binary n) where
274+ Show (Binary n) where
275 show (BO x) = show x ++ "0"
275 show (BO x) = show x ++ "0"
276 show (BI x) = show x ++ "1"
276 show (BI x) = show x ++ "1"
277 show BEnd = ""
277 show BEnd = ""
docs/tutorial/syntax.rst+2−2
@@ -168,7 +168,7 @@ declaring:
168 pure : Expr G a -> Expr G a
168 pure : Expr G a -> Expr G a
169 pure = id
169 pure = id
170
170
171−Note that there is no need for these to be part of an instance of
171+Note that there is no need for these to be part of an implementation of
172``Applicative``, since idiom bracket notation translates directly to
172``Applicative``, since idiom bracket notation translates directly to
173the names ``<*>`` and ``pure``, and ad-hoc type-directed overloading
173the names ``<*>`` and ``pure``, and ad-hoc type-directed overloading
174is allowed. We can now say:
174is allowed. We can now say:
@@ -179,7 +179,7 @@ is allowed. We can now say:
179 fact = expr (\x => If (Op (==) x (Val 0))
179 fact = expr (\x => If (Op (==) x (Val 0))
180 (Val 1) (Op (*) [| fact (Op (-) x (Val 1)) |] x))
180 (Val 1) (Op (*) [| fact (Op (-) x (Val 1)) |] x))
181
181
182−With some more ad-hoc overloading and type class instances, and a new
182+With some more ad-hoc overloading and use of interfaces, and a new
183syntax rule, we can even go as far as:
183syntax rule, we can even go as far as:
184
184
185.. code-block:: idris
185.. code-block:: idris