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
effect flip | |
ctl flip () : bool | |
fun calculation () | |
if flip () then | |
val unused = flip () | |
if flip () then 0.5 | |
else 4.0 | |
else 1.0 |
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 Data.BWord(BWord(..),fromBWord) where | |
newtype BWord = BWord Integer | |
deriving (Eq,Ord,Show) | |
fromBWord :: BWord -> Integer | |
fromBWord (BWord x) = x | |
minBound' :: Integer | |
minBound' = fromIntegral (minBound::Word) |
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 Data.BWord(BWord(..),fromBWord) where | |
newtype BWord = BWord Integer | |
deriving (Eq,Ord,Show) | |
fromBWord :: BWord -> Integer | |
fromBWord (BWord x) = x | |
minBound' :: Integer | |
minBound' = fromIntegral (minBound::Word) |
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
{-# LANGUAGE OverloadedStrings #-} | |
import Data.String (fromString) | |
import System.Environment (getArgs) | |
import qualified Network.Wai.Handler.Warp as Warp | |
import qualified Network.Wai as Wai | |
import qualified Network.HTTP.Types as H | |
import qualified Data.ByteString as BS -- use for input | |
import qualified Data.ByteString.Lazy as LBS -- use for out |
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
type MemberId = Int | |
type ItemId = Int | |
data Sex = Man | Woman deriving (Show,Eq) | |
data Member = Member { | |
memberId :: MemberId | |
,memberName :: String | |
,memberSex :: Sex |
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
import Data.Either (isLeft) | |
type Err = String | |
type ID = Int | |
type Rank = Int | |
type Name = String | |
type RankDB = [(Rank,ID)] | |
type NameDB = [(ID,Name)] | |
idFromRank :: RankDB -> Rank -> Either Err ID |
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
import Data.Maybe (isNothing,fromJust) | |
type ID = Int | |
type Rank = Int | |
type Name = String | |
type RankDB = [(Rank,ID)] | |
type NameDB = [(ID,Name)] | |
idFromRank :: RankDB -> Rank -> Maybe ID | |
idFromRank db rk = lookup rk db |
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
import Data.List (foldl') | |
import Control.Monad.Reader (Reader,runReader,ask) | |
import Control.Monad (foldM) | |
main = do | |
print $ total 0.08 [(108,True,2),(200,False,1),(324,True,2),(400,False,1)] | |
print $ totalG [(108,True,2),(200,False,1),(324,True,2),(400,False,1)] | |
print $ totalR 0.08 [(108,True,2),(200,False,1),(324,True,2),(400,False,1)] |
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
import Control.Concurrent(forkIO,threadDelay) | |
import qualified Control.Concurrent.STM.TChan as TChan | |
import qualified Control.Monad.STM as STM | |
main = do | |
rp <- TChan.newTChanIO | |
bc <- TChan.newBroadcastTChanIO | |
forkIO $ broadcast bc | |
forkIO $ receive 0 rp bc | |
forkIO $ receive 1 rp bc |
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
import Control.Concurrent(forkIO,threadDelay) | |
import qualified Control.Concurrent.STM.TChan as TChan | |
import qualified Control.Monad.STM as STM | |
main = do | |
rp <- TChan.newTChanIO | |
pc <- TChan.newTChanIO | |
forkIO $ produce pc | |
forkIO $ produce pc | |
forkIO $ produce pc |
NewerOlder