Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

improve example

  • Loading branch information...
commit 48642b048b6218fe9d9353240733edf21f761c11 1 parent 8c97ddf
@mikeplus64 authored
Showing with 17 additions and 5 deletions.
  1. +17 −5 src/Example.hs
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
Please sign in to comment.
Something went wrong with that request. Please try again.