First, the code
newtype Exceptional e m a = Exceptional { deExceptional :: m a }
deriving (Functor, Applicative, Monad)
instance (Exception e, MonadThrow m) => MonadError e (Exceptional e m) where
throwError = Exceptional . throwM
{-# LANGUAGE ConstraintKinds, DataKinds, DeriveGeneric, DerivingVia #-} | |
{-# LANGUAGE ExplicitNamespaces, FlexibleContexts, FlexibleInstances #-} | |
{-# LANGUAGE GADTs, GeneralizedNewtypeDeriving, MultiParamTypeClasses #-} | |
{-# LANGUAGE PolyKinds, ScopedTypeVariables, StandaloneDeriving #-} | |
{-# LANGUAGE TypeApplications, TypeFamilies, TypeInType, TypeOperators #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# OPTIONS_GHC -Wall #-} | |
module Data.Aeson.Generic.DerivingVia | |
( StrFun(..), Setting(..), SumEncoding'(..), DefaultOptions, WithOptions(..) | |
, -- Utility type synonyms to save ticks (') before promoted data constructors |
-- SYSTEM F | |
-- http://homepages.inf.ed.ac.uk/slindley/papers/embedding-f.pdf | |
-- | |
-- Type-level lambdas | |
-- https://gist.github.com/AndrasKovacs/ac71371d0ca6e0995541e42cd3a3b0cf | |
{-# language TemplateHaskell, ScopedTypeVariables, RankNTypes, | |
TypeFamilies, UndecidableInstances, DeriveFunctor, GADTs, | |
TypeOperators, TypeApplications, AllowAmbiguousTypes, |
const IdModule = { | |
fmap: (fn) => (x) => fn(x), | |
} | |
const ConstModule = { | |
fmap: (fn) => (x) => x, | |
} | |
/** |
## Principal type-schemes for functional programs | |
**Luis Damas and Robin Milner, POPL '82** | |
> module W where | |
> import Data.List | |
> import Data.Maybe | |
> import Data.Function |
#Layered Grammar of Graphics
###Short description:
The project aim is to implement layered [Grammar of Graphics][303], in [Haskell][308] using [Diagrams][309] as backend. The core ideas is to start with the raw data and think about all the transformations, statistics, etc. that go into graphing it. With a good framework, this can help us see connections between different graphs and create new ones. You’ll realize that a pie chart is basically just a stacked bar chart plotted in polar coordinates, with bar height mapped to pie-slice angle… and that can get you thinking.
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-} | |
import Control.Monad | |
import Control.Monad.Free | |
class (Functor f, Functor g, Functor h) => Compose f g h | f g -> h where | |
compose :: f x -> g y -> Free h (Free f x, Free g y) | |
compose f g = return (liftF f, liftF g) | |
composeF :: Compose f g h => Free f x -> Free g x -> Free h x |
{-# LANGUAGE PackageImports #-} | |
{- | |
You need to register your Twitter application at <http://dev.twitter.com/> | |
to get the consumer key and secret needed for OAuth. When connecting to | |
Twitter for the first time, do this: | |
let consumer = Consumer "consumer key" "consumer secret" | |
token <- authenticate |