Skip to content

Commit

Permalink
rename: ftypes -> dtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
timjb committed Jul 14, 2016
1 parent c7fda64 commit 7f0c350
Show file tree
Hide file tree
Showing 30 changed files with 191 additions and 191 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ftypes [![Build Status][travis-image]][travis-url]
# dtypes [![Build Status][travis-image]][travis-url]

[travis-image]: https://travis-ci.org/timjb/ftypes.svg?branch=master
[travis-url]: https://travis-ci.org/timjb/ftypes
[travis-image]: https://travis-ci.org/timjb/dtypes.svg?branch=master
[travis-url]: https://travis-ci.org/timjb/dtypes
38 changes: 19 additions & 19 deletions ftypes.cabal → dtypes.cabal
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: ftypes
name: dtypes
version: 0.1.0.0
synopsis: Functors, Applicatives, Traversables etc. of kind (k -> *) -> *
description: Please see README.md
homepage: https://github.com/timjb/ftypes#readme
homepage: https://github.com/timjb/dtypes#readme
license: MIT
license-file: LICENSE
author: Tim Baumann
Expand All @@ -20,20 +20,20 @@ tested-with:
library
hs-source-dirs: src
exposed-modules:
FTypes,
FTypes.Classes,
FTypes.Classes.FApplicative,
FTypes.Classes.FChoice,
FTypes.Classes.FFunctor,
FTypes.Classes.FTraversable,
FTypes.Classes.HasFType,
FTypes.Combinators,
FTypes.Compose,
FTypes.Precompose,
FTypes.Postcompose,
FTypes.TH,
FTypes.Trafo,
FTypes.Internal.TH.Helpers
DTypes,
DTypes.Classes,
DTypes.Classes.DApplicative,
DTypes.Classes.DChoice,
DTypes.Classes.DFunctor,
DTypes.Classes.DTraversable,
DTypes.Classes.HasDType,
DTypes.Combinators,
DTypes.Compose,
DTypes.Precompose,
DTypes.Postcompose,
DTypes.TH,
DTypes.Trafo,
DTypes.Internal.TH.Helpers
build-depends:
base >= 4.7 && < 5,
template-haskell,
Expand All @@ -42,13 +42,13 @@ library
default-language: Haskell2010
ghc-options: -Wall

test-suite ftypes-th
test-suite dtypes-th
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: templates.hs
build-depends:
base,
ftypes,
dtypes,
template-haskell,
HTF,
safe,
Expand All @@ -58,4 +58,4 @@ test-suite ftypes-th

source-repository head
type: git
location: https://github.com/timjb/ftypes
location: https://github.com/timjb/dtypes
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module GithubUser where

import JSONFormat
import FTypes
import DTypes

import Data.Aeson ((.=), (.:))
import qualified Data.Aeson as A
Expand Down Expand Up @@ -66,7 +66,7 @@ instance A.FromJSON GithubUser where
-}

makeFType ''GithubUser
makeDType ''GithubUser

ghUserJSONFormat :: JSONFormat GithubUser
ghUserJSONFormat =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module JSONFormat where

import FTypes
import DTypes

import Control.Applicative (Const (..))
import Data.Functor.Identity (Identity (..))
Expand Down Expand Up @@ -48,9 +48,9 @@ parseField field obj = do
parseJSON (fieldFormat field) jsonVal

objectFormat
:: (HasFType o, FApplicative (FType o), FTraversable (FType o))
:: (HasDType o, DApplicative (DType o), DTraversable (DType o))
=> String
-> FType o JSONField
-> DType o JSONField
-> JSONFormat o
objectFormat name fields =
JSONFormat
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: ftypes-aeson
name: dtypes-aeson
version: 0.1.0.0
synopsis: example for parsing JSON using aeson together with ftypes
homepage: https://github.com/timjb/ftypes/tree/master/examples/ftypes-aeson
synopsis: example for parsing JSON using aeson together with dtypes
homepage: https://github.com/timjb/dtypes/tree/master/examples/dtypes-aeson
license: MIT
license-file: LICENSE
author: Tim Baumann
Expand All @@ -15,7 +15,7 @@ library
GithubUser
build-depends:
base,
ftypes,
dtypes,
aeson,
text
hs-source-dirs: .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ module Main
) where

import qualified Options.Applicative as OA
import FTypes.TH (makeFType)
import FTypes.Classes.FTraversable (fsequenceA')
import FTypes.Classes.HasFType (HasFType (..))
import DTypes.TH (makeDType)
import DTypes.Classes.DTraversable (fsequenceA')
import DTypes.Classes.HasDType (HasDType (..))

-- adapted example from the optparse-applicative README

Expand All @@ -19,7 +19,7 @@ data Sample
, quiet :: Bool
}

makeFType ''Sample
makeDType ''Sample

sample :: OA.Parser Sample
sample =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: ftypes-optparse-applicative
name: dtypes-optparse-applicative
version: 0.1.0.0
synopsis: example for using optparse-applicative together with ftypes
homepage: https://github.com/timjb/ftypes/tree/master/examples/ftypes-optparse-applicative
synopsis: example for using optparse-applicative together with dtypes
homepage: https://github.com/timjb/dtypes/tree/master/examples/dtypes-optparse-applicative
license: MIT
license-file: LICENSE
author: Tim Baumann
maintainer: [email protected]
build-type: Simple
cabal-version: >= 1.10

executable ftypes-optparse-applicative
executable dtypes-optparse-applicative
main-is: Main.hs
build-depends:
base,
optparse-applicative,
ftypes
dtypes
hs-source-dirs: .
default-language: Haskell2010
7 changes: 7 additions & 0 deletions src/DTypes.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module DTypes
( module X
) where

import DTypes.Classes as X
import DTypes.Combinators as X
import DTypes.TH as X
9 changes: 9 additions & 0 deletions src/DTypes/Classes.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module DTypes.Classes
( module X
) where

import DTypes.Classes.DFunctor as X
import DTypes.Classes.DApplicative as X
import DTypes.Classes.DTraversable as X
import DTypes.Classes.DChoice as X
import DTypes.Classes.HasDType as X
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE TypeOperators #-}

module FTypes.Classes.FApplicative
( FApplicative (..)
module DTypes.Classes.DApplicative
( DApplicative (..)
, fpureTrafo
, fliftA1, fliftA2, fliftA3, fliftA4, fliftA5, fliftA6, fliftA7, fliftA8
) where

import FTypes.Classes.FFunctor
import FTypes.Compose
import FTypes.Trafo
import DTypes.Classes.DFunctor
import DTypes.Compose
import DTypes.Trafo

#if MIN_VERSION_base(4,8,0)
import Control.Applicative (liftA2)
Expand All @@ -21,7 +21,7 @@ import Control.Applicative ((<$>), liftA2)

infixl 4 <<*>>, <<*, *>>

class FFunctor r => FApplicative (r :: (k -> *) -> *) where
class DFunctor r => DApplicative (r :: (k -> *) -> *) where
-- axioms (analog to applicative axioms):
-- fpure idTrafo <<*>> r = r
-- pureTrafo o <<*>> u <<*>> v <<*>> w = u <<*>> (v <<*>> w)
Expand All @@ -35,11 +35,11 @@ class FFunctor r => FApplicative (r :: (k -> *) -> *) where
(<<*) :: r f -> r g -> r f
(<<*) = fliftA2 const

instance (Applicative f, FApplicative r) => FApplicative (Compose f r) where
instance (Applicative f, DApplicative r) => DApplicative (Compose f r) where
fpure x = Compose (pure (fpure x))
Compose f <<*>> Compose x = Compose (liftA2 (<<*>>) f x)

fpureTrafo :: FApplicative r => (f ==> g) -> r (f ==>> g)
fpureTrafo :: DApplicative r => (f ==> g) -> r (f ==>> g)
fpureTrafo f = fpure (TrafoComp f)

wrap1
Expand Down Expand Up @@ -78,51 +78,51 @@ wrap7
wrap7 f = TrafoComp (wrap6 <$> f)

fliftA1
:: FFunctor r
:: DFunctor r
=> (forall a. f a -> g a)
-> r f -> r g
fliftA1 = ffmap

fliftA2
:: FApplicative r
:: DApplicative r
=> (forall a. f a -> g a -> h a)
-> r f -> r g -> r h
fliftA2 f s t = (wrap1 <$> f) <<$>> s <<*>> t

fliftA3
:: FApplicative r
:: DApplicative r
=> (forall a. f a -> g a -> h a -> i a)
-> r f -> r g -> r h -> r i
fliftA3 f s t u = (wrap2 <$> f) <<$>> s <<*>> t <<*>> u

fliftA4
:: FApplicative r
:: DApplicative r
=> (forall a. f a -> g a -> h a -> i a -> j a)
-> r f -> r g -> r h -> r i -> r j
fliftA4 f s t u v = (wrap3 <$> f) <<$>> s <<*>> t <<*>> u <<*>> v

fliftA5
:: FApplicative r
:: DApplicative r
=> (forall a. f a -> g a -> h a -> i a -> j a -> k a)
-> r f -> r g -> r h -> r i -> r j -> r k
fliftA5 f s t u v w = (wrap4 <$> f) <<$>> s <<*>> t <<*>> u <<*>> v <<*>> w

fliftA6
:: FApplicative r
:: DApplicative r
=> (forall a. f a -> g a -> h a -> i a -> j a -> k a -> l a)
-> r f -> r g -> r h -> r i -> r j -> r k -> r l
fliftA6 f s t u v w x =
(wrap5 <$> f) <<$>> s <<*>> t <<*>> u <<*>> v <<*>> w <<*>> x

fliftA7
:: FApplicative r
:: DApplicative r
=> (forall a. f a -> g a -> h a -> i a -> j a -> k a -> l a -> m a)
-> r f -> r g -> r h -> r i -> r j -> r k -> r l -> r m
fliftA7 f s t u v w x y =
(wrap6 <$> f) <<$>> s <<*>> t <<*>> u <<*>> v <<*>> w <<*>> x <<*>> y

fliftA8
:: FApplicative r
:: DApplicative r
=> (forall a. f a -> g a -> h a -> i a -> j a -> k a -> l a -> m a -> n a)
-> r f -> r g -> r h -> r i -> r j -> r k -> r l -> r m -> r n
fliftA8 f s t u v w x y z =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}

module FTypes.Classes.FChoice
module DTypes.Classes.DChoice
( (:+:) (..)
, FChoice (..)
, DChoice (..)
) where

import FTypes.Classes.FFunctor
import DTypes.Classes.DFunctor

-- TODO: import
data (:+:) f g a = LeftF (f a) | RightF (g a)

class FFunctor rec => FChoice (rec :: (k -> *) -> *) where
class DFunctor rec => DChoice (rec :: (k -> *) -> *) where
fchoose :: rec (f :+: g) -> Either (rec f) (rec g)
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeOperators #-}

module FTypes.Classes.FFunctor
( FFunctor (..)
module DTypes.Classes.DFunctor
( DFunctor (..)
, (<<$>>)
) where

import FTypes.Compose
import FTypes.Trafo
import DTypes.Compose
import DTypes.Trafo

infixl 4 <<$>>, <<$

class FFunctor (r :: (k -> *) -> *) where
class DFunctor (r :: (k -> *) -> *) where
-- axioms:
-- ffmap id = id
-- ffmap (f . g) = fmap1 f . fmap1 g
Expand All @@ -25,8 +25,8 @@ class FFunctor (r :: (k -> *) -> *) where
x <<$ r = ffmap (const x) r

-- synonym
(<<$>>) :: FFunctor r => (f ==> g) -> r f -> r g
(<<$>>) :: DFunctor r => (f ==> g) -> r f -> r g
(<<$>>) = ffmap

instance (Functor f, FFunctor r) => FFunctor (Compose f r) where
instance (Functor f, DFunctor r) => DFunctor (Compose f r) where
ffmap t (Compose x) = Compose (ffmap t <$> x)
Loading

0 comments on commit 7f0c350

Please sign in to comment.