packages feed

compound-types (empty) → 0.1

raw patch · 8 files changed

+245/−0 lines, 8 filesdep +basedep +base-preludedep +compound-typessetup-changed

Dependencies added: base, base-prelude, compound-types, rebase

Files

+ LICENSE view
@@ -0,0 +1,22 @@+Copyright (c) 2016, Nikita Volkov++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 the following+conditions:++The above copyright notice and this permission notice shall be+included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR+OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ compound-types.cabal view
@@ -0,0 +1,73 @@+name:+  compound-types+version:+  0.1+category:+  Data, Types, Type System+synopsis:+  Sum and Product types and such+description:+  This package provides scalable composite types with neat syntax.+  Additionally it provides the strict data-structures.+homepage:+  https://github.com/nikita-volkov/compound-types +bug-reports:+  https://github.com/nikita-volkov/compound-types/issues +author:+  Nikita Volkov <nikita.y.volkov@mail.ru>+maintainer:+  Nikita Volkov <nikita.y.volkov@mail.ru>+copyright:+  (c) 2016, Nikita Volkov+license:+  MIT+license-file:+  LICENSE+build-type:+  Simple+cabal-version:+  >=1.10+++source-repository head+  type:+    git+  location:+    git://github.com/nikita-volkov/compound-types.git+++library+  hs-source-dirs:+    library+  ghc-options:+  default-extensions:+    Arrows, BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TupleSections, TypeFamilies, TypeOperators, UnboxedTuples+  default-language:+    Haskell2010+  other-modules:+    CompoundTypes.Private.Prelude+    CompoundTypes.Private.Strict.Sum+    CompoundTypes.Private.Strict.Product+  exposed-modules:+    CompoundTypes.Strict+  build-depends:+    -- general:+    base-prelude < 2,+    base >= 4.6 && < 4.10+++executable demo+  hs-source-dirs:+    demo+  main-is:+    Main.hs+  ghc-options:+    -threaded+    "-with-rtsopts=-N"+  default-extensions:+    Arrows, BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, TemplateHaskell, TupleSections, TypeFamilies, TypeOperators, UnboxedTuples+  default-language:+    Haskell2010+  build-depends:+    compound-types,+    rebase >= 1 && < 2
+ demo/Main.hs view
@@ -0,0 +1,33 @@+module Main where++import Rebase.Prelude+import CompoundTypes.Strict+++main =+  error "This demonstration is all about the compilability"++-- |+-- Same as the following type: +-- +-- > Sum3 Int Char Bool+type IntCharBoolSum =+  Int + Char + Bool++-- |+-- How it can be pattern-matched+intCharBoolSumToText :: IntCharBoolSum -> String+intCharBoolSumToText =+  \case+    Sum3_1 int -> "Int: " <> show int+    Sum3_2 char -> "Char: " <> show char+    Sum3_3 bool -> "Bool: " <> show bool++-- |+-- Same as the following type:+-- +-- > Sum3 Int (Product2 Char (Sum2 Bool String)) Char+-- +-- Just as in the math, the product operator exhibits a higher priority.+type SumAndProductMixture =+  Int + Char * (Bool + String) + Char
+ library/CompoundTypes/Private/Prelude.hs view
@@ -0,0 +1,10 @@+module CompoundTypes.Private.Prelude+(+  module Exports,+)+where+++-- base-prelude+-------------------------+import BasePrelude as Exports
+ library/CompoundTypes/Private/Strict/Product.hs view
@@ -0,0 +1,47 @@+module CompoundTypes.Private.Strict.Product where+++data Product2 a b =+  Product2 !a !b++data Product3 a b c =+  Product3 !a !b !c++data Product4 a b c d =+  Product4 !a !b !c !d++data Product5 a b c d e =+  Product5 !a !b !c !d !e++-- |+-- Automatically derives the product-type of the according arity+-- from expressions such as:+-- +-- > (Int * Char * Bool)+-- +-- In that case it will resolve to:+-- +-- > Product3 Int Char Bool+type family (*) a b where+  Product4 v1 v2 v3 v4 * v5 =+    Product5 v1 v2 v3 v4 v5+  Product3 v1 v2 v3 * Product2 v4 v5 =+    Product5 v1 v2 v3 v4 v5+  Product3 v1 v2 v3 * v4 =+    Product4 v1 v2 v3 v4+  Product2 v1 v2 * Product3 v3 v4 v5 =+    Product5 v1 v2 v3 v4 v5+  Product2 v1 v2 * Product2 v3 v4 =+    Product4 v1 v2 v3 v4+  Product2 v1 v2 * v3 =+    Product3 v1 v2 v3+  v1 * Product4 v2 v3 v4 v5 =+    Product5 v1 v2 v3 v4 v5+  v1 * Product3 v2 v3 v4 =+    Product4 v1 v2 v3 v4+  v1 * Product2 v2 v3 =+    Product3 v1 v2 v3+  v1 * v2 =+    Product2 v1 v2++infixl 1 *
+ library/CompoundTypes/Private/Strict/Sum.hs view
@@ -0,0 +1,47 @@+module CompoundTypes.Private.Strict.Sum where+++data Sum2 a b =+  Sum2_1 !a | Sum2_2 !b++data Sum3 a b c =+  Sum3_1 !a | Sum3_2 !b | Sum3_3 !c++data Sum4 a b c d =+  Sum4_1 !a | Sum4_2 !b | Sum4_3 !c | Sum4_4 !d++data Sum5 a b c d e =+  Sum5_1 !a | Sum5_2 !b | Sum5_3 !c | Sum5_4 !d | Sum5_5 !e++-- |+-- Automatically derives the sum-type of the according arity+-- from expressions such as:+-- +-- > (Int + Char + Bool)+-- +-- In that case it will resolve to:+-- +-- > Sum3 Int Char Bool+type family (+) a b where+  Sum4 v1 v2 v3 v4 + v5 =+    Sum5 v1 v2 v3 v4 v5+  Sum3 v1 v2 v3 + Sum2 v4 v5 =+    Sum5 v1 v2 v3 v4 v5+  Sum3 v1 v2 v3 + v4 =+    Sum4 v1 v2 v3 v4+  Sum2 v1 v2 + Sum3 v3 v4 v5 =+    Sum5 v1 v2 v3 v4 v5+  Sum2 v1 v2 + Sum2 v3 v4 =+    Sum4 v1 v2 v3 v4+  Sum2 v1 v2 + v3 =+    Sum3 v1 v2 v3+  v1 + Sum4 v2 v3 v4 v5 =+    Sum5 v1 v2 v3 v4 v5+  v1 + Sum3 v2 v3 v4 =+    Sum4 v1 v2 v3 v4+  v1 + Sum2 v2 v3 =+    Sum3 v1 v2 v3+  v1 + v2 =+    Sum2 v1 v2++infixl 0 +
+ library/CompoundTypes/Strict.hs view
@@ -0,0 +1,11 @@+-- |+-- Implementations of strict data-structures.+module CompoundTypes.Strict+(+  module CompoundTypes.Private.Strict.Sum,+  module CompoundTypes.Private.Strict.Product,+)+where++import CompoundTypes.Private.Strict.Sum+import CompoundTypes.Private.Strict.Product