Commit cc1a7a6a authored by Tobias Dammers's avatar Tobias Dammers 🦈

Re-run import

parent 42f5a508
redirect(wiki:Building/AddingLibs)?
\ No newline at end of file
Page moved to [Building/AddingLibs](building/adding-libs)
\ No newline at end of file
......@@ -96,10 +96,14 @@ is about adding `Integer` primitive operations and they are not inline
The part about the User's Guide is also not accurate: In "The Glasgow
Haskell Copiler User's Guide, Version 6.2", section 7.2, I read that
>
>
> There used to be long section about \[the primitives\] here in the User
> Guide, but it became out of date and wrong information is worse than
> none.
>
>
So that's a relief.
......
......@@ -13,21 +13,26 @@ JB: I suggest the following formats
- Pair Programming: groups of 2 read and write code, focus on one particular aspect
- Snapshot: \<5 minute for reporting results of hacking sessions to the group
<table><tr><th>**Time**</th>
<th>**Topic**</th>
<th>**Chair/Presenter**</th></tr>
<tr><th></th>
<th></th>
<th></th></tr>
<tr><th></th>
<th></th>
<th></th></tr>
<table><tr><th> <b>Time</b> </th>
<th> <b>Topic</b> </th>
<th> <b>Chair/Presenter</b>
</th></tr>
<tr><th> </th>
<th> </th>
<th>
</th></tr>
<tr><th> </th>
<th> </th>
<th>
</th></tr>
<tr><th> Thu, early</th>
<th> Individual setup on arrival </th>
<th></th></tr>
<th>
</th></tr>
<tr><th> Thu, noon </th>
<th> Lunch </th>
<th></th></tr>
<th>
</th></tr>
<tr><th> Thu, 1:30 </th>
<th> T:Jumpstart session: repository and build setup, Debugging </th>
<th> ?Vladimir? / Jost
......@@ -54,17 +59,20 @@ JB: I suggest the following formats
</th></tr>
<tr><th> Thu, dinner </th>
<th> Pizza </th>
<th></th></tr>
<th>
</th></tr>
<tr><th> Thu, late </th>
<th> Pair programming II ? </th>
<th> -
</th></tr>
<tr><th></th>
<th></th>
<th></th></tr>
<tr><th> </th>
<th> </th>
<th>
</th></tr>
<tr><th> Fri, 9am </th>
<th> Breakfast? </th>
<th></th></tr>
<th>
</th></tr>
<tr><th> Fri, 9:30 </th>
<th> ?T:GUM implementation </th>
<th> Mustafa
......@@ -75,10 +83,12 @@ JB: I suggest the following formats
</th></tr>
<tr><th> Fri, 10:30 </th>
<th> Pair Programming: Tracing, Packing, configure/packaging </th>
<th></th></tr>
<th>
</th></tr>
<tr><th> Fri, 1pm </th>
<th> Lunch break </th>
<th></th></tr>
<th>
</th></tr>
<tr><th> Fri, 2pm </th>
<th> Organising the development, group positioning </th>
<th> HWL
......@@ -101,50 +111,63 @@ JB: I suggest the following formats
</th></tr>
<tr><th> Fri, 5:30 </th>
<th> Summary snapshots, check-in </th>
<th></th></tr>
<th>
</th></tr>
<tr><th> Fri, 6pm </th>
<th> Brainstorm (with scotch & malt?) </th>
<th> Brainstorm (with scotch &amp; malt?) </th>
<th> bar tender
</th></tr>
<tr><th> Fri, late </th>
<th> Curry and games evening </th>
<th> -
</th></tr>
<tr><th></th>
<th></th>
<th></th></tr>
<tr><th> </th>
<th> </th>
<th>
</th></tr>
<tr><th> Sat, 9:30 </th>
<th> Extensions and Future directions </th>
<th> Chair:
</th></tr>
<tr><th></th>
<tr><th> </th>
<th> Globus, GHC-GAP, GHC-SMP, Microkernel, Packing as-a-library </th>
<th> tba
</th></tr>
<tr><th> Sat, 10:30 </th>
<th> Pair programming: various projects (analysis) </th>
<th></th></tr>
<th>
</th></tr>
<tr><th> Sat, 12:30 </th>
<th> Summary snapshots </th>
<th></th></tr>
<tr><th></th>
<th></th>
<th></th></tr>
<th>
</th></tr>
<tr><th> </th>
<th> </th>
<th>
</th></tr>
<tr><th> Sat, 1pm </th>
<th> Lunch break </th>
<th></th></tr>
<th>
</th></tr>
<tr><th> Sat, 3pm </th>
<th> Pair programming: Tracing, Packing code, various projects </th>
<th></th></tr>
<th>
</th></tr>
<tr><th> Sat, 5pm </th>
<th> Summary snapshots </th>
<th></th></tr>
<th>
</th></tr>
<tr><th> Sat, 5:30 </th>
<th> Result check-in (repository) and wrap-up </th>
<th></th></tr>
<th>
</th></tr>
<tr><th> Sat, late </th>
<th> Pub and winding-down </th>
<th></th></tr>
<tr><th></th>
<th></th>
<th></th></tr></table>
\ No newline at end of file
<th>
</th></tr>
<tr><th> </th>
<th> </th>
<th>
</th></tr></table>
......@@ -121,10 +121,13 @@ Don't forget to "ssh ec2 sudo halt" when you've finished.
## AMIs
We've prepared the following AMIs for GHC development:
<table><tr><th>**Region**</th>
<th>**AMI**</th>
<table><tr><th><b>Region</b></th>
<th><b>AMI</b>
</th>
<th></th></tr>
<tr><th>us-east</th>
<th>ami-916c81f8</th>
......
......@@ -82,9 +82,14 @@ deserialiseAnnEnv :: Typeable t => ([Word8] -> t) -> AnnEnv -> NameEnv t
This function could be in main/Annotations.lhs.
## OLD Implementation Notes
****
**
**
In this old implementation, annotations look like this:
......@@ -150,10 +155,16 @@ Evaluation of the actual value of the annotation is done at the point they are a
## Evolved Implementation
The Summer of Code implementation had some drawbacks:
- You don't detect non-terminating or otherwise "wrong" annotations at compile time
- It is difficult to specify an API that allows adding annotations to the program being compiled because that API needs both a value (that represents the annotation to plugins that may be later on in the pipeline) and a Core expression (that is inserted into the actual target program). What's more, you need to ensure that you are able to find a Typeable dictionary in the program being compiled that corresponds to the dictionary supplied by the user of the API.
- Modules must refer to all the packages that contain data structures used in their annotations. This may be a particular problem if you wish to annotate values with things from the GHC package.
......@@ -353,6 +364,10 @@ f :: ...
- **(Only in SoC implementation)** Plugins cannot currently add further annotations during compilation that will be compiled into the result. I.e. any annotations they add are transient and disappear at the end of that particular run of the Core pipeline.
- We might want to add attribute metadata, so users can specify the multiplicity attributes should take, what sorts of things they can be attached to (value, type, module), and perhaps even what types they can be attached to (e.g. "only things of type a -\> Bool for some a"), similar to C\# ([ http://msdn.microsoft.com/en-us/library/tw5zxet9(VS.80).aspx](http://msdn.microsoft.com/en-us/library/tw5zxet9(VS.80).aspx)) or Java.
- We might want to extend annotation syntax so you can attach multiple annotations in a single definition, like so:
......@@ -375,4 +390,4 @@ x = ...
- **(Only in SoC implementation)** I believe it would make sense to allow annotations to use the implementations of values in the module being compiled,: after all, I they can use the implementations of values in imported modules. This would filling out the relevant field with an error during compilation (for the benefit of plugins) and linking the annotation fields up to the required values after compilation. Is this a good idea?
- Have retention policies, similar to Java?
- See also the Haskell Prime ticket: [ http://hackage.haskell.org/trac/haskell-prime/ticket/88](http://hackage.haskell.org/trac/haskell-prime/ticket/88)
\ No newline at end of file
- See also the Haskell Prime ticket: [ http://hackage.haskell.org/trac/haskell-prime/ticket/88](http://hackage.haskell.org/trac/haskell-prime/ticket/88)
......@@ -19,42 +19,85 @@ parser and returned as a separate `ApiAnns` structure in the
This keeps both the keyword location and the original comments with their
locations.
```
typeApiAnns=(Map.MapApiAnnKey[SrcSpan],Map.MapSrcSpan[LocatedAnnotationComment])typeApiAnnKey=(SrcSpan,AnnKeywordId)
type ApiAnns = ( Map.Map ApiAnnKey [SrcSpan]
, Map.Map SrcSpan [Located AnnotationComment])
type ApiAnnKey = (SrcSpan,AnnKeywordId)
```
Each AST element with annotations has an entries in this Map. The key comprises the SrcSpan of the original element and the AnnKeywordId of the stored annotation. The value is a list of SrcSpans where that particular keyword appears. This is a list to cater for e.g. ";;;;". Top level elements are captured against 'nullSrcSpan'.
So for the source file "examples/Test.hs" having contents
```
-- |Comment not in a SrcSpanfoo x =-- Compute foolet a =4-- using ain a + x
-- |Comment not in a SrcSpan
foo x = -- Compute foo
let a = 4 -- using a
in a + x
```
The returned ApiAnns are
```
([((examples/Test.hs:(2,1)-(4,10),AnnEqual),[examples/Test.hs:2:7]),((examples/Test.hs:(2,1)-(4,10),AnnFunId),[examples/Test.hs:2:1-3]),((examples/Test.hs:(2,1)-(4,10),AnnSemi),[examples/Test.hs:5:1]),((examples/Test.hs:(3,3)-(4,10),AnnIn),[examples/Test.hs:4:3-4]),((examples/Test.hs:(3,3)-(4,10),AnnLet),[examples/Test.hs:3:3-5]),((examples/Test.hs:3:7-11,AnnEqual),[examples/Test.hs:3:9]),((examples/Test.hs:3:7-11,AnnFunId),[examples/Test.hs:3:7]),((examples/Test.hs:4:6-10,AnnVal),[examples/Test.hs:4:8]),((<no location info>,AnnEofPos),[examples/Test.hs:5:1])],[(examples/Test.hs:(2,1)-(4,10),[AnnLineComment"-- Compute foo"]),(examples/Test.hs:(3,3)-(4,10),[AnnLineComment"-- using a"]),(<no location info>,[AnnLineComment"-- |Comment not in a SrcSpan"])])
([((examples/Test.hs:(2,1)-(4,10), AnnEqual), [examples/Test.hs:2:7]),
((examples/Test.hs:(2,1)-(4,10), AnnFunId), [examples/Test.hs:2:1-3]),
((examples/Test.hs:(2,1)-(4,10), AnnSemi), [examples/Test.hs:5:1]),
((examples/Test.hs:(3,3)-(4,10), AnnIn), [examples/Test.hs:4:3-4]),
((examples/Test.hs:(3,3)-(4,10), AnnLet), [examples/Test.hs:3:3-5]),
((examples/Test.hs:3:7-11, AnnEqual), [examples/Test.hs:3:9]),
((examples/Test.hs:3:7-11, AnnFunId), [examples/Test.hs:3:7]),
((examples/Test.hs:4:6-10, AnnVal), [examples/Test.hs:4:8]),
((<no location info>, AnnEofPos), [examples/Test.hs:5:1])],
[(examples/Test.hs:(2,1)-(4,10),
[AnnLineComment "-- Compute foo"]),
(examples/Test.hs:(3,3)-(4,10), [AnnLineComment "-- using a"]),
(<no location info>,
[AnnLineComment "-- |Comment not in a SrcSpan"])])
```
This allows the annotation to be retrieved by
```
-- | Retrieve a list of annotation 'SrcSpan's based on the 'SrcSpan'-- of the annotated AST element, and the known type of the annotation.getAnnotation::ApiAnns->SrcSpan->AnnKeywordId->[SrcSpan]getAnnotation(anns,_) span ann
=caseMap.lookup (span,ann) anns ofNothing->[]Just ss -> ss
-- | Retrieve a list of annotation 'SrcSpan's based on the 'SrcSpan'
-- of the annotated AST element, and the known type of the annotation.
getAnnotation :: ApiAnns -> SrcSpan -> AnnKeywordId -> [SrcSpan]
getAnnotation (anns,_) span ann
= case Map.lookup (span,ann) anns of
Nothing -> []
Just ss -> ss
```
### Annotation structures
Each annotation is simply a `SrcSpan`.
```
-- | Note: in general the names of these are taken from the-- corresponding token, unless otherwise noteddataAnn=AnnAs|AnnAt|AnnBang|AnnBy|AnnCase|AnnClass|AnnClose-- ^ } or ] or ) or #) etc|AnnColon|AnnColon2..
-- | Note: in general the names of these are taken from the
-- corresponding token, unless otherwise noted
data Ann = AnnAs
| AnnAt
| AnnBang
| AnnBy
| AnnCase
| AnnClass
| AnnClose -- ^ } or ] or ) or #) etc
| AnnColon
| AnnColon2
..
```
......@@ -67,58 +110,104 @@ Points to note:
### Capturing in the parser
The annotations are captured in the lexer / parser by extending `PState` to include a field
```
dataPState=PState{...
annotations ::[(ApiAnnKey,SrcSpan)]}
data PState = PState {
...
annotations :: [(ApiAnnKey,SrcSpan)]
}
```
The lexer exposes a helper function to add an annotation
```
addAnnotation::SrcSpan->Ann->SrcSpan->P()addAnnotation l a v =P$\s ->POk s {
annotations =((AK l a), v): annotations s
}()
addAnnotation :: SrcSpan -> Ann -> SrcSpan -> P ()
addAnnotation l a v = P $ \s -> POk s {
annotations = ((AK l a), v) : annotations s
} ()
```
The parser also has some helper functions of the form
```
typeMaybeAnn=Maybe(SrcSpan->P())gl= getLoc
gj x =Just(gl x)aa::Located a ->(Ann,Located c)->P(Located a)aa a@(L l _)(b,s)= addAnnotation l b (gl s)>> return a
type MaybeAnn = Maybe (SrcSpan -> P ())
gl = getLoc
gj x = Just (gl x)
ams::Located a ->[MaybeAnn]->P(Located a)ams a@(L l _) bs =(mapM_ (\a -> a l)$ catMaybes bs)>> return a