Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
haskell2010
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Glasgow Haskell Compiler
Packages
haskell2010
Commits
72baf1ec
Commit
72baf1ec
authored
13 years ago
by
Michal Terepeta
Committed by
Ian Lynagh
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Make splitAt conform to Haskell 98/2010 (fixes #1182).
parent
d9d14b4e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Data/List.hs
+1
-1
1 addition, 1 deletion
Data/List.hs
Prelude.hs
+22
-1
22 additions, 1 deletion
Prelude.hs
with
23 additions
and
2 deletions
Data/List.hs
+
1
−
1
View file @
72baf1ec
...
...
@@ -181,4 +181,4 @@ module Data.List (
,
genericReplicate
-- :: (Integral a) => a -> b -> [b]
)
where
import
"base"
Data.List
import
"base"
Data.List
hiding
(
splitAt
)
This diff is collapsed.
Click to expand it.
Prelude.hs
+
22
−
1
View file @
72baf1ec
...
...
@@ -137,7 +137,7 @@ import qualified "base" Control.Exception.Base as New (catch)
import
"base"
Control.Monad
import
"base"
System.IO
import
"base"
System.IO.Error
(
IOError
,
ioError
,
userError
)
import
"base"
Data.List
import
"base"
Data.List
hiding
(
splitAt
)
import
"base"
Data.Either
import
"base"
Data.Maybe
import
"base"
Data.Tuple
...
...
@@ -216,3 +216,24 @@ gcd 0 0 = error "Prelude.gcd: gcd 0 0 is undefined"
gcd
x
y
=
GHC
.
Real
.
gcd
x
y
#
endif
#
ifndef
__HUGS__
-- The GHC's version of 'splitAt' is too strict in 'n' compared to
-- Haskell98/2010 version. Ticket #1182.
-- | 'splitAt' @n xs@ returns a tuple where first element is @xs@ prefix of
-- length @n@ and second element is the remainder of the list:
--
-- > splitAt 6 "Hello World!" == ("Hello ","World!")
-- > splitAt 3 [1,2,3,4,5] == ([1,2,3],[4,5])
-- > splitAt 1 [1,2,3] == ([1],[2,3])
-- > splitAt 3 [1,2,3] == ([1,2,3],[])
-- > splitAt 4 [1,2,3] == ([1,2,3],[])
-- > splitAt 0 [1,2,3] == ([],[1,2,3])
-- > splitAt (-1) [1,2,3] == ([],[1,2,3])
--
-- It is equivalent to @('take' n xs, 'drop' n xs)@.
-- 'splitAt' is an instance of the more general 'Data.List.genericSplitAt',
-- in which @n@ may be of any integral type.
splitAt
::
Int
->
[
a
]
->
([
a
],[
a
])
splitAt
n
xs
=
(
take
n
xs
,
drop
n
xs
)
#
endif
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