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
Model registry
Operate
Terraform modules
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
Gesh
GHC
Commits
16d1e5ac
Commit
16d1e5ac
authored
24 years ago
by
Simon Peyton Jones
Browse files
Options
Downloads
Patches
Plain Diff
[project @ 2000-08-31 19:57:42 by simonpj]
Make freeze and thaw top-level
parent
83f85baa
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ghc/lib/std/PrelArr.lhs
+27
-21
27 additions, 21 deletions
ghc/lib/std/PrelArr.lhs
with
27 additions
and
21 deletions
ghc/lib/std/PrelArr.lhs
+
27
−
21
View file @
16d1e5ac
% -----------------------------------------------------------------------------
% $Id: PrelArr.lhs,v 1.2
4
2000/0
7/07 11:03:57
simon
mar
Exp $
% $Id: PrelArr.lhs,v 1.2
5
2000/0
8/31 19:57:42
simon
pj
Exp $
%
% (c) The University of Glasgow, 1994-2000
%
...
...
@@ -275,6 +275,12 @@ type IPr = (Int, Int)
data Ix ix => Array ix elt = Array ix ix (Array# elt)
data Ix ix => STArray s ix elt = STArray ix ix (MutableArray# s elt)
-- Mutterings about dependent types... ignore!
-- Array :: ix -> ix -> Array# elt -> Array
-- Array :: forall { l::int, h::int, l<=h } Int(l) -> Int(h) -> Array#(h-l+1) -> Array(l,h)
-- Array :: forall { l1,l2::int, h1,h2::int, l1<=h1+1,l2<=h2+1 }
-- (Int(l1),Int(l2)) -> (Int(h1),Int(h2)) -> Array#((h1-l1+1)*(h2-l2+1)) -> Array(l1,h1,l2,h2)
data STRef s a = STRef (MutVar# s a)
...
...
@@ -539,17 +545,17 @@ freezeSTArray (STArray l u arr#) = ST $ \ s# ->
case rangeSize (l,u) of { I# n# ->
case freeze arr# n# s# of { (# s2#, frozen# #) ->
(# s2#, Array l u frozen# #) }}
where
freeze :: MutableArray# s ele -- the thing
-> Int# -- size of thing to be frozen
-> State# s -- the Universe and everything
-> (# State# s, Array# ele #)
freeze m_arr# n# s#
= case newArray# n# init s# of { (# s2#, newarr1# #) ->
case copy 0# n# m_arr# newarr1# s2# of { (# s3#, newarr2# #) ->
unsafeFreezeArray# newarr2# s3#
}}
where
freeze :: MutableArray# s ele -- the thing
-> Int# -- size of thing to be frozen
-> State# s -- the Universe and everything
-> (# State# s, Array# ele #)
freeze m_arr# n# s#
= case newArray# n# init s#
of { (# s2#, newarr1# #) ->
case copy 0# n# m_arr# newarr1# s2# of { (# s3#, newarr2# #) ->
unsafeFreezeArray# newarr2# s3#
}}
where
init = error "freezeArray: element not copied"
copy :: Int# -> Int#
...
...
@@ -584,16 +590,16 @@ thawSTArray (Array l u arr#) = ST $ \ s# ->
case rangeSize (l,u) of { I# n# ->
case thaw arr# n# s# of { (# s2#, thawed# #) ->
(# s2#, STArray l u thawed# #)}}
thaw :: Array# ele -- the thing
-> Int# -- size of thing to be thawed
-> State# s -- the Universe and everything
-> (# State# s, MutableArray# s ele #)
thaw arr1# n# s#
= case newArray# n# init s# of { (# s2#, newarr1# #) ->
copy 0# n# arr1# newarr1# s2# }
where
thaw :: Array# ele -- the thing
-> Int# -- size of thing to be thawed
-> State# s -- the Universe and everything
-> (# State# s, MutableArray# s ele #)
thaw arr1# n# s#
= case newArray# n# init s# of { (# s2#, newarr1# #) ->
copy 0# n# arr1# newarr1# s2# }
where
init = error "thawSTArray: element not copied"
copy :: Int# -> Int#
...
...
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