Commit 01480a7c authored by Tim Steenvoorden's avatar Tim Steenvoorden
Browse files

add Enum class

parent d5fdd9ab
definition module Algebra.Enum
from Data.Nat import :: Nat
// import Algebra.Enum._Internal
// import Clean._SystemEnum
import _SystemEnum
/// # Class
class Enum a where
toEnum :: !Nat -> a // toEnum, enum, object, mapping
fromEnum :: !a -> Nat // fromEnum, natural, numeral, order, position, count
succ :: !a -> a
pred :: !a -> a
enumFrom :: !a -> .[a]
enumFromTo :: !a !a -> .[a]
enumFromThen :: a a -> .[a]
enumFromThenTo :: !a !a !a -> .[a]
implementation module Algebra.Enum
definition module Algebra.Enum._Internal
from Algebra.Order import class Enum(..)
/*
This module must be imported if dotdot expressions are used
[from .. ] -> _from from
[from .. to] -> _from_to from to
[from, then .. ] -> _from_then from then
[from, then .. to] -> _from_then_to from then to
*/
_from x :== enumFrom x
_from_to x y :== enumFromTo x y
_from_then x y :== enumFromThen x y
_from_then_to x y z :== enumFromThenTo x y z
implementation module Algebra.Enum._Internal
definition module Clean._SystemEnum
from Algebra.Enum import class Enum(enumFrom, enumFromTo, enumFromThen, enumFromThenTo)
/*
This module must be imported if dotdot expressions are used
[from .. ] -> _from from
[from .. to] -> _from_to from to
[from, then .. ] -> _from_then from then
[from, then .. to] -> _from_then_to from then to
*/
//FIXME doesn't print right...
_from x :== enumFrom x
_from_to x y :== enumFromTo x y
_from_then x y :== enumFromThen x y
_from_then_to x y z :== enumFromThenTo x y z
implementation module Clean._SystemEnum
definition module Data.Enum
implementation module Data.Enum
definition module _SystemEnum
from Algebra.Enum import class Enum(enumFrom, enumFromTo, enumFromThen, enumFromThenTo)
/*
This module must be imported if dotdot expressions are used
[from .. ] -> _from from
[from .. to] -> _from_to from to
[from, then .. ] -> _from_then from then
[from, then .. to] -> _from_then_to from then to
*/
//FIXME doesn't print right...
_from x :== enumFrom x
_from_to x y :== enumFromTo x y
_from_then x y :== enumFromThen x y
_from_then_to x y z :== enumFromThenTo x y z
implementation module _SystemEnum
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment