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
| The MIT License (MIT) | |
| Copyright (c) 2019 Richard Cook | |
| Permission is hereby granted, free of charge, to any person obtaining a copy of | |
| this software and associated documentation files (the "Software"), to deal in | |
| the Software without restriction, including without limitation the rights to | |
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
| the Software, and to permit persons to whom the Software is furnished to do so, | |
| subject to the following conditions: |
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
| The MIT License (MIT) | |
| Copyright (c) 2019 Richard Cook | |
| Permission is hereby granted, free of charge, to any person obtaining a copy of | |
| this software and associated documentation files (the "Software"), to deal in | |
| the Software without restriction, including without limitation the rights to | |
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
| the Software, and to permit persons to whom the Software is furnished to do so, | |
| subject to the following conditions: |
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
| The MIT License (MIT) | |
| Copyright (c) 2019 Richard Cook | |
| Permission is hereby granted, free of charge, to any person obtaining a copy of | |
| this software and associated documentation files (the "Software"), to deal in | |
| the Software without restriction, including without limitation the rights to | |
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
| the Software, and to permit persons to whom the Software is furnished to do so, | |
| subject to the following conditions: |
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
| struct Foo { | |
| title: String, | |
| } | |
| impl Foo { | |
| fn new(title: &str) -> Foo { | |
| Foo { | |
| title: title.to_string(), | |
| } | |
| } |
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
| #!/usr/bin/env stack | |
| -- stack --resolver=lts-12.6 script | |
| module Main (main) where | |
| data Expr = | |
| Val Int | |
| | Add Expr Expr | |
| | Sub Expr Expr | |
| | Mul Expr Expr |
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
| package my.package; | |
| final class Foo { | |
| private final String value; | |
| public Foo(final String value) { | |
| this.value = value; | |
| } | |
| public String getValue() { |
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 Expr = | |
| Val Int | |
| | Add Expr Expr | |
| | Mul Expr Expr | |
| eval :: Expr -> Int | |
| eval (Val x) = x | |
| eval (Add x y) = eval x + eval y | |
| eval (Mul x y) = eval x * eval y |
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
| #!/usr/bin/env stack | |
| {- | |
| stack --resolver=lts-13.3 script | |
| --package Glob | |
| --package process | |
| --package temporary | |
| -} | |
| {-# OPTIONS_GHC -Wall -Werror #-} |
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
| parseDatabaseUrl :: String -> Maybe ConnectInfo | |
| parseDatabaseUrl s = do | |
| let (s1, s2) = break (== ':') s | |
| unless (s1 == "postgres") (fail "Invalid scheme") | |
| let (s3, s4) = break (\c -> c /= ':' && c /= '/') s2 | |
| unless (s3 == "://") (fail "Invalid separator") | |
| let (user, s6) = break (== ':') s4 | |
| when (length user < 1) (fail "Invalid user") | |
| let s7 = drop 1 s6 | |
| (password, s8) = break (== '@') s7 |
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
| #!/usr/bin/env stack | |
| -- stack --resolver=lts-12.6 script | |
| {-# LANGUAGE DeriveDataTypeable #-} | |
| {-# LANGUAGE DeriveFoldable #-} | |
| {-# LANGUAGE FlexibleInstances #-} | |
| {-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| {-# LANGUAGE StandaloneDeriving #-} |