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
| {-# LANGUAGE ViewPatterns #-} | |
| import Data.List | |
| -- Here is Haskell equivalent of unmarshaling json to interface in Go. See | |
| -- corresponding Go file for full Go code. | |
| -- I'll use regular 'Show' and 'Read' instances instead of marshaling to/from | |
| -- json. 'Show' instance will be required during creation of values of 'Rx' | |
| -- types. But it's actually does not matter, where to require it or require or |
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 main | |
| import ( | |
| "fmt" | |
| "encoding/json" | |
| "reflect" | |
| ) | |
| // Unmarshal json to a struct containing interface field. See full |
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
| [Unit] | |
| Description=Offload /home/deck/.var/app/ | |
| [email protected] | |
| [email protected] | |
| [Mount] | |
| What=/run/media/mmcblk0p1/deck/.var/ | |
| Where=/home/deck/.var/ | |
| Type=none | |
| Options=bind,nofail | |
| [Install] |
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 main | |
| import ( | |
| "fmt" | |
| ) | |
| // newtype Cont r a = Cont ((a -> r) -> r) | |
| type Cont[Result any, A any] func(func(A) Result) Result |
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 main | |
| import "fmt" | |
| // Haskell: data R a = R (R a) | E a | |
| type R [Result any] func() (R[Result], Result) | |
| // Haskell: Cont (R Result) T | |
| type Cont [T any, Result any] func(T) (R[Result], Result) |
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 main | |
| import "fmt" | |
| // Haskell: data R a = R (R a) | E a | |
| type R func() (R, []int) | |
| // Haskell: Cont (R [a]) [a] | |
| type Cont func([]int) (R, []int) |
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
| import Control.Monad.Trans.Cont | |
| import Data.Function | |
| data R a = R (R a) | E a | |
| -- This function is called from 'shift' and 'shift' returns immediately | |
| -- (without calling further continuation) because result is already here - 'R' | |
| -- value. Continuation 'k' will be called later, when evaluation of returned | |
| -- 'R' value is forced in 'run'. |
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 main | |
| import ( | |
| "fmt" | |
| "sync" | |
| "net/http" | |
| "bytes" | |
| ) | |
| func worker(i int, ch <-chan interface{}) { |
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
| #include <iostream> | |
| #include <string> | |
| #include <vector> | |
| #include <algorithm> | |
| #include <Windows.h> | |
| using namespace std; | |
| vector<string> splitToBlocks(const string& text, size_t blockSize) { | |
| vector<string> blocks; |
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
| # cat /etc/systemd/system/test.timer | |
| [Timer] | |
| OnCalendar= | |
| OnCalendar=*-*-* *:*:00 | |
| RandomizedDelaySec=0 | |
| Unit=test.target | |
| [Install] | |
| Also=test.target |
NewerOlder