Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 4 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 20 additions and 7 deletions.
  1. +1 −1 record.cabal
  2. +2 −1 src/Data/Record.hs
  3. +17 −5 src/Example.hs
View
2 record.cabal
@@ -1,5 +1,5 @@
name: record
-version: 1.0.1
+version: 1.0.2
synopsis: Efficient, type safe records implemented using GADTs and type level strings.
homepage: http://quasimal.com/projects/records
license: BSD3
View
3 src/Data/Record.hs
@@ -16,7 +16,7 @@
, ScopedTypeVariables
, ExplicitNamespaces #-}
-module Data.RecordT ( key
+module Data.Record ( key
, set
, alt
, get
@@ -32,6 +32,7 @@ module Data.RecordT ( key
, alter
, append
, RecordT
+ , Record
, runcomp
, Pure
, (:=)
View
22 src/Example.hs
@@ -9,14 +9,26 @@ type Point
, "z" := Double
, "colour" := (Int, Int, Int) ]
-op :: Record P Point
+op :: Record Point
op = 0 & 0 & 0 & (0,0,0) & end
main :: IO ()
main = do
point <- runcomp newIORef op
- print =<< readIORef ([get|x|] point)
- print =<< readIORef ([get|y|] point)
- print =<< readIORef ([get|z|] point)
- print =<< readIORef ([get|colour|] point)
+ -- point :: RecordT IORef Point
+
+ let pointx = [get|x|] point
+ pointy = [get|x|] point
+ pointz = [get|z|] point
+ pointc = [get|colour|] point
+
+ writeIORef pointx 0
+ writeIORef pointy 1
+ writeIORef pointz 2
+ writeIORef pointc (255, 255, 0)
+
+ -- "freeze" the record
+ frozenPoint <- runtrans readIORef point
+ -- frozenPoint :: Record Point
+ print frozenPoint

No commit comments for this range

Something went wrong with that request. Please try again.