This file contains 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
use std::sync::{Arc, Mutex}; | |
use std::thread; | |
fn main() { | |
let a = Arc::new(Mutex::new(0)); | |
let b = Arc::new(Mutex::new(0)); | |
let mut handles = vec![]; | |
{ | |
let a = Arc::clone(&a); |
This file contains 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
class Nat (a :: Nat) | |
where toInt :: NProxy a → Int | |
instance natZero :: Nat Zero | |
where toInt _ = 0 | |
instance natSucc :: Nat n ⇒ Nat (Succ n) | |
where toInt _ = 1 + toInt (NProxy :: NProxy n) | |
newtype Vec (n :: Nat) a = Vec (Array a) |
This file contains 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
foreign import kind Nat | |
foreign import kind Boolean | |
foreign import data Zero :: Nat | |
foreign import data Succ :: Nat → Nat | |
foreign import data True :: Boolean | |
foreign import data False :: Boolean | |
data NProxy (a :: Nat) = NProxy | |
data BProxy (b :: Boolean) = BProxy |
This file contains 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 Zero | |
data Succ n | |
type Two = Succ (Succ Zero) | |
type Three = Succ (Succ (Succ Zero)) | |
data True | |
data False | |
class IsEven n b |
This file contains 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 Nat = Succ Nat | Zero | |
isEven :: Nat → Boolean | |
isEven Zero = true | |
isEven (Succ n) = isOdd n | |
isOdd :: Nat → Boolean | |
isOdd Zero = false | |
isOdd (Succ n) = isEven n |
This file contains 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
module Main where | |
import Prelude | |
import Effect (Effect) | |
import Effect.Class.Console (log) | |
class Printf r | |
where printf :: String -> r | |
instance printfString :: Printf String |
This file contains 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
module Main where | |
import Prelude | |
import Data.Tuple (Tuple(..), snd) | |
import Data.Monoid (class Monoid, mempty) | |
import Control.Monad.Eff.Console (logShow) | |
import TryPureScript (render, withConsole) | |
newtype State s a = State (s -> Tuple a s) |
This file contains 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
module Main where | |
import Prelude | |
import Data.Tuple (Tuple(..), snd) | |
import Data.Monoid (class Monoid, mempty) | |
import Control.Monad.Eff.Console (logShow) | |
import TryPureScript (render, withConsole) | |
newtype Writer w a = Writer (Tuple a w) |
This file contains 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
module Main where | |
import Prelude | |
import Control.Monad.Reader.Class | |
import Control.Monad.Eff.Console (logShow) | |
import TryPureScript | |
newtype Reader r a = Reader (r -> a) |
This file contains 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
liftedAdd :: forall f a. Apply f => Semiring a => f a -> f a -> f a | |
liftedAdd = lift2 (+) | |
combineMaybe :: forall a f. Applicative f => Maybe (f a) -> f (Maybe a) | |
combineMaybe Nothing = pure Nothing | |
combineMaybe (Just f) = Just <$> f |
NewerOlder