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
module Example.HelloGlsl where | |
import Prelude (Unit(..) | |
,($) | |
,bind) | |
import Control.Monad.Eff (Eff(..)) | |
import Control.Monad.Eff.Alert (Alert(..) | |
,alert) | |
import Control.Monad.Eff.Console (CONSOLE(..) |
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
module FilterM where | |
import Prelude (Monad, ($), (<), (>), (/=), bind, return) | |
import Data.List (List(..)) | |
import Data.Maybe (Maybe(..)) | |
filterM' :: forall m a. (Monad m) => (a -> m Boolean) -> List a -> List a -> m (List a) | |
filterM' p acc Nil = return acc | |
filterM' p acc (Cons x xs) = do |
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
module Sums where | |
import Data.Array ((:), foldM, nub, sort) | |
import Data.Maybe (Maybe(..)) | |
import Prelude (($), (+), (++), map) | |
-- Given an array of integers, compute the list of all | |
-- possible totals, using each integer at most once. | |
sums :: Array Int -> Maybe (Array Int) |
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
module Pi where | |
import Control.Monad.Eff (Eff(..), forE) | |
import Control.Monad.Eff.Random (RANDOM(..), random) | |
import Control.Monad.ST (ST(..), modifySTRef, newSTRef, readSTRef) | |
import Data.Array ((:), filter, length) | |
import Data.Int (toNumber) | |
import Data.Tuple (Tuple(..)) | |
import Prelude (($), (<=), (+), (*), (/), bind, return, unit) |
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
module Fibonacci where | |
import List exposing ((::), head, map2, reverse, tail) | |
import Maybe exposing (andThen) | |
fibonacci : Int -> List Int | |
fibonacci n = | |
let fibonacci' n acc = | |
if n <= 2 | |
then acc |
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
╭ ◜ ◝ ͡ ◝ ͡ ◜ ◝ ╮ | |
(fill in here) | |
╰ ͜ ╯ | |
O | |
o | |
° | |
〃∩ ∧_∧ 💕 | |
⊂⌒( ´・ω・)💕 | |
`ヽ_っ_/ ̄ ̄ ̄/ | |
\/___/ |
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
splitWith :: (a -> Bool) -> [a] -> [[a]] | |
splitWith p l | |
| null l = [] | |
| null xs = splitWith p $ tail xs' | |
| otherwise = xs : splitWith p xs' where | |
(xs, xs') = break p l |
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
interactWith :: (String -> String) -> FilePath -> FilePath -> IO () | |
interactWith f inputFile outputFile = do | |
input <- readFile inputFile | |
writeFile outputFile (f input) | |
transpose = unlines . transpose' . lines where | |
transpose' ss | all ((==) "") ss = [] | |
transpose' ss = map head nonEmptySs : (transpose' $ map tail nonEmptySs) where | |
nonEmptySs = filter ((/=) "") ss |
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
interactWith :: (String -> String) -> FilePath -> FilePath -> IO () | |
interactWith f inputFile outputFile = do | |
input <- readFile inputFile | |
writeFile outputFile (f input) | |
writeFirstWords inputFile outputFile = interactWith firstWords inputFile outputFile where | |
firstWord "" = "" | |
firstWord line = head $ words line | |
firstWords file = unlines $ map firstWord $ lines file |
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
{- | | |
Fill in the Blank: Meet Mabes - the other Maybe type. | |
This exercise is all about defining common abstraction over Mabes, e.g.: | |
* Functor | |
* Applicative | |
* Monad | |
* Alternative |