首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏黯羽轻扬

    类型_Haskell笔记3

    (Show) 通过deriving关键字声明类型派生,让一个类型的值也成为其它类型的成员。 试着直接输出Shape值: > Circle 1 1 1 Circle 1.0 1.0 1.0 干脆把坐标点也抽离出来: data Point = Point Float Float deriving (Show) data Shape = Circle Point Float | Rectangle Point Point deriving (Show) circleArea (Circle _ r 比如派生自Eq后可以通过==和/=来比较值的相等性: data Mytype = Mytype Int String deriving (Show, Eq) > Mytype 3 "a" == Mytype data Mytype = EmptyValue | Singleton | Mytype Int String deriving (Show, Eq, Read, Ord) > EmptyValue

    1.4K40发布于 2019-06-12
  • 来自专栏旅途散记

    听GPT 讲Rust源代码--compiler(47)

    /src/deriving/cmp/目录下,它的作用是实现用于自动派生Ord trait的宏。 首先,encodable.rs文件定义了两个宏expand_deriving_encodable和expand_deriving_decodable,分别用于生成编码(Encodable)和解码(Decodable 对于枚举类型,expand_deriving_encodable和expand_deriving_decodable宏会分别对枚举类型的每个变体调用相应的编码或解码逻辑,并通过编码后的变体标识和包含的数据 /src/deriving/debug.rs文件的作用是实现自动化的Debug派生宏。 /deriving/default.rs 文件是 Rust 编译器源代码中用于实现默认推导的宏。

    63910编辑于 2024-04-26
  • 来自专栏刘笑江的专栏

    learn-haskell

    ) (take (x) fib)) Day3 类与类型 自定义类型 {- cards.hs -} module Main where data Suit = Spades | Hearts deriving (Show) data Rank = Ten | Jack | Queen | King | Ace deriving (Show) type Card = (Rank, Suit) backwards (h:t) = backwards t ++ [h] 多态数据类型 类型相同的三元组、 module Main where data Triplet a = Trio a a a deriving Trio Trio :: a -> a -> a -> Triplet a 树 module Main where data Tree a = Children [Tree a] | Leaf a deriving d3 = crawl d2 in d3 Monad Approach module Main where data Position t = Position t deriving

    1.7K30发布于 2018-05-28
  • 来自专栏我的独立博客

    Haskell 自定义type与typeclass

    自定义type Part One Haskell中使用data关键字来定义新的数据类型: data BookInfo = Book Int String [String] deriving (Show) 我们可以这样定义我们的List: data List a = Empty | Cons a (List a) deriving(Show,Read,Ord) 用record syntax表示: data List a = Empty | Cons {headList::a, tailList::List a} deriving(Show,Read,Ord) ghci> Empty Empty ghci ,这样他们就会自动拥有中缀的性质,同样的我们可以套用在值构造器上,因为他们不过是回传类型的函数而已 infixr 5 :-: data List a = Empty | a :-: (List a) deriving let a = 3 :-: 4 :-: 5 :-: Empty ghci> 100 :-: a (:-:) 100 ((:-:) 3 ((:-:) 4 ((:-:) 5 Empty))) haskell在deriving

    79010编辑于 2024-09-02
  • 来自专栏区块链大本营

    七夕送礼很发愁?自己编写一个区块链送女友吧~

    Control.Comonad.Cofree import Data.Data import qualified Data.Vector as V newtype Account = Account Integer deriving data Transaction = Transaction { _from :: Account, _to :: Account, _amount :: Integer } deriving (Eq, Show) newtype BlockF a = Block (V.Vector a) deriving (Eq, Show, Foldable, Traversable, Functor SHA1 data BlockHeader = BlockHeader { _miner :: Account, _parentHash :: HaskoinHash } deriving (Eq, Show) data MerkleF a = Genesis | Node BlockHeader a deriving (Eq

    1.3K160发布于 2018-05-10
  • Haskell网络爬虫:视频列表获取案例分析

    fromDocument, ($//), ($/), (&/), (&//), (>=>))data Video = Video { title :: String , link :: String } deriving import Data.ByteString.Lazy (ByteString)data Video = Video { title :: String , link :: String } deriving

    62010编辑于 2024-05-29
  • 来自专栏旅途散记

    听GPT 讲Rust源代码--compiler(48)

    File: rust/compiler/rustc_builtin_macros/src/deriving/hash.rs 在Rust源代码中,rust/compiler/rustc_builtin_macros /src/deriving/hash.rs文件的作用是实现了#[derive(Hash)]宏。 /src/deriving/generic/ty.rs的作用是定义了一些用于泛型派生的类型相关的结构体和枚举。 /src/deriving/generic/mod.rs文件负责实现通用派生宏。 /src/deriving/clone.rs文件的作用是为自动化派生(deriving) Clone trait 提供实现。

    52610编辑于 2024-04-26
  • 来自专栏python进阶学习

    Haskell网络爬虫:视频列表获取案例分析

    //), ($/), (&/), (&//), (>=>)) data Video = Video { title :: String , link :: String } deriving Data.ByteString.Lazy (ByteString) data Video = Video { title :: String , link :: String } deriving

    55410编辑于 2024-06-08
  • 来自专栏CreateAMind

    神经突触算法结构图大全(13篇论文汇总)

    processing scheme based on the dendritic integration in a single neuron 13 A normative framework for deriving

    27910编辑于 2023-09-13
  • 来自专栏小赵Java总结

    【源码分析】Spring依赖注入原理

    AnnotationConfigApplicationContext的源码,查看其构造函数如下: /** * Create a new AnnotationConfigApplicationContext, deriving componentClasses) { registerBean(componentClass); } } /** * Register a bean from the given bean class, deriving 进入doRegisterBean: /** * Register a bean from the given bean class, deriving its metadata from * AnnotationConfigApplicationContext的源码,查看其构造函数如下: /** * Create a new AnnotationConfigApplicationContext, deriving

    1.7K31编辑于 2022-12-01
  • 来自专栏Tech Explorer

    [翻译]轻松7步,导出Y结合子

    本文译自 “Deriving the Y Combinator in 7 Easy Steps“, 原文链接:http://igstan.ro/posts/2010-12-01-deriving-the-y-combinator-in

    43920发布于 2021-06-25
  • 来自专栏小徐学爬虫

    用Haskell语言和wreq库配合HTTP写个爬虫程序

    JSON 响应,格式为:{"id": 1, "name": "example"}data Response = Response { id :: Int, name :: String} deriving setRequestProxy proxy req-- 数据类型用于解析 JSONdata Response = Response { id :: Int, name :: String} deriving

    98410编辑于 2025-03-10
  • 来自专栏黯羽轻扬

    Monoid_Haskell笔记9

    ,所以像创造ZipList一样,我们创造出了Sum和Product类(位于Data.Monoid): newtype Product a = Product { getProduct :: a } deriving (Eq, Ord, Read, Show, Bounded, Generic, Generic1, Num) newtype Sum a = Sum { getSum :: a } deriving Num类似,Bool值也存在两个幺半群:||运算与幺元False,&&运算与幺元True: -- ||运算与幺元False newtype Any = Any { getAny :: Bool } deriving |)instance Monoid Any where mempty = Any False-- &&运算与幺元True newtype All = All { getAll :: Bool } deriving fromList ) whereimport Data.Monoid import Data.Foldabledata Tree a = EmptyTree | Node a (Tree a) (Tree a) deriving

    1.2K30发布于 2019-06-12
  • 来自专栏Java架构师必看

    RedHat yum的配置[通俗易懂]

    If there is no such line in /etc/yum.conf, then yum infers the correct value by deriving the version

    4.1K30编辑于 2022-07-25
  • 来自专栏CSDN旧文

    1745 Divisibility

    One can place + or - operators between integers in the sequence, thus deriving different arithmetical

    33320发布于 2020-10-28
  • 来自专栏我的独立博客

    haskell 中的newtype

    haskell中一般使用data关键字来自定义type,像这样: data BookInfo = Book Int String [String] deriving (Show) 但有些情况下要使用newtype

    1K10编辑于 2024-09-02
  • 来自专栏CreateAMind

    皮层回路实时学习的神经元最小作用原理 2023

    Methods Euler-Lagrange equations as inverse low-pass filters Deriving the network dynamics from the Euler-Lagrange equations Deriving the error backpropagation formula Supplementary information A Extracting

    37820编辑于 2023-09-01
  • 来自专栏GEE数据专栏,GEE学习专栏,GEE错误集等专栏

    Google Earth Engine——HydroSHEDS是基于2000年NASA的航天飞机雷达地形任务(SRTM)获得的高程数据

    conditioning process alters the original DEM and may render it incorrect for applications other than deriving

    38210编辑于 2024-02-02
  • 来自专栏黯羽轻扬

    深入typeclass_Haskell笔记4

    派生自某类(deriving (SomeTypeclass))是说具有某类定义的行为,相当于OOP中的实现了某个接口,所以具有接口定义的行为 一.声明 class关键字用来定义新的typeclass: 类似于函数调用,也有柯里化特性,可以进行部分应用(partially apply) 还有一些更奇怪的kind,例如: data Frank a b = Frank {frankField :: b a} deriving

    93310发布于 2019-06-12
  • 来自专栏前端杂货铺

    深入seajs源码系列二

    script = getCurrentScript() if (script) { meta.uri = script.src } // NOTE: If the id-deriving // the end of the insert execution, so use `currentlyAddingScript` to // hold current node, for deriving

    1.1K80发布于 2018-03-15
领券