This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data PList a b = Nil | |
| | Cons a (PList a b) | |
| test :: PList Int String | |
| test = Cons 3 $ Cons 2 $ Cons 1 Nil | |
| data Foo = Foo | |
| test2 :: PList Int Foo | |
| test2 = Cons 3 $ Cons 2 $ Cons 1 Nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data Safe a = Safe a | |
| data NotSafe = NotSafe | |
| data SafeList a b where | |
| Nil :: SafeList a NotSafe | |
| Cons :: a -> SafeList a b -> SafeList a (Safe b) | |
| safeHead :: SafeList a (Safe b) -> a | |
| safeHead (Cons x _) = x | |
| -- safeHead Nil = ??? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A simple class in Python | |
| class car(): | |
| # The __init__ method | |
| def __init__(self, color): | |
| self.color = color | |
| # The color method | |
| def color(self): | |
| return self.color | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| irb(main):001:0> "false" ? true : false | |
| (irb):1: warning: string literal in condition | |
| => true | |
| # no warning if string is not a literal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| and _ False = False | |
| and False _ = False | |
| and _ _ = True | |
| -- inferred type: Bool -> Bool -> Bool | |
| -- underestimated parameter type: the function would also work called like this: | |
| and 42 False | |
| -- and return False; the type checker throws an error for this though. | |
| and' _ False = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data T1 = Bernd | Uwe | |
| data T2 = Bernd | Flo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data Project = Project { | |
| projId :: String, | |
| projKind :: ProjectKind, | |
| projDescription :: String, | |
| projBudget :: Int, | |
| projTeam :: [Person] | |
| } | |
| all_members :: [Project] -> [Person] | |
| all_members projects = concat $ map projTeam projects |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def nb_lines(width, text) | |
| text = "" if text.nil? | |
| cw = @CurrentFont['cw'] | |
| width = @w - @rMargin - @x if (width == 0) | |
| wmax = (width - 2 * @cMargin) * 1000 / @FontSize | |
| s = text.gsub("\r", '') | |
| nb = s.length | |
| nb -= 1 if nb > 0 && s[nb-1] == "\n" | |
| sep = -1 | |
| i, j, l = 0, 0, 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| . | |
| ├── deps | |
| │ └── lager | |
| ├── disco | |
| │ ├── ebin | |
| │ └── src | |
| ├── launcher | |
| │ ├── ebin | |
| │ └── src | |
| ├── main.config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % documentation for rebar.config: https://github.com/basho/rebar/blob/master/rebar.config.sample | |
| {sub_dirs, ["launcher", "disco"]}. | |
| {erl_opts, [debug_info, fail_on_warning, parse_transform, lager_transform]}. | |
| {require_otp_vsn, "R14"}. | |
| {deps, | |
| [lager, |