express-0.1.8: Dynamically-typed expressions involving applications and variables.
Copyright(c) 2016-2021 Rudy Matela
License3-Clause BSD (see the file LICENSE)
MaintainerRudy Matela <rudy@matela.com.br>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Express.Utils.Typeable

Description

This module is part of Express.

Utilities to manipulate TypeReps (of Typeable values).

Synopsis

Documentation

elementTy :: TypeRep -> TypeRep Source #

This function returns the type of the element of a list. It will throw an error when not given the list type.

> > elementTy $ typeOf (undefined :: [Int])
Int
> > elementTy $ typeOf (undefined :: [[Int]])
[Int]
> > elementTy $ typeOf (undefined :: [Bool])
Bool
> > elementTy $ typeOf (undefined :: Bool)
*** Exception: error (elementTy): `Bool' is not a list type

typesIn :: TypeRep -> [TypeRep] Source #

O(n). Return all sub types of a given type including itself.

> typesIn $ typeOf (undefined :: Int)
[Int]
> typesIn $ typeOf (undefined :: Bool)
[Bool]
> typesIn $ typeOf (undefined :: [Int])
[ Int
, [Int]
]
> typesIn $ typeOf (undefined :: Int -> Int -> Int)
[ Int
, Int -> Int
, Int -> Int -> Int
]
> typesIn $ typeOf (undefined :: Int -> [Int] -> [Int])
[ Int
, [Int]
, [Int] -> [Int]
, Int -> [Int] -> [Int]
]
> typesIn $ typeOf (undefined :: Maybe Bool)
[ Bool
, Maybe Bool
]

(->::) :: TypeRep -> TypeRep -> TypeRep infixr 9 Source #

An infix alias for mkFunTy. It is right associative.