impossible 1.0.0 → 1.1.1
raw patch · 3 files changed
+91/−53 lines, 3 filesdep ~basedep ~lens
Dependency ranges changed: base, lens
Files
- impossible.cabal +32/−31
- src/Data/Impossible.hs +59/−16
- src/Data/Impossible/Compact.hs +0/−6
impossible.cabal view
@@ -1,33 +1,34 @@-name: impossible-version: 1.0.0-cabal-version: >=1.10-build-type: Simple-license: Apache-2.0-license-file: LICENSE-copyright: Copyright (C) 2015 Wojciech Danilo-maintainer: Wojciech Danilo <wojciech.danilo@gmail.com>-stability: experimental-homepage: https://github.com/wdanilo/impossible-bug-reports: https://github.com/wdanilo/impossible/issues-synopsis: Set of data and type definitions of impossible types. Impossible types are useful when declaring type classes / type families instances that should not be expanded by GHC until a specific type is provided in order to keep the types nice and readable.-category: Data-author: Wojciech Danilo+-- This file has been generated from package.yaml by hpack version 0.20.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: 64672f76f3aca51f06b95f51917243b73f4f48aecb9c40e4c1bd19cd5818481a -library- exposed-modules:- Data.Impossible- Data.Impossible.Compact- build-depends:- base >=4.6 && <4.9,- lens >=4.13- default-language: Haskell2010- default-extensions: ConstraintKinds DataKinds DefaultSignatures- DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric- DeriveTraversable DoAndIfThenElse EmptyDataDecls FlexibleContexts- FlexibleInstances GeneralizedNewtypeDeriving InstanceSigs- LambdaCase MultiParamTypeClasses OverloadedStrings- StandaloneDeriving TemplateHaskell TupleSections TypeOperators- ViewPatterns TypeFamilies- hs-source-dirs: src- ghc-options: -Wall -O2+name: impossible+version: 1.1.1+synopsis: Set of data and type definitions of impossible types. Impossible types are useful when declaring type classes / type families instances that should not be expanded by GHC until a specific type is provided in order to keep the types nice and readable.+category: Data+stability: experimental+homepage: https://github.com/luna/impossible+bug-reports: https://github.com/luna/impossible/issues+author: Luna Team+maintainer: Wojciech Danilo <wojciech.danilo@luna-lang.org>+copyright: Copyright (C) 2018 Luna Team+license: Apache-2.0+license-file: LICENSE+build-type: Simple+cabal-version: >= 1.10 +library+ hs-source-dirs:+ src+ default-extensions: AllowAmbiguousTypes ApplicativeDo BangPatterns BinaryLiterals ConstraintKinds DataKinds DefaultSignatures DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable DoAndIfThenElse DuplicateRecordFields EmptyDataDecls FlexibleContexts FlexibleInstances FunctionalDependencies GeneralizedNewtypeDeriving InstanceSigs LambdaCase MonadComprehensions MultiWayIf NamedWildCards NegativeLiterals NoImplicitPrelude NumDecimals OverloadedLabels PackageImports QuasiQuotes PatternSynonyms RankNTypes RecursiveDo ScopedTypeVariables StandaloneDeriving TemplateHaskell TupleSections TypeApplications TypeFamilies TypeFamilyDependencies TypeOperators UnicodeSyntax ViewPatterns LiberalTypeSynonyms RelaxedPolyRec+ ghc-options: -Wall -O2+ build-depends:+ base >=4.10 && <4.12+ , lens+ exposed-modules:+ Data.Impossible+ other-modules:+ Paths_impossible+ default-language: Haskell2010
src/Data/Impossible.hs view
@@ -4,29 +4,72 @@ import Prelude import Data.Monoid+import GHC.Stack --- === Types ===+-- === Definitions === -- -data Impossible = Impossible deriving (Show)+data Impossible = Impossible deriving (Show)+class ImpCls -type ImpossibleM = ImpossibleM1-type ImpossibleT = ImpossibleM2 -data ImpossibleM1 t1 = ImpossibleM1 deriving (Show)-data ImpossibleM2 t1 t2 = ImpossibleM2 deriving (Show)-data ImpossibleM3 t1 t2 t3 = ImpossibleM3 deriving (Show)-data ImpossibleM4 t1 t2 t3 t4 = ImpossibleM4 deriving (Show)-data ImpossibleM5 t1 t2 t3 t4 t5 = ImpossibleM5 deriving (Show)+-- === Utils === -- --- ImpNat is defined as the maximum Int on 64 bit architecture. If GHC has some optimizations of Nat Values, it is nice not to exceed the value.-type ImpossibleNat = 9223372036854775807 +impossible :: HasCallStack => a+impossibleTo :: HasCallStack => String -> a+impossible = withFrozenCallStack $ error "Impossible happened" ; {-# INLINE impossible #-}+impossibleTo = withFrozenCallStack . error . ("Impossible happened: " <>) ; {-# INLINE impossibleTo #-} --- === Utils ===+-- === Primitives === -- -impossible :: a-impossible = error "Impossible happened."+-- type instance Imp = Impossible+-- type instance Imp = ImpCls+-- type instance Imp = '[Impossible]+-- type instance Imp = 'Just Imp+--+-- type instance Imp = 9223372036854775807 -- | ImpNat is defined as the maximum Int on 64 bit architecture. If GHC has some optimizations of Nat Values, it is nice not to exceed the value.+-- type instance Imp = "*I*M*P*O*S*S*I*B*L*E*" -- | Impossible definition for typelevel Symbols -impossible' :: String -> a-impossible' = error . ("Impossible happened: " <>)++-- === Parametrized impossibility === --++data ImpossibleM1 t1 = ImpossibleM1 deriving (Show, Functor, Traversable, Foldable)+data ImpossibleM2 t1 t2 = ImpossibleM2 deriving (Show, Functor, Traversable, Foldable)+data ImpossibleM3 t1 t2 t3 = ImpossibleM3 deriving (Show, Functor, Traversable, Foldable)+data ImpossibleM4 t1 t2 t3 t4 = ImpossibleM4 deriving (Show, Functor, Traversable, Foldable)+data ImpossibleM5 t1 t2 t3 t4 t5 = ImpossibleM5 deriving (Show, Functor, Traversable, Foldable)+data ImpossibleM6 t1 t2 t3 t4 t5 t6 = ImpossibleM6 deriving (Show, Functor, Traversable, Foldable)+data ImpossibleM7 t1 t2 t3 t4 t5 t6 t7 = ImpossibleM7 deriving (Show, Functor, Traversable, Foldable)+data ImpossibleM8 t1 t2 t3 t4 t5 t6 t7 t8 = ImpossibleM8 deriving (Show, Functor, Traversable, Foldable)+data ImpossibleM9 t1 t2 t3 t4 t5 t6 t7 t8 t9 = ImpossibleM9 deriving (Show, Functor, Traversable, Foldable)++-- type instance Imp = ImpossibleM1+-- type instance Imp = ImpossibleM2+-- type instance Imp = ImpossibleM3+-- type instance Imp = ImpossibleM4+-- type instance Imp = ImpossibleM5+-- type instance Imp = ImpossibleM6+-- type instance Imp = ImpossibleM7+-- type instance Imp = ImpossibleM8+-- type instance Imp = ImpossibleM9++-- Dummy instances+instance Monad ImpossibleM1 where _ >>= _ = impossible ; {-# INLINE (>>=) #-}+instance Applicative ImpossibleM1 where pure _ = impossible ; {-# INLINE pure #-}+ _ <*> _ = impossible ; {-# INLINE (<*>) #-}+++-- === Abbreviations === --++type Imp = Impossible+type ImpM = ImpossibleM1+type ImpM1 = ImpossibleM1+type ImpM2 = ImpossibleM2+type ImpM3 = ImpossibleM3+type ImpM4 = ImpossibleM4+type ImpM5 = ImpossibleM5+type ImpM6 = ImpossibleM6+type ImpM7 = ImpossibleM7+type ImpM8 = ImpossibleM8+type ImpM9 = ImpossibleM9
− src/Data/Impossible/Compact.hs
@@ -1,6 +0,0 @@-module Data.Impossible.Compact where--import Data.Impossible--type I = Impossible-type IM = ImpossibleM