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 }
-- construction
r1 :: R Bool
r1 = C { l = 42, x = True }
r2 :: R a
r2 = C {}
-- pattern matching
fun :: R a -> Bool
fun C { l = 42 } = True
fun2 :: R a -> Bool
fun2 C {} = False
-- update
upd :: R Bool -> R Bool
upd r = r { x = False, l = 0 }
-- selection
......
{-# LANGUAGE Records #-}
module RecordTest where
type Record =
{ intField :: Int
, boolField :: Bool
}
import HaskellRecords
empty = { intField := 0, boolField := False }
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 }
r = C 73 False
\ No newline at end of file
Markdown is supported
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