Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
alexbiehl-gc
GHC
Commits
63596a18
Commit
63596a18
authored
26 years ago
by
sof
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 1998-08-14 13:16:00 by sof]
Fixed GetOpt example
parent
7bc7b37a
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ghc/docs/libraries/libs.sgml
+21
-16
21 additions, 16 deletions
ghc/docs/libraries/libs.sgml
with
21 additions
and
16 deletions
ghc/docs/libraries/libs.sgml
+
21
−
16
View file @
63596a18
...
@@ -625,7 +625,7 @@ data ForeignObj -- abstract, instance of: Eq
...
@@ -625,7 +625,7 @@ data ForeignObj -- abstract, instance of: Eq
makeForeignObj :: Addr{-object-} -> Addr{-finaliser-} -> IO ForeignObj
makeForeignObj :: Addr{-object-} -> Addr{-finaliser-} -> IO ForeignObj
writeForeignObj :: ForeignObj -> Addr{-new value-} -> IO ()
writeForeignObj :: ForeignObj -> Addr{-new value-} -> IO ()
data StablePtr a
data StablePtr a
-- abstract, instance of: Eq.
makeStablePtr :: a -> IO (StablePtr a)
makeStablePtr :: a -> IO (StablePtr a)
deRefStablePtr :: StablePtr a -> IO a
deRefStablePtr :: StablePtr a -> IO a
freeStablePtr :: StablePtr a -> IO ()
freeStablePtr :: StablePtr a -> IO ()
...
@@ -811,7 +811,7 @@ which might be used to build an ordered binary tree, say.
...
@@ -811,7 +811,7 @@ which might be used to build an ordered binary tree, say.
The <tt/Dynamic/ library provides cheap-and-cheerful dynamic types for
The <tt/Dynamic/ library provides cheap-and-cheerful dynamic types for
Haskell. A dynamically typed value is one which carries type
Haskell. A dynamically typed value is one which carries type
information with it at run-time, and is represented
here
by the
information with it at run-time, and is represented by the
abstract type <tt/Dynamic/. Values can be converted into <tt/Dynamic/
abstract type <tt/Dynamic/. Values can be converted into <tt/Dynamic/
ones, which can then be combined and manipulated by the program using
ones, which can then be combined and manipulated by the program using
the operations provided over the abstract, dynamic type. One of
the operations provided over the abstract, dynamic type. One of
...
@@ -907,7 +907,10 @@ following,
...
@@ -907,7 +907,10 @@ following,
A really efficient implementation is possible if we guarantee/demand
A really efficient implementation is possible if we guarantee/demand
that the strings are unique, and for a particular type constructor,
that the strings are unique, and for a particular type constructor,
the application <tt/mkTyCon/ to the string that represents the type
the application <tt/mkTyCon/ to the string that represents the type
constructor is never duplicated. [<bf/Q:/ <em>Would this constraint be
constructor is never duplicated. Provided you follow the
the author of <tt/Typeable/
[<bf/Q:/ <em>Would this constraint be
unworkable in practice?</em>]
unworkable in practice?</em>]
<item>
<item>
Both <tt/TyCon/ and <tt/TypeRep/ are instances of the <tt/Show/ type
Both <tt/TyCon/ and <tt/TypeRep/ are instances of the <tt/Show/ type
...
@@ -1029,33 +1032,35 @@ options in any old order or not.
...
@@ -1029,33 +1032,35 @@ options in any old order or not.
To hopefully illuminate the role of the different <tt/GetOpt/ data
To hopefully illuminate the role of the different <tt/GetOpt/ data
structures, here's the command-line options for a (very simple)
structures, here's the command-line options for a (very simple)
compiler
e
:
compiler:
<tscreen><verb>
<tscreen><verb>
module Opts where
import GetOpt
import Maybe ( fromMaybe )
data Flag
data Flag
= Verbose | Version
= Verbose | Version
| Input String | Output String
| Input String | Output String
| LibDir String
deriving Show
deriving Show
options :: [OptDescr Flag]
options :: [OptDescr Flag]
options =
options =
[ Option ['v'] ["verbose"] (NoArg Verbose) "chatty output on stderr"
[ Option ['v'] ["verbose"] (NoArg Verbose) "chatty output on stderr"
, Option ['V','?'] ["version"] (NoArg Version) "show version number"
, Option ['V','?'] ["version"] (NoArg Version) "show version number"
, Option ['o'] ["output"] (OptArg out "FILE") "output FILE"
, Option ['o'] ["output"] (OptArg outp "FILE") "output FILE"
, Option ['c'] [] (OptArg in "FILE") "input FILE"
, Option ['c'] [] (OptArg inp "FILE") "input FILE"
, Option ['L'] ["libdir"] (ReqArg LibDir "DIR") "library directory"
]
]
out :: Maybe String -> Flag
inp,outp :: Maybe String -> Flag
out Nothing = Output "stdout"
outp = Output . fromMaybe "stdout"
out (Just of) = Output of
inp = Input . fromMaybe "stdout"
in :: Maybe String -> Flag
in Nothing = Input "stdin"
in (Just i) = Input i
compilerOpts :: [String] -> IO (
String
, String)
compilerOpts :: [String] -> IO (
[Flag]
,
[
String
]
)
compilerOpts argv =
compilerOpts argv =
case (getOpt
NoOrder
options argv) of
case (getOpt
Permute
options argv) of
(o,n,[] ) -> return (o,n)
(o,n,[] ) -> return (o,n)
(_,_,errs) -> fail (userError (concat errs ++ usageInfo header options))
(_,_,errs) -> fail (userError (concat errs ++ usageInfo header options))
where header = "Usage: ic [OPTION...] files..."
where header = "Usage: ic [OPTION...] files..."
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment