Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jberryman
GHC
Commits
9fc2778c
Commit
9fc2778c
authored
May 16, 2013
by
Krzysztof Gogolewski
Committed by
Simon Peyton Jones
May 16, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Documentation: use new syntax for record GADTs (#7915)
parent
d533da9d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
17 deletions
+16
-17
docs/users_guide/glasgow_exts.xml
docs/users_guide/glasgow_exts.xml
+16
-17
No files found.
docs/users_guide/glasgow_exts.xml
View file @
9fc2778c
...
...
@@ -3071,12 +3071,11 @@ selectors.
Here is the example of that section, in GADT-style syntax:
<programlisting>
data Counter a where
NewCounter { _this :: self
, _inc :: self -> self
, _display :: self -> IO ()
, tag :: a
}
:: Counter a
NewCounter :: { _this :: self
, _inc :: self -> self
, _display :: self -> IO ()
, tag :: a
} -> Counter a
</programlisting>
As before, only one selector function is generated here, that for
<literal>
tag
</literal>
.
Nevertheless, you can still use all the field names in pattern matching and record construction.
...
...
@@ -3188,17 +3187,17 @@ As mentioned in <xref linkend="gadt-style"/>, record syntax is supported.
For example:
<programlisting>
data Term a where
Lit
{ val :: Int } ::
Term Int
Succ
{ num :: Term Int } ::
Term Int
Pred
{ num :: Term Int } ::
Term Int
IsZero
{ arg :: Term Int } ::
Term Bool
Pair { arg1 :: Term a
, arg2 :: Term b
} ::
Term (a,b)
If { cnd :: Term Bool
, tru :: Term a
, fls :: Term a
} ::
Term a
Lit
:: { val :: Int } ->
Term Int
Succ
:: { num :: Term Int } ->
Term Int
Pred
:: { num :: Term Int } ->
Term Int
IsZero
:: { arg :: Term Int } ->
Term Bool
Pair
::
{ arg1 :: Term a
, arg2 :: Term b
} ->
Term (a,b)
If
::
{ cnd :: Term Bool
, tru :: Term a
, fls :: Term a
} ->
Term a
</programlisting>
However, for GADTs there is the following additional constraint:
every constructor that has a field
<literal>
f
</literal>
must have
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment