-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Overloaded pragmas as a plugin -- -- Implement Overloaded pragmas as a source plugin -- -- For example we can replace -- --
-- {-# LANGUAGE OverloadedStrings #-}
--
--
-- with
--
--
-- {-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Strings #-}
--
@package overloaded
@version 0.1
-- | Overloaded characters.
module Overloaded.Chars
-- | Class for Char-like datastructures
--
-- A character literal x is desugared to
--
-- -- fromChar 'x' --class FromChar a fromChar :: FromChar a => Char -> a instance Overloaded.Chars.FromChar GHC.Types.Char -- | Overloaded if-expression. module Overloaded.If -- | Class for Bool-like datastrucutres -- -- An if--expression if b then t else e is desugared to -- --
-- ifte (toBool b) t e ---- -- Enabled with: -- --
-- {-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:If #-}
--
class ToBool b
toBool :: ToBool b => b -> Bool
-- | ToBool overloaded if-expression.
ifte :: ToBool b => b -> a -> a -> a
instance Overloaded.If.ToBool GHC.Types.Bool
instance Overloaded.If.ToBool (GHC.Maybe.Maybe a)
instance Overloaded.If.ToBool (Data.Either.Either b a)
-- | Another way to desugar overloaded numeric literals. See
-- FromNatural.
--
-- An explicit list expression, e.g. [1, True] is desugared to
--
-- -- cons 1 (cons True nil) ---- -- Enabled with: -- --
-- {-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Lists #-}
--
module Overloaded.Lists
-- | Class for nil, []
--
-- See test-suite for ways to define instances for Map. There are
-- at-least two-ways.
class Nil a
nil :: Nil a => a
-- | Class for Cons :.
class Cons x ys zs | zs -> x ys
cons :: Cons x ys zs => x -> ys -> zs
instance Overloaded.Lists.Cons a [a] [a]
instance Overloaded.Lists.Cons a [a] (GHC.Base.NonEmpty a)
instance Overloaded.Lists.Cons a (Data.Vec.Lazy.Vec n a) (Data.Vec.Lazy.Vec ('Data.Nat.S n) a)
instance Overloaded.Lists.Cons (f x) (Data.SOP.NP.NP f xs) (Data.SOP.NP.NP f (x : xs))
instance Overloaded.Lists.Cons (Data.SOP.NP.NP f xs) (Data.SOP.NP.POP f xss) (Data.SOP.NP.POP f (xs : xss))
instance Overloaded.Lists.Nil [a]
instance (n Data.Type.Equality.~ 'Data.Nat.Z) => Overloaded.Lists.Nil (Data.Vec.Lazy.Vec n a)
instance (xs Data.Type.Equality.~ '[]) => Overloaded.Lists.Nil (Data.SOP.NP.NP f xs)
instance (xs Data.Type.Equality.~ '[]) => Overloaded.Lists.Nil (Data.SOP.NP.POP f xs)
-- | Overloaded natural numbers.
module Overloaded.Naturals
-- | Class for Natural-like datastructures
--
-- A numeric literal 42 is desugared to
--
-- -- fromNatural 42 --class FromNatural a fromNatural :: FromNatural a => Natural -> a instance Overloaded.Naturals.FromNatural GHC.Natural.Natural instance Overloaded.Naturals.FromNatural GHC.Integer.Type.Integer -- | Another way to desugar overloaded numeric literals. See -- FromNumeral. module Overloaded.Numerals -- | Another way to desugar numerals. -- -- A numeric literal 123 is desugared to -- --
-- fromNumeral @123 ---- -- Enabled with: -- --
-- {-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Numerals #-}
--
--
-- One can do type-level computations with this.
class FromNumeral (n :: Nat) a
fromNumeral :: FromNumeral n a => a
-- | Default implementation of fromNumeral.
--
-- Usage example:
--
-- -- instance (KnownNat n, ...) => FromNumeral n MyType where -- fromNumeral = defaultFromNumeral @n --defaultFromNumeral :: forall n a. (KnownNat n, Integral a) => a instance Overloaded.Numerals.FinFromNumeral 'Data.Nat.Z ('Data.Nat.S m) instance Overloaded.Numerals.FinFromNumeral n m => Overloaded.Numerals.FinFromNumeral ('Data.Nat.S n) ('Data.Nat.S m) instance (Overloaded.Numerals.FinFromNumeral (Data.Type.Nat.FromGHC n) m, Overloaded.Numerals.IsLess (Data.Type.Nat.FromGHC n) m n (Data.Type.Nat.ToGHC m)) => Overloaded.Numerals.FromNumeral n (Data.Fin.Fin m) instance (GHC.TypeNats.KnownNat n, Overloaded.Numerals.OverflowCheck n "Word8" (n GHC.TypeNats.<=? 255)) => Overloaded.Numerals.FromNumeral n GHC.Word.Word8 instance (GHC.TypeNats.KnownNat n, Overloaded.Numerals.OverflowCheck n "Word8" (n GHC.TypeNats.<=? 65535)) => Overloaded.Numerals.FromNumeral n GHC.Word.Word16 instance (GHC.TypeNats.KnownNat n, Overloaded.Numerals.OverflowCheck n "Word8" (n GHC.TypeNats.<=? 4294967295)) => Overloaded.Numerals.FromNumeral n GHC.Word.Word32 instance (GHC.TypeNats.KnownNat n, Overloaded.Numerals.OverflowCheck n "Word8" (n GHC.TypeNats.<=? 18446744073709551615)) => Overloaded.Numerals.FromNumeral n GHC.Word.Word64 instance GHC.TypeNats.KnownNat n => Overloaded.Numerals.FromNumeral n GHC.Natural.Natural instance GHC.TypeNats.KnownNat n => Overloaded.Numerals.FromNumeral n GHC.Integer.Type.Integer instance GHC.TypeNats.KnownNat n => Overloaded.Numerals.FromNumeral n GHC.Types.Int instance GHC.TypeNats.KnownNat n => Overloaded.Numerals.FromNumeral n Data.Nat.Nat -- | Overloaded plugin, which makes magic possible. module Overloaded.Plugin -- | Overloaded plugin. -- -- To enable plugin put the following at top of the module: -- --
-- {-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Symbols #-}
--
--
-- At least one option is required, multiple can given either using
-- multiple -fplugin-opt options, or by separating options with
-- colon:
--
--
-- {-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Symbols:Numerals #-}
--
--
-- Options also take optional desugaring names, for example
--
--
-- {-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Labels=Data.Generics.ProductFields.field #-}
--
--
-- to desugar OverloadedLabels directly into field from
-- generics-lens (no need to import orphan instance!)
--
-- -- fromSymbol @"example" ---- -- Enabled with: -- --
-- {-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Symbols #-}
--
class FromSymbol (s :: Symbol) a
fromSymbol :: FromSymbol s a => a
instance (GHC.TypeLits.KnownSymbol s, Overloaded.Symbols.SeqList (Data.Symbol.Ascii.Internal.ToList s)) => Overloaded.Symbols.FromSymbol s Data.ByteString.Internal.ByteString
instance (GHC.TypeLits.KnownSymbol s, Overloaded.Symbols.SeqList (Data.Symbol.Ascii.Internal.ToList s)) => Overloaded.Symbols.FromSymbol s Data.ByteString.Lazy.Internal.ByteString
instance (GHC.TypeLits.KnownSymbol s, a Data.Type.Equality.~ GHC.Types.Char) => Overloaded.Symbols.FromSymbol s [a]
instance GHC.TypeLits.KnownSymbol s => Overloaded.Symbols.FromSymbol s Data.Text.Internal.Text
instance GHC.TypeLits.KnownSymbol s => Overloaded.Symbols.FromSymbol s Data.Text.Internal.Lazy.Text
-- | Overloaded* language extensions as a source plugin.
module Overloaded
-- | Overloaded plugin.
--
-- To enable plugin put the following at top of the module:
--
--
-- {-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Symbols #-}
--
--
-- At least one option is required, multiple can given either using
-- multiple -fplugin-opt options, or by separating options with
-- colon:
--
--
-- {-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Symbols:Numerals #-}
--
--
-- Options also take optional desugaring names, for example
--
--
-- {-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Labels=Data.Generics.ProductFields.field #-}
--
--
-- to desugar OverloadedLabels directly into field from
-- generics-lens (no need to import orphan instance!)
--
-- -- fromSymbol @"example" ---- -- Enabled with: -- --
-- {-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Symbols #-}
--
class FromSymbol (s :: Symbol) a
fromSymbol :: FromSymbol s a => a
-- | Another way to desugar numerals.
--
-- A numeric literal 123 is desugared to
--
-- -- fromNumeral @123 ---- -- Enabled with: -- --
-- {-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:Numerals #-}
--
--
-- One can do type-level computations with this.
class FromNumeral (n :: Nat) a
fromNumeral :: FromNumeral n a => a
-- | Default implementation of fromNumeral.
--
-- Usage example:
--
-- -- instance (KnownNat n, ...) => FromNumeral n MyType where -- fromNumeral = defaultFromNumeral @n --defaultFromNumeral :: forall n a. (KnownNat n, Integral a) => a -- | Class for Natural-like datastructures -- -- A numeric literal 42 is desugared to -- --
-- fromNatural 42 --class FromNatural a fromNatural :: FromNatural a => Natural -> a -- | Class for Char-like datastructures -- -- A character literal x is desugared to -- --
-- fromChar 'x' --class FromChar a fromChar :: FromChar a => Char -> a -- | Class for nil, [] -- -- See test-suite for ways to define instances for Map. There are -- at-least two-ways. class Nil a nil :: Nil a => a -- | Class for Cons :. class Cons x ys zs | zs -> x ys cons :: Cons x ys zs => x -> ys -> zs -- | Class for Bool-like datastrucutres -- -- An if--expression if b then t else e is desugared to -- --
-- ifte (toBool b) t e ---- -- Enabled with: -- --
-- {-# OPTIONS -fplugin=Overloaded -fplugin-opt=Overloaded:If #-}
--
class ToBool b
toBool :: ToBool b => b -> Bool
-- | ToBool overloaded if-expression.
ifte :: ToBool b => b -> a -> a -> a