Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
curry
curry-frontend
Commits
db2dfc03
Commit
db2dfc03
authored
Feb 20, 2015
by
Jan Rasmus Tikovsky
Browse files
Updated tests for Haskell's record syntax
parent
9558e65a
Changes
2
Show whitespace changes
Inline
Side-by-side
test/HaskellRecords.curry
View file @
db2dfc03
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
...
...
test/RecordTest.curry
View file @
db2dfc03
{-# 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 }
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment