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
e4a420e9
Commit
e4a420e9
authored
Mar 04, 2015
by
Jan Rasmus Tikovsky
Browse files
Updated tests for new record syntax
parent
3b6530c8
Changes
3
Hide whitespace changes
Inline
Side-by-side
test/HaskellRecords.curry
View file @
e4a420e9
module HaskellRecords where
module HaskellRecords where
data R a = C { l :: Int, x :: a }
-- data R a = C { l :: Int, x :: a }
| D { l :: Int }
-- | D { l :: Int }
--
-- -- 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
-- getL :: R a -> Int
-- getL r = l r
-- construction
data R = C { label :: Int, l2 :: Bool }
r1 :: R Bool
r1 = C { l = 42, x = True }
r
2
:: R
a
r :: R
r
2
= C {}
r = C {
label = 42, l2 = True
}
-- pattern matching
r' :: R
fun :: R a -> Bool
r' = r { label = 73 }
fun C { l = 42 } = True
fun2 :: R a -> Bool
unr :: R
fun2 C {} = False
unr = C { l2 = True }
-- update
upd :: R Bool -> R Bool
upd r = r { x = False, l = 0 }
-- selection
getL :: R a -> Int
getL r = l r
\ No newline at end of file
test/RecordTest.curry
View file @
e4a420e9
module RecordTest where
module RecordTest
(Agent, lastName, trueIdentity, mike)
where
import HaskellRecords
data Person = Person { firstName :: String, lastName :: String }
| Agent { lastName :: String, trueIdentity :: Person }
r = C 73 False
mike :: Person
\ No newline at end of file
mike = Person { firstName = "Mike", lastName = "Smith" }
\ No newline at end of file
test/RecordTest2.curry
View file @
e4a420e9
module RecordTest2 where
module RecordTest2 where
import RecursiveRecords
import RecordTest
updLN = mike { lastName = "Doe" }
showR :: R Int -> String
showR r = show (r :> f1) ++ (r :> f2)
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