diff options
author | Remigiusz Suwalski <remigiusz-suwalski@users.noreply.github.com> | 2017-01-10 10:06:27 +0100 |
---|---|---|
committer | Remigiusz Suwalski <remigiusz-suwalski@users.noreply.github.com> | 2017-01-10 10:06:27 +0100 |
commit | cc0bd98aeed7bb0b03b78422c63c382907eced77 (patch) | |
tree | d5ba732c3f736e62b485d252b07827427a1804b6 /pl-pl/haskell-pl.html.markdown | |
parent | 7e3b7a5326c948ec80e79c687e462d62538fe319 (diff) |
Translate data types
Diffstat (limited to 'pl-pl/haskell-pl.html.markdown')
-rw-r--r-- | pl-pl/haskell-pl.html.markdown | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/pl-pl/haskell-pl.html.markdown b/pl-pl/haskell-pl.html.markdown index b747ebb3..ae44cd9a 100644 --- a/pl-pl/haskell-pl.html.markdown +++ b/pl-pl/haskell-pl.html.markdown @@ -287,29 +287,28 @@ foldr (\x y -> 2*x + y) 4 [1,2,3] -- 16 (2 * 1 + (2 * 2 + (2 * 3 + 4))) ---------------------------------------------------- --- 7. Data Types +-- 7. Typy danych ---------------------------------------------------- --- Here's how you make your own data type in Haskell +-- Oto jak tworzy się nowe typy danych w Haskellu: data Color = Red | Blue | Green --- Now you can use it in a function: - +-- Teraz można używać ich we własnych funkcjach: say :: Color -> String say Red = "You are Red!" say Blue = "You are Blue!" say Green = "You are Green!" --- Your data types can have parameters too: +-- Twoje typy danych mogą posiadać nawet parametry: data Maybe a = Nothing | Just a --- These are all of type Maybe -Just "hello" -- of type `Maybe String` -Just 1 -- of type `Maybe Int` -Nothing -- of type `Maybe a` for any `a` +-- Wszystkie poniższe są typu Maybe +Just "hello" -- typu `Maybe String` +Just 1 -- typu `Maybe Int` +Nothing -- typu `Maybe a` for any `a` ---------------------------------------------------- -- 8. Haskell IO |