Skip to content

Commit 810a88a

Browse files
committed
Enable --no-projection-like by default (and recommend users to do the same)
1 parent b0422d3 commit 810a88a

File tree

12 files changed

+24
-12
lines changed

12 files changed

+24
-12
lines changed

docs/source/introduction.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,13 @@ You can use agda2hs with the [Haskell
7171
Stack](https://docs.haskellstack.org/en/stable/) tool.
7272

7373
TODO: integrate agda2hs as a preprocessor for stack
74+
75+
### Creating an Agda2Hs project
76+
77+
All agda2hs projects should have a dependency on the `base` library provided by
78+
Agda, and can also optionally depend on the `containers` library. Using Agda's
79+
standard library with agda2hs is not supported.
80+
81+
All agda2hs projects should enable the `--erasure` option of Agda. It is also
82+
recommended to enable the `--no-projection-like` flag since otherwise functions
83+
might get inlined inadvertently.

docs/source/tutorials.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ This is how the `example-basics.agda-lib` file looks for our project:
2323
```
2424
name: example-basics
2525
include: .
26-
depend: agda2hs
27-
flags: --erasure
26+
depend: base
27+
flags: --erasure --no-projection-like
2828
```
2929
The `include` label specifies the current folder as the path for files to be included in the library. For our toy example it works perfectly, but for a bigger library it might be handy to place all the `.agda` files in a single repository such as `src`.
3030

3131
The only dependency we need so far is `agda2hs`, as that is where `Haskell.Prelude` and agda2hs pragmas live.
3232

33-
Finally, to be able to import modules we need in this example, erasure needs to be enabled. We add it as a flag.
33+
Finally, to be able to import modules we need in this example, erasure needs to be enabled. We add it as a flag. We also enable the `--no-projection-like` flag since otherwise functions might get inlined inadvertently.
3434

3535
Let's look at the `HelloWorld.agda` file now:
3636

lib/base/base.agda-lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
name: base
66
depend:
77
include: .
8-
flags: -W noUnsupportedIndexedMatch --erasure
8+
flags: -W noUnsupportedIndexedMatch --erasure --no-projection-like

lib/containers/containers.agda-lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ name: containers
22
include: agda
33
depend:
44
base
5-
flags: --erasure --no-import-sorts
5+
flags: --erasure --no-import-sorts --no-projection-like

test/ProjLike.agda

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{-# OPTIONS --projection-like #-}
2+
13
module ProjLike where
24

35
open import Haskell.Prelude

test/agda2hs-test.agda-lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
name: agda2hs-test
22
depend:
33
include: . ../lib/base/
4-
flags: --sized-types --erasure
4+
flags: --sized-types --erasure --no-projection-like

test/golden/Issue302.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Issue302 where
22

33
not0 :: Int -> Bool
4-
not0 n = not (n == 0)
4+
not0 n = n /= 0
55

test/golden/Superclass.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ baz :: DiscreteOrd a => a -> Bool
2828
baz x = x < x
2929

3030
usebaz :: Bool
31-
usebaz = True < True
31+
usebaz = baz True
3232

test/golden/Test.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ double :: Monoid a => a -> a
114114
double x = x <> x
115115

116116
doubleSum :: NatSum -> NatSum
117-
doubleSum = \ x -> x <> x
117+
doubleSum = double
118118

119119
hd :: [a] -> a
120120
hd [] = error "hd: empty list"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
name: example-basics
22
include: .
33
depend: agda2hs
4-
flags: --erasure
4+
flags: --erasure --no-projection-like

0 commit comments

Comments
 (0)