Skip to content

Commit bff3131

Browse files
committed
Doc tool enhancements, get documentations error free
1 parent 68e04fc commit bff3131

File tree

13 files changed

+165
-57
lines changed

13 files changed

+165
-57
lines changed

frege/PreludeProperties.fr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ package frege.PreludeProperties where
4444
import Data.List
4545

4646
import frege.prelude.Math (floor)
47-
import Test.QuickCheck
47+
-- import Test.QuickCheckArbitrary ()
48+
import Test.QuickCheck
4849

4950
trivial = (`classify` "trivial")
5051

frege/compiler/Classes.fr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ funForCIT cname iname tname (mname@MName _ base) = do
477477
expr = mbx,
478478
typ = U.pSigma, anno = false, exported = false,
479479
state = Unchecked, sid = 0,
480-
doc = Just ("inherited from '" ++ xname.nice g ++ "'")}
480+
doc = Just ("inherited from '" ++ xname.nicer g ++ "'")}
481481
U.enter imem
482482
U.linkq (MName tname base) imem
483483
else if cname.our g || mem.vis == Abstract then
@@ -488,7 +488,7 @@ funForCIT cname iname tname (mname@MName _ base) = do
488488
typ = U.pSigma, anno = false, exported = false,
489489
state = Unchecked,
490490
sid = 0,
491-
doc = Just ("uses '" ++ xname.nice g ++ "'"),
491+
doc = Just ("uses '" ++ xname.nicer g ++ "'"),
492492
expr = Just (Vbl isym.pos xname Nothing)}
493493
U.enter imem
494494
U.linkq (MName tname base) imem

frege/compiler/Data.fr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ data QName =
378378
nicer (Local {uid, base}) g = base
379379
nicer (qn@TName p s) g
380380
| findit qn g == findit (TName g.thisPack s) g = s
381+
nicer (MName t s) g = t.nicer g ++ "." ++ s
381382
nicer qn g = nice qn g
382383
--- tell if this is the name of a let or lambda bound item
383384
isLocal (Local{}) = true

frege/compiler/DocUtils.fr

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,12 @@ docSym g (SymT {name, doc, typ=ForAll _ rho, env, nativ, pur, mutable}) = (code
199199
DL (Just "func") (map (docSym g) members)]],
200200
p <- d ]
201201

202-
docSym g (SymD {name, doc, typ, flds}) = (code title, docit g doc) where
203-
title = label name
202+
docSym g (SymD {name, doc, typ, vis, flds}) = (code title, docit g doc) where
203+
title = lbl -- label name
204204
:- text " "
205205
:- typeorfields
206+
lbl | vis == Public = label name
207+
| otherwise = (bold . text) (show vis) :- text " " :- label name
206208
typeorfields = if (all (isJust ConField.name) flds && not (null flds)) then fields else types
207209
fields = text "{" :- joint ", " fsmap flds :- text "}"
208210
types = joins 2 (drho ConField.typ) flds
@@ -223,6 +225,8 @@ docSym g (SymV {name, typ, doc, nativ, pur, strsig, throwing}) = (code title, do
223225

224226
docSym g (SymL {name,alias}) = case alias.findit g of
225227
Nothing -> (badref (name.nice g ++ "links to " ++ alias.nice g ++ " but not found"), [])
228+
Just (vsym@SymV{}) = docSym g vsym.{name,
229+
doc = Just ("Alias for '" ++ name.base ++ "'")}
226230
Just sym -> docSym g sym
227231

228232
--- create a label for a variable or a constructor

frege/control/Concurrent.fr

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
Concurrency in Frege comes in 2 flavors.
55
The first is through 'Thread's, which are,
6-
unlike in Haskell, @OS@ threads.
6+
unlike in Haskell, _OS threads_.
77
88
The second possibility is to use a thread pool and an executor service
99
one can submit tasks to. But note that blocking asynchronous tasks,
@@ -14,8 +14,10 @@ module frege.control.Concurrent where
1414

1515
import frege.java.util.Concurrent as C
1616

17-
--- A thread safe, shared variable, that is either full or empty.
18-
abstract data MVar a = MV (BlockingQueue a) where
17+
--- A thread safe, shared variable, that is either full or empty.
18+
--- Technically, this is just a 'BlockingQueue' restricted to length 1.
19+
abstract data MVar a = MV (BlockingQueue a) where
20+
1921
--- create an empty 'MVar'
2022
newEmpty = ArrayBlockingQueue.new 1 >>= return . MV
2123

@@ -31,7 +33,7 @@ abstract data MVar a = MV (BlockingQueue a) where
3133
--- put a value in a 'MVar', returns false if already full.
3234
offer (MV q) a = q.offer a
3335

34-
--- get the value from a 'MVar', return 'Nothing' is empty
36+
--- get the value from a 'MVar', return 'Nothing' when empty
3537
poll (MV q) = q.poll
3638

3739
-- Haskell compatibility
@@ -42,7 +44,7 @@ tryPutMVar = MVar.offer
4244

4345

4446
--- Create and start a new OS 'Thread' that runs an 'IO' action.
45-
--- In Frege, there is no difference between 'forkIO' and 'forkOS'
47+
--- In Frege, there is no difference between 'forkIO' and 'frege.control.Concurrent#forkOS' at this time.
4648
forkIO :: IO () -> IO Thread
4749
forkIO action = do
4850
r <- Runnable.new action

frege/data/Traversable.fr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected instance Applicative (StateL s) where
9292
in (s'', f v))
9393

9494
{-- The 'mapAccumL' function behaves like a combination of 'fmap'
95-
and 'foldl'; it applies a function to each element of a structure,
95+
and 'fold'; it applies a function to each element of a structure,
9696
passing an accumulating parameter from left to right, and returning
9797
a final value of this accumulator together with the new structure.
9898
-}

frege/data/TreeMap.fr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ intersection s1 s2 = (Tree.insertList empty . filter ((s2 `contains`) . fst) . T
324324
diff s1 s2 = (Tree.insertList empty . filter (not . (s2 `contains`) . fst) . Tree.each) s1
325325

326326
import Test.QuickCheck
327+
import Test.QuickCheckArbitrary () -- avoid doc error
327328

328329
instance CoArbitrary (Ord k, CoArbitrary k, CoArbitrary v) => (Tree k v) where
329330
coarbitrary Tree.Nil = variant 0
@@ -336,7 +337,7 @@ instance Arbitrary (Ord k, Arbitrary k, Arbitrary v) => (Tree k v) where
336337
aTree = arbitrary :: Gen (Tree Int String)
337338
aList = arbitrary :: Gen [(Int, String)]
338339

339-
--- The empty tree is 'Nil'
340+
--- The empty tree is 'Tree.Nil'
340341
p_emptyIsNil = property (nil empty)
341342
where
342343
nil Tree.Nil = true

frege/java/IO.fr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ native stdin frege.runtime.Runtime.stdin :: BufferedReader
107107
Not intended for direct use but rather as something
108108
a 'PrintWriter' can be made of. (Though, because
109109
of the 'Appendable' inheritance, one could
110-
still 'append' directly.)
110+
still 'Appendable.append' directly.)
111111
112112
To be used like:
113113
@@ -175,7 +175,7 @@ data BufferedReader = mutable native java.io.BufferedReader where
175175
native new :: Reader -> IO BufferedReader
176176
{--
177177
Reads a line of text. A line is considered to be terminated
178-
by any one of a line feed ('\n'), a carriage return ('\r'),
178+
by any one of a line feed ("\n"), a carriage return ("\r"),
179179
or a carriage return followed immediately by a linefeed.
180180
181181
[Returns:] 'Just' _string_, where _string_ is the contents of the line,
@@ -196,7 +196,7 @@ data BufferedReader = mutable native java.io.BufferedReader where
196196
_ -> br.close >> return (reverse acc)
197197

198198
{--
199-
Reads the next line from a buffered reader using 'readLine',
199+
Reads the next line from a buffered reader using 'BufferedReader.readLine',
200200
and returns the string or throws 'EOFException' on end of file.
201201
-}
202202
getLine :: BufferedReader -> IO String

frege/prelude/PreludeList.fr

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
This package provides common list functions for the Frege language.
3939
4040
It contains all functions described in section 9.1 of the
41-
_Haskell 2010 Language Report_, except for @lookup@, which has been moved
41+
_Haskell 2010 Language Report_, except for 'Data.List#lookup', which has been moved
4242
to @frege.data.List@ (the equivalent of Haskell's @Data.List@).
4343
4444
In addition to the common list functions, three type classes capture common
@@ -48,11 +48,7 @@
4848
['ListSource'] is the type class for types that can be converted to lists ('toList').
4949
There are instances for 'String', 'Maybe', 'Either' and arrays.
5050
51-
The functions 'words' and 'lines' take 'String' arguments and return lists of 'String',
52-
whereas 'unwords' and 'unlines' take an instance of 'ListSource' with 'String' elements
53-
and return a single 'String'.
54-
55-
This package is /implementation specific/ insofar as the compiler may
51+
This module is _implementation specific_ insofar as the compiler may
5652
assume that certain items are defined here in a certain way.
5753
Changes may thus lead to compiler crashes or java code that
5854
will be rejected by the java compiler.

frege/prelude/PreludeText.fr

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
-- «•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»«•»
2-
31
{--
42
Classes and Instances to convert values to 'String's ('show') and 'String's to values
5-
('read').
3+
("read").
64
75
There are a few differences to Haskell, notably
86
9-
- 'Read' cannot be derived and supports only simple types
7+
- "Read" cannot be derived and supports only simple types
108
-}
119

1210
protected package frege.prelude.PreludeText where

0 commit comments

Comments
 (0)