@@ -11,21 +11,25 @@ import Data.Maybe (Maybe(..))
1111import Data.Monoid (power )
1212import Data.Newtype (class Newtype , over2 , wrap )
1313
14+ -- ANCHOR: Point
1415newtype Point
15- = Point
16- { x :: Number
17- , y :: Number
18- }
16+ = Point
17+ { x :: Number
18+ , y :: Number
19+ }
20+ -- ANCHOR_END: Point
1921
2022instance showPoint :: Show Point where
2123 show (Point p) =
2224 " (" <> show p.x <> " , " <> show p.y <> " )"
2325
26+ -- ANCHOR: Complex
2427newtype Complex
2528 = Complex
2629 { real :: Number
2730 , imaginary :: Number
2831 }
32+ -- ANCHOR_END: Complex
2933
3034instance showComplex :: Show Complex where
3135 show (Complex c) =
@@ -83,11 +87,13 @@ instance ringComplex :: Ring Complex where
8387 sub (Complex a) (Complex b) = Complex $ a - b
8488-}
8589
90+ -- ANCHOR: Shape
8691data Shape
87- = Circle Point Number
88- | Rectangle Point Number Number
89- | Line Point Point
90- | Text Point String
92+ = Circle Point Number
93+ | Rectangle Point Number Number
94+ | Line Point Point
95+ | Text Point String
96+ -- ANCHOR_END: Shape
9197
9298derive instance genericShape :: Generic Shape _
9399
@@ -102,8 +108,9 @@ instance showShape :: Show Shape where
102108 show (Text p s) = "(Text " <> show p <> " " <> show s <> ")"
103109-}
104110
105- data NonEmpty a
106- = NonEmpty a (Array a )
111+ -- ANCHOR: NonEmpty
112+ data NonEmpty a = NonEmpty a (Array a )
113+ -- ANCHOR_END: NonEmpty
107114
108115instance eqNonEmpty :: Eq a => Eq (NonEmpty a ) where
109116 eq (NonEmpty e1 a1) (NonEmpty e2 a2) = e1 == e2 && a1 == a2
@@ -125,9 +132,9 @@ instance functorNonEmpty :: Functor NonEmpty where
125132 map func (NonEmpty e1 a1) = NonEmpty (func e1) (map func a1)
126133-}
127134
128- data Extended a
129- = Infinite
130- | Finite a
135+ -- ANCHOR: Extended
136+ data Extended a = Infinite | Finite a
137+ -- ANCHOR_END: Extended
131138
132139derive instance eqExtended :: Eq a => Eq (Extended a )
133140{-
@@ -156,10 +163,13 @@ instance foldableNonEmpty :: Foldable NonEmpty where
156163 foldl func st (NonEmpty val arr) = foldl func st ([ val ] <> arr)
157164 foldMap func (NonEmpty val arr) = foldMap func ([ val ] <> arr)
158165
159- data OneMore f a
160- = OneMore a (f a )
166+ -- ANCHOR: OneMore
167+ data OneMore f a = OneMore a (f a )
168+ -- ANCHOR_END: OneMore
161169
170+ -- ANCHOR: OneMore_Foldable
162171instance foldableOneMore :: Foldable f => Foldable (OneMore f ) where
172+ -- ANCHOR_END: OneMore_Foldable
163173 foldr func st (OneMore val more) = func val lastB
164174 where
165175 lastB = foldr func st more
@@ -184,20 +194,28 @@ unsafeMaximum :: Partial => Array Int -> Int
184194unsafeMaximum arr = case maximum arr of
185195 Just m -> m
186196
187- class
188- Monoid m <= Action m a where
189- act :: m -> a -> a
197+ -- ANCHOR: Action
198+ class Monoid m <= Action m a where
199+ act :: m -> a -> a
200+ -- ANCHOR_END: Action
190201
191- newtype Multiply
192- = Multiply Int
202+ -- ANCHOR: Multiply
203+ newtype Multiply = Multiply Int
204+ -- ANCHOR_END: Multiply
193205
206+ -- ANCHOR: semigroupMultiply
194207instance semigroupMultiply :: Semigroup Multiply where
195- append (Multiply n) (Multiply m) = Multiply (n * m)
208+ append (Multiply n) (Multiply m) = Multiply (n * m)
209+ -- ANCHOR_END: semigroupMultiply
196210
211+ -- ANCHOR: monoidMultiply
197212instance monoidMultiply :: Monoid Multiply where
198- mempty = Multiply 1
213+ mempty = Multiply 1
214+ -- ANCHOR_END: monoidMultiply
199215
216+ -- ANCHOR: Multiply_Action
200217instance actionMultiplyInt :: Action Multiply Int where
218+ -- ANCHOR_END: Multiply_Action
201219 act (Multiply n) m = n * m
202220
203221{-
@@ -227,14 +245,17 @@ instance actionMultiplyInt :: Action Multiply Int where
227245derive newtype instance showMultiply :: Show Multiply
228246derive newtype instance eqMultiply :: Eq Multiply
229247
248+ -- ANCHOR: actionMultiplyString
230249instance actionMultiplyString :: Action Multiply String where
250+ -- ANCHOR_END: actionMultiplyString
231251 act (Multiply n) s = power s n
232252
233253instance actionArray :: Action m a => Action m (Array a ) where
234254 act m arr = map (act m) arr
235255
236- newtype Self m
237- = Self m
256+ -- ANCHOR: Self
257+ newtype Self m = Self m
258+ -- ANCHOR_END: Self
238259
239260instance actionSelf :: Monoid m => Action m (Self m ) where
240261 act m1 (Self m2) = Self (m1 <> m2)
@@ -250,11 +271,14 @@ arrayHasDuplicates arr =
250271 in
251272 length arr /= (length $ nubByEq hashAndValEqual arr)
252273
253- newtype Hour
254- = Hour Int
274+ -- ANCHOR: Hour
275+ newtype Hour = Hour Int
276+ -- ANCHOR_END: Hour
255277
278+ -- ANCHOR: eqHour
256279instance eqHour :: Eq Hour where
257- eq (Hour n) (Hour m) = mod n 12 == mod m 12
280+ eq (Hour n) (Hour m) = mod n 12 == mod m 12
281+ -- ANCHOR_END: eqHour
258282
259283instance hashHour :: Hashable Hour where
260284 hash (Hour h) = hash $ mod h 12
0 commit comments