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
| class CanQuack a where | |
| quack :: a -> IO () | |
| class HasFeathers a where | |
| feathers :: a -> IO () | |
| data Duck = Duck | |
| data Person = Person | |
| instance CanQuack Duck where |
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 #-} | |
| import Data.Monoid | |
| import Typed.Spreadsheet | |
| celsius = spinButton "Celsius" 0.1 | |
| convert c = "Fahrenheit: " <> display (c * 9 / 5 + 32) | |
| main = textUI "Celsius to Fahrenheit converter" (fmap convert celsius) |
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
| data Message = PlainText String | Encrypted String | |
| send :: Message -> Recipient -> IO () | |
| send (Encrypted m) recipient = some magic with m | |
| send (PlainText _) _ = undefined | |
| data Maybe a = Just a | Nothing | |
| -- movin' to phantom types | |
| data Message a = Message String |
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
| data PrimExpr = | |
| BinExpr BinOp PrimExpr PrimExpr | |
| | UnExpr UnOp PrimExpr | |
| | ConstExpr String | |
| | IntExpr Int | |
| | BoolExpr Bool | |
| data BinOp = | |
| OpEq | |
| | OpAnd |
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
| {- ---------------------------------------------------------------------- | |
| Raw code file for "Evolution of a Haskell Programmer" | |
| Fritz Ruehr, Willamette University | |
| See <http://www.willamette.edu/~fruehr/haskell/evolution.html> | |
| Any given variation section (seperated by horizontal rules) can be enabled | |
| by setting off its delimiting nested comments with EOL comments | |
| (in which case the previously enabled section should be disabled). |
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
| sequence :: Monad m => [m a] -> m [a] | |
| sequence = foldr mcons (return []) | |
| where mcons p q = p >>= \x -> q >>= \y -> return (x : y) | |
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
| trait Vect[Size, A] | |
| def ++[n, m, a](v1: Vect[n, a], v2: Vect[m, a]): Vect[(n + m), a] | |
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
| data Toy b next = | |
| Output b next | |
| | Bell next | |
| | Done | |
| deriving (Show) | |
| data FixE f e = Fix (f (FixE f e)) | Throw e | |
| catch :: (Functor f) => FixE f e1 -> (e1 -> FixE f e2) -> FixE f e2 | |
| catch (Fix x) f = Fix (fmap (flip catch f) x) |
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 RankNTypes #-} | |
| module F where | |
| data User = User { name :: String, age :: Int } deriving Show | |
| data Project = Project { owner :: User } deriving Show | |
| type Lens s a = Functor f => (a -> f a) -> s -> f s | |
| newtype Identity a = Identity { runIdentity :: a } |
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
| scala> type Foo[A, B] = Map[A, B] | |
| defined type alias Foo | |
| scala> type World[M[_]] = M[Int] | |
| warning: there was one feature warning; re-run with -feature for details | |
| defined type alias World | |
| scala> type X[A] = World[({ type M[A] = Foo[String, A] })#M] | |
| defined type alias X |