Commit db2dfc03 authored by Jan Rasmus Tikovsky 's avatar Jan Rasmus Tikovsky
Browse files

Updated tests for Haskell's record syntax

parent 9558e65a
module HaskellRecords (R (C)) where module HaskellRecords (R (C), getL) where
data R a = C { l :: Int, x :: a } data R a = C { l :: Int, x :: a }
-- construction -- construction
r1 :: R Bool
r1 = C { l = 42, x = True } r1 = C { l = 42, x = True }
r2 :: R a
r2 = C {} r2 = C {}
-- pattern matching -- pattern matching
fun :: R a -> Bool
fun C { l = 42 } = True fun C { l = 42 } = True
fun2 :: R a -> Bool
fun2 C {} = False fun2 C {} = False
-- update -- update
upd :: R Bool -> R Bool
upd r = r { x = False, l = 0 } upd r = r { x = False, l = 0 }
-- selection -- selection
......
{-# LANGUAGE Records #-}
module RecordTest where module RecordTest where
type Record = import HaskellRecords
{ intField :: Int
, boolField :: Bool
}
empty = { intField := 0, boolField := False } r = C 73 False
\ No newline at end of file
full = { intField := 1, boolField := True }
expr = empty :> intField + 1 == 0
match { intField = i | _ } = i
-- int :: { intField :: Int | a }
-- int = { intField := 0 }
type Record2 =
{ intField2 :: Int
, boolField2 :: Bool
}
test = { intField2 := 0, boolField2 := True }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment