-
Une personne est un tuple
{sexe, Nom, Age}
, ousexe
peut prendre les valeurshomme
oufemme
. Ecrire un accesseur pour le nom de la personne. -
Créer une liste de personnes.
-
Extraire la liste des noms des personnes contenues dans la liste
- sans utilier
lists:map
- puis en utilisant
lists:map
.
- sans utilier
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 OverloadedStrings #-} | |
module Main (main) where | |
import Data.List (groupBy) | |
import Data.Function (on) | |
import Data.Text (Text) | |
import qualified Data.Text.Lazy as LT | |
import qualified Data.Text.IO as TextIO | |
import Lucid |
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 OverloadedStrings, ExtendedDefaultRules, DataKinds #-} | |
import Web.Spock.Safe | |
import Lucid | |
import Lucid.Base (makeAttribute) | |
import Data.Text.Lazy (toStrict) | |
import Data.Text (Text) | |
import Network.Wai.Middleware.Static |
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 GADTs #-} | |
module Singleton where | |
data S n = Succ n | |
data Z = Zero | |
class Nat n | |
instance Nat Z | |
instance Nat n => Nat (S n) |
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 OverloadedStrings #-} | |
module Main where | |
import qualified Data.Conduit.List as CL | |
import qualified Data.Text as T | |
import qualified Data.Text.IO as T | |
import Data.Conduit (($$)) | |
import Control.Lens ((^.)) | |
import Control.Monad.IO.Class (liftIO) | |
import Web.Twitter.Conduit(sourceWithMaxId, |
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
LOCKED = 'locked' | |
UNLOCKED = 'unlocked' | |
PUSH = 'push' | |
COIN = 'coin' | |
class Fsm(object): | |
def __init__(self, init_state, transitions, handler=None): | |
self.state = init_state |
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 Network (withSocketsDo, accept, listenOn, PortID(PortNumber)) | |
import Control.Concurrent (forkIO) | |
import System.IO (Handle, hClose, hGetLine, hSetBuffering, BufferMode (..)) | |
import Control.Applicative ((<$>), (<*>)) | |
import Control.Monad (forever) | |
import Control.Monad.STM (atomically) | |
import Control.Concurrent.STM (STM) | |
import Control.Concurrent.STM.TChan (TChan, newTChan, writeTChan, readTChan) | |
import Control.Concurrent.STM.TVar (TVar, newTVar, writeTVar, readTVar) | |
import Control.Concurrent.STM.SSem (SSem) |
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.Category ((>>>)) | |
let io h = interact $ (++"\n") . show . h | |
let maplines h = map (h . words) . lines | |
let to_float = read :: String -> Float | |
let nth = flip (!!) | |
let (|>) = (>>>) :: (a -> b) -> (b -> c) -> (a -> c) |
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 FlexibleInstances, MultiParamTypeClasses #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
module Polynomial where | |
import Test.SmallCheck.Series (Serial) | |
import GHC.Generics (Generic) | |
import qualified Text.ParserCombinators.Parsec as Parsec | |
import Text.ParserCombinators.Parsec (ParseError, Parser, sepBy1) |
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 FlexibleInstances, MultiParamTypeClasses #-} | |
{-# LANGUAGE DeriveGeneric #-} | |
module Json where | |
import Test.SmallCheck.Series | |
import GHC.Generics | |
import Data.List (intercalate) | |
import qualified Text.ParserCombinators.Parsec.Token as Token |
NewerOlder