`
tangtong
  • 浏览: 62485 次
  • 来自: ...
社区版块
存档分类
最新评论

Iterate abstract --Basic

阅读更多

不存在“无中生有”,物理学家寻找基本粒子,我们即是上帝,数学家用定义和公理确定这些“基本例子”。下面我来总结一下Haskell里面最Basic的基本粒子。

 

Bool

-- |The 'Bool' type is an enumeration.  It is defined with 'False'
-- first so that the corresponding 'Prelude.Enum' instance will give
-- 'Prelude.fromEnum' 'False' the value zero, and
-- 'Prelude.fromEnum' 'True' the value 1.
data  Bool  =  False | True  deriving (Eq, Ord)

        -- Read in GHC.Read, Show in GHC.Show

Ordering

-- | Represents an ordering relationship between two values: less
-- than, equal to, or greater than.  An 'Ordering' is returned by
-- 'compare'.
data Ordering = LT | EQ | GT deriving (Eq, Ord)

        -- Read in GHC.Read, Show in GHC.Show

 Char

{-| The character type 'Char' is an enumeration whose values represent
Unicode (or equivalently ISO\/IEC 10646) characters
(see <http://www.unicode.org/> for details).
This set extends the ISO 8859-1 (Latin-1) character set
(the first 256 charachers), which is itself an extension of the ASCII
character set (the first 128 characters).
A character literal in Haskell has type 'Char'.

To convert a 'Char' to or from the corresponding 'Int' value defined
by Unicode, use 'Prelude.toEnum' and 'Prelude.fromEnum' from the
'Prelude.Enum' class respectively (or equivalently 'ord' and 'chr').
-}
data Char = C# Char#


-- We don't use deriving for Eq and Ord, because for Ord the derived
-- instance defines only compare, which takes two primops.  Then
-- '>' uses compare, and therefore takes two primops instead of one.

 Int

data Int = I# Int#

-- ^A fixed-precision integer type with at least the range @[-2^29 .. 2^29-1]@.
-- The exact range for a given implementation can be determined by using
-- 'Prelude.minBound' and 'Prelude.maxBound' from the 'Prelude.Bounded' class.

 Integer

-- | Arbitrary-precision integers.
data Integer    

= S# Int# -- small integers #ifndef ILX
| J# Int# ByteArray# -- large integers #else
| J# Void BigInteger -- .NET big ints foreign type dotnet "BigInteger" BigInteger #endif

 Float

-- | Single-precision floating point numbers.
-- It is desirable that this type be at least equal in range and precision
-- to the IEEE single-precision type.
data Float      = F# Float#

 Double

-- | Double-precision floating point numbers.
-- It is desirable that this type be at least equal in range and precision
-- to the IEEE double-precision type.
data Double     = D# Double#

 Basic Monads(有些不合时宜,先放在这里)

IO Monad

{-|
A value of type @'IO' a@ is a computation which, when performed,
does some I\/O before returning a value of type @a@.  

There is really only one way to \"perform\" an I\/O action: bind it to
@Main.main@ in your program.  When your program is run, the I\/O will
be performed.  It isn't possible to perform I\/O from an arbitrary
function, unless that function is itself in the 'IO' monad and called
at some point, directly or indirectly, from @Main.main@.

'IO' is a monad, so 'IO' actions can be combined using either the do-notation
or the '>>' and '>>=' operations from the 'Monad' class.
-}
newtype IO a = IO (State# RealWorld -> (# State# RealWorld, a #))

 Maybe Monad

-- | The 'Maybe' type encapsulates an optional value.  A value of type
-- @'Maybe' a@ either contains a value of type @a@ (represented as @'Just' a@), 
-- or it is empty (represented as 'Nothing').  Using 'Maybe' is a good way to 
-- deal with errors or exceptional cases without resorting to drastic
-- measures such as 'error'.
--
-- The 'Maybe' type is also a monad.  It is a simple kind of error
-- monad, where all errors are represented by 'Nothing'.  A richer
-- error monad can be built using the 'Data.Either.Either' type.

data  Maybe a  =  Nothing | Just a

deriving (Eq, Ord)

 Either Monad

{-|

The 'Either' type represents values with two possibilities: a value of
type @'Either' a b@ is either @'Left' a@ or @'Right' b@.

The 'Either' type is sometimes used to represent a value which is
either correct or an error; by convention, the 'Left' constructor is
used to hold an error value and the 'Right' constructor is used to
hold a correct value (mnemonic: \"right\" also means \"correct\").
-}
data  Either a b  =  Left a | Right b   deriving (Eq, Ord ) 
分享到:
评论

相关推荐

    PyPI 官网下载 | plone.app.iterate-1.0a1.2-py2.4.egg

    资源来自pypi官网。 资源全名:plone.app.iterate-1.0a1.2-py2.4.egg

    Python库 | plone.app.iterate-1.0b1.1-py2.4.egg

    资源分类:Python库 所属语言:Python 资源全名:plone.app.iterate-1.0b1.1-py2.4.egg 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    初级java笔试题-iterate-clojure-workshop12:迭代clojure-workshop12

    iterate-clojure-workshop12 或者,将其解压缩到某处并输入。 要准备好您需要的所有工具,请执行附加的脚本(如果您已经安装了 Leiningen 或 Catnip,您可能需要检查/修改它): bash$ source prepare_all.sh # Note...

    Python库 | plone.app.iterate-1.0a1.2.tar.gz

    标题中的"plone.app.iterate-1.0a1.2.tar.gz"是一个Python库的压缩包文件,属于Plone生态的一部分。Plone是一个开源的内容管理系统(CMS),它基于Zope应用服务器,广泛用于构建企业级网站、内网、知识管理和协作...

    iterate-summer-javascript-class-2018:夏季项目迭代

    -v $( pwd ) /src:/home/iterate/application/src \ iterate/summer-class:latest CRA沸腾板 该项目是通过引导的。 您将在下面找到一些有关如何执行常见任务的信息。 您可以在找到本指南的最新版本。 目录 可用...

    iterate-keywords-开源

    修补(http://www.cl-user.net/asp/libs/iterate)迭代以允许(iter(:for从1到10)(:collect i))而不是(iter(for i从1到10)(收集我))

    hayk-assessment-iterate-over-collections

    给定一个对象数组: class Company attr_accessor :name, :size def initialize(name, size) @name = name @size = size end end companies = [ Company.new('Alpha', 30), Company.new('Beta', 300), ...

    struts-logic iterate标签学习指南

    Struts-Logic Iterate标签是Apache Struts框架中的一个重要组件,用于在JSP页面中迭代集合对象,如数组、列表或Map。这个标签提供了一种简洁的方式来遍历数据,并且可以与Struts的其他标签(如`bean:write`)配合...

    ibatis中iterate的例子

    在iBatis中,`&lt;iterate&gt;`标签是一个非常实用的功能,它允许我们处理集合数据,如数组、List或Map等,进行循环遍历并生成动态SQL语句。下面我们将详细探讨`&lt;iterate&gt;`标签的用法及其示例。 `&lt;iterate&gt;`标签的主要...

    iterate-until:迭代调用函数直到满足条件

    npm install iterate-until bower install iterate-until 用法 var iterateUntil = require ( 'iterate-until' ) ; function addTwo ( i ) { return i + 2 ; } function isLessThanEight ( n ) { return n &lt; 8...

    struts 标签 logic:iterate使用 logic:iterate

    在`struts`的标签库中,`logic:iterate`是一个非常重要的标签,用于遍历集合对象,如`List`、`Map`或数组,并对每个元素执行循环操作。 `logic:iterate`标签的主要属性包括: 1. `id`: 用于给循环中的当前元素创建...

    Android代码-android-Camera2Basic

    You can learn how to iterate through characteristics of all the cameras attached to the device, display a camera preview, and take pictures. Introduction The Camera2 API provides an interface to ...

    logic:iterate 是什么,怎么用

    ### logic:iterate 标签详解 #### 一、概述 `logic:iterate` 是 Struts 标签库中的一个重要组成部分,主要用于在 JSP 页面中循环遍历集合对象(如 List、Array 或 Map 等)。它能够有效地帮助开发者在前端展示动态...

    ibatis标签

    标题中的“ibatis&lt;iterate&gt;标签”指的是在iBATIS框架中用于动态SQL的一个关键功能。iBATIS是一个优秀的持久层框架,它允许将SQL语句直接嵌入到Java代码中,简化了数据库操作。而`&lt;iterate&gt;`标签是iBATIS提供的一个...

    day37 04-Hibernate二级缓存:list和iterate方法比较

    今天我们将探讨的是Hibernate的二级缓存,特别是`list`和`iterate`方法的区别,这对于优化数据库访问性能至关重要。 一级缓存是Hibernate内置的,它是Session级别的缓存,自动管理实体对象的生命周期。然而,一级...

    iterate-开源

    Iterate是Bravais-lattice-finding算法的实现,该算法来自:Andrews和Bernstein,Acta Cryst。 (1988)。 A44、1009-1018晶格和精简细胞作为6空间中的点,并通过投影选择了Bravais晶格类型。

    Pandas Cheat Sheet

    # All categories (/pandas) | # Import, version (/pandas/import-version)...# Iterate over data (/pandas/iterate-over-data) | # Aggregate data (/pandas/aggregate-data) | # Save & Load (/pandas/save-load) |

    jsp脚本和标签:实现循环和分支逻辑

    jsp脚本和&lt;logic:iterate&gt;标签:实现循环和分支逻辑 jsp脚本和&lt;logic:iterate&gt;标签:实现循环和分支逻辑 jsp脚本和&lt;logic:iterate&gt;标签:实现循环和分支逻辑

    random-iterate:以随机顺序迭代列表中的值

    var iterate = require ( 'random-iterate' ) var ite = iterate ( [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] ) console . log ( ite ( ) ) // maybe 4 console . log ( ite ( ) ) // maybe 9 . . . 7 more time . . ...

Global site tag (gtag.js) - Google Analytics