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 DefaultSignatures, DeriveGeneric, TypeOperators, FlexibleContexts, StandaloneDeriving, ScopedTypeVariables, FlexibleInstances, DeriveFunctor, DeriveFoldable, DeriveTraversable #-} | |
module Main ( | |
main | |
) where | |
import Data.Text (Text) | |
import qualified Data.Map as Map | |
import Data.Foldable (Foldable) |
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.Array | |
import Data.Maybe | |
import Data.Ord | |
import Data.Foldable (toList) | |
import Data.Char | |
import Data.List | |
type Sudoku = Array Pos (Maybe Color) | |
type Pos = (Int, Int) | |
type Color = Int |
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.Tree hiding (unfoldTreeM_BF, unfoldForestM_BF) | |
import Data.Traversable | |
import Prelude hiding (sequence) | |
import Control.Monad.Free | |
import Data.Functor.Identity | |
unfoldTreeM_BF :: Monad m => (b->m (a, [b])) -> b -> m (Tree 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
{- | |
Copyright (c) 2014 Stephen Diehl | |
Copyright (c) 2015 Cedric Shock | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the | |
"Software"), to deal in the Software without restriction, including | |
without limitation the rights to use, copy, modify, merge, publish, | |
distribute, sublicense, and/or sell copies of the Software, and to | |
permit persons to whom the Software is furnished to do so, subject to |
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 GADTs #-} | |
{-# LANGUAGE ConstraintKinds #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE GeneralizedNewtypeDeriving #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE ConstraintKinds #-} |
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 Control.PrimRec ( | |
ArrowLike (..), | |
PrimRec (..), | |
module Control.Category, | |
module Data.Nat | |
) where | |
import Control.Category | |
import Data.Nat |
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.Applicative | |
import Data.List | |
import Data.Maybe | |
data Term = Var Int | Lam Int Term | App Term Term deriving (Show) | |
data BTerm = BVar Int | BLam BTerm | BApp BTerm BTerm deriving (Show) -- BVar 0 refers to the closest lambda | |
lam2db :: Term -> Maybe BTerm | |
lam2db = go [] | |
where |
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 Statistics.Distribution | |
import Statistics.Distribution.Normal | |
data D n = D {n :: n, s :: n} | |
instance Integral n => Distribution (D n) where | |
cumulative d x = cumulativeD d (floor x) | |
instance Integral n => DiscreteDistr (D n) where | |
probability d x = probabilityD d (fromIntegral x) |
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
deleteLast :: (a -> Bool) -> [a] -> [a] | |
deleteLast delete = snd . go | |
where | |
go [] = (False, []) | |
go (x:xs) = (delete x || deleteLater, if not (delete x) || deleteLater then x:xs' else xs') | |
where | |
(deleteLater, xs') = go xs | |
filterLast p = deleteLast (not . p) |
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 PolyKinds #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE RankNTypes #-} | |
module Data.TypeMap ( | |
TypeMap (), | |
null, | |
size, | |
member, |
OlderNewer