Ticket #13025: Main.hs
File Main.hs, 378 bytes (added by , 3 years ago) |
---|
Line | |
---|---|
1 | {-# LANGUAGE DataKinds #-} |
2 | module Main where |
3 | import Rec |
4 | |
5 | type MyRec = Rec '[ '("A",Int), '("B",Int), '("C",Int) ] |
6 | |
7 | getC :: MyRec -> Int |
8 | getC = getField (Proxy::Proxy '("C",Int)) |
9 | |
10 | doubleC :: MyRec -> MyRec |
11 | doubleC r = setC (2 * (getC r)) r |
12 | where setC = set . (Field :: Int -> Field '("C",Int)) |
13 | |
14 | main :: IO () |
15 | main = print (getC (Field 1 :& Field 2 :& Field 3 :& Nil :: MyRec)) |