blarney-0.1.0.0
Copyright(c) Alexandre Joannou 2019
LicenseMIT
Maintaineralexandre.joannou@gmail.com
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageGHC2021

Blarney.Option

Contents

Description

An Option type, similar to Maybe in functionality but represented as a pair of a flag and a value.

Synopsis

Option type

data Option t Source #

Option type to wrap a value. An 'Option t' is represented as a pair of a 'Bit 1' indicating whether the value held is valid, and a value of type t.

Constructors

Option 

Fields

Instances

Instances details
Functor Option # 
Instance details

Defined in Blarney.Option

Methods

fmap :: (a -> b) -> Option a -> Option b #

(<$) :: a -> Option b -> Option a #

Generic (Option t) # 
Instance details

Defined in Blarney.Option

Associated Types

type Rep (Option t) :: Type -> Type #

Methods

from :: Option t -> Rep (Option t) x #

to :: Rep (Option t) x -> Option t #

Cmp t => Cmp (Option t) # 
Instance details

Defined in Blarney.Option

Methods

(.<.) :: Option t -> Option t -> Bit 1 Source #

(.<=.) :: Option t -> Option t -> Bit 1 Source #

(.==.) :: Option t -> Option t -> Bit 1 Source #

(.>.) :: Option t -> Option t -> Bit 1 Source #

(.>=.) :: Option t -> Option t -> Bit 1 Source #

(.!=.) :: Option t -> Option t -> Bit 1 Source #

Bits t => Bits (Option t) # 
Instance details

Defined in Blarney.Option

Associated Types

type SizeOf (Option t) :: Nat Source #

FShow t => FShow (Option t) # 
Instance details

Defined in Blarney.Option

Interface t => Interface (Option t) # 
Instance details

Defined in Blarney.Option

type Rep (Option t) # 
Instance details

Defined in Blarney.Option

type Rep (Option t) = D1 ('MetaData "Option" "Blarney.Option" "blarney-0.1.0.0-inplace" 'False) (C1 ('MetaCons "Option" 'PrefixI 'True) (S1 ('MetaSel ('Just "valid") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Bit 1)) :*: S1 ('MetaSel ('Just "val") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 t)))
type SizeOf (Option t) # 
Instance details

Defined in Blarney.Option

type SizeOf (Option t) = GSizeOf (Rep (Option t))

some :: Bits t => t -> Option t Source #

Builds an Option with a valid value

none :: Bits t => Option t Source #

Builds an invalid Option

isSome :: Bits t => Option t -> Bit 1 Source #

Tests if an Option is a some

isNone :: Bits t => Option t -> Bit 1 Source #

Tests if an Option is a none

fromOption :: Bits t => t -> Option t -> t Source #

Gets the value from a valid Option, or a given default value otherwise