-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ first part of #105 ] Add support for compiling records to Haskell t…
…uples
- Loading branch information
1 parent
f0bd92a
commit 593f55d
Showing
11 changed files
with
193 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
open import Haskell.Prelude | ||
|
||
record Stuff (a : Set) : Set where | ||
no-eta-equality; pattern | ||
constructor stuff | ||
field | ||
something : Int | ||
more : a | ||
another : Bool | ||
|
||
{-# COMPILE AGDA2HS Stuff unboxed-tuple #-} | ||
|
||
foo : Stuff Int → Stuff Bool → Stuff Char | ||
foo (stuff a b c) (stuff x y z) = stuff (a + b + x) 'x' (or (c ∷ y ∷ z ∷ [])) | ||
|
||
{-# COMPILE AGDA2HS foo #-} | ||
|
||
bare : Int → Char → Bool → Stuff Char | ||
bare = stuff | ||
|
||
{-# COMPILE AGDA2HS bare #-} | ||
|
||
section : a → Bool → Stuff a | ||
section = stuff 42 | ||
|
||
{-# COMPILE AGDA2HS section #-} | ||
|
||
record NoStuff : Set where | ||
no-eta-equality; pattern | ||
constructor dontlook | ||
|
||
{-# COMPILE AGDA2HS NoStuff tuple #-} | ||
|
||
bar : NoStuff → NoStuff | ||
bar dontlook = dontlook | ||
|
||
{-# COMPILE AGDA2HS bar #-} | ||
|
||
-- This is legal, basically the same as an unboxed record. | ||
record Legal (a : Set) : Set where | ||
constructor mkLegal | ||
field | ||
theA : a | ||
|
||
{-# COMPILE AGDA2HS Legal tuple #-} | ||
|
||
baz : Legal Int → Legal Int | ||
baz (mkLegal x) = mkLegal 42 | ||
|
||
{-# COMPILE AGDA2HS baz #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,4 +81,5 @@ import Issue302 | |
import Issue309 | ||
import Issue317 | ||
import ErasedPatternLambda | ||
import CustomTuples | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{-# LANGUAGE UnboxedTuples, TupleSections #-} | ||
module CustomTuples where | ||
|
||
foo :: | ||
(# Int, Int, Bool #) -> | ||
(# Int, Bool, Bool #) -> (# Int, Char, Bool #) | ||
foo (# a, b, c #) (# x, y, z #) | ||
= (# a + b + x, 'x', or [c, y, z] #) | ||
|
||
bare :: Int -> Char -> Bool -> (# Int, Char, Bool #) | ||
bare = (# ,, #) | ||
|
||
section :: a -> Bool -> (# Int, a, Bool #) | ||
section = (# 42, , #) | ||
|
||
bar :: () -> () | ||
bar () = () | ||
|
||
baz :: (Int) -> (Int) | ||
baz (x) = (42) | ||
|