A wrapper of type W
that contains zero or more elements of type a
.
A function named functionname
that takes a value of type a
, a value of type b
and returns a value of type c
.
module Tests | |
open canopy | |
open Utils | |
open System | |
let veranda (rootPath) = (rootPath + ": Veranda") &&& fun () -> | |
let clickNext expected fn = | |
click ".verandawizard.selected input[type=submit]" |
// In C# we can't enforce generic classes in interfaces, so we can't use interfaces to define the contract. | |
// I can only give examples of the minimal code it needs to implement. | |
class FunctorImpl<T> { | |
FunctorImpl<T> Pure(T val); | |
FunctorImpl<S> Apply<S>(Func<T, S> fn); | |
// Requirement: Pure(val).Apply(x=>x) == Pure(val) | |
} | |
class ApplicativeImpl<T> where { |
{-# LANGUAGE OverloadedStrings #-} | |
module Lib.DB(query_,query,execute_,execute,lastInsertRowId | |
,find,DB.FromRow,DB.fromRow,DB.field,ResourceT,runResourceT) | |
where | |
import Control.Monad (liftM) | |
import Control.Monad.IO.Class (liftIO) | |
import Control.Monad.Reader (ReaderT (..), ask, runReader) | |
import Control.Monad.Trans.Class (lift) |
+++ Description = "" Tags = ["Development", "Haskell", "C#", "CSharp"] date = "2015-10-16T09:24:25+02:00" menu = "main" title = "Haskell concepts in C#"
+++
I've made numerous attempts to explain functors, applicatives, monads and the likes in .Net, and here is another one:
-- Sudoku solver by @ToJans | |
-- | |
-- Parses a Sudoku from a string and solves it | |
-- Parsing happens by filtering out ['1'-'9'] and '.' | |
{-# LANGUAGE OverloadedStrings #-} | |
module Sudoko where | |
import Data.Maybe(isNothing,fromMaybe) |
-- A quadtree implementation with a max points per node | |
module Main where | |
import Control.Monad (replicateM) | |
import System.Random (randomRIO) | |
data Point = Point Int Int | |
deriving Show | |
type LeafPointCount = Int |
import Control.Monad (when) | |
import Data.Char (toLower) | |
import Data.List (transpose) | |
import System.Random (randomIO) | |
wordsPath :: FilePath | |
wordsPath = "words.txt"-- "/usr/share/dict/words" | |
data GameState = GameState | |
{ _wordToGuess :: String |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TypeOperators #-} | |
module StorageServer where | |
import Models | |
import Servant.API | |
import ServantHelpers | |
import StorageDB |